Skip to content

Commit 3f696fd

Browse files
committed
rename progress component visibility prop to hidden
1 parent 0bee733 commit 3f696fd

13 files changed

Lines changed: 66 additions & 63 deletions

File tree

chartlets.js/CHANGES.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
- `vite: ^8.0.16`
77
- `vitest: ^4.1.8`
88

9-
* Added `visible` support for progress components. Progress indicators can
10-
now be hidden via `visible={false}` and are automatically shown while a
11-
server-side callback with an output such as `Output("progress", "visible")`
9+
* Added `hidden` support for progress components. Progress indicators can
10+
now be hidden via `hidden={false}` and are automatically shown while a
11+
server-side callback with an output such as `Output("progress", "hidden")`
1212
is pending.
1313

1414
## Version 0.2.0 (from 2026/03/11)

chartlets.js/packages/lib/src/actions/helpers/invokeCallbacks.test.ts

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
88

99
import { store } from "@/store";
10-
import type { CallbackRequest, StateChangeRequest } from "@/types/model/callback";
10+
import type {
11+
CallbackRequest,
12+
StateChangeRequest,
13+
} from "@/types/model/callback";
1114
import type { ComponentState } from "@/types/state/component";
1215
import { invokeCallbacks } from "./invokeCallbacks";
1316

@@ -20,8 +23,8 @@ function createDeferred<T>() {
2023
}
2124

2225
function getProgressComponent() {
23-
return (store.getState().contributionsRecord.panels[0].component!
24-
.children![0] as ComponentState);
26+
return store.getState().contributionsRecord.panels[0].component!
27+
.children![0] as ComponentState;
2528
}
2629

2730
const callbackRequest: CallbackRequest = {
@@ -51,15 +54,15 @@ describe("invokeCallbacks", () => {
5154
{
5255
type: "CircularProgress",
5356
id: "progress",
54-
visible: false,
57+
hidden: false,
5558
},
5659
],
5760
},
5861
callbacks: [
5962
{
6063
function: { name: "calculate", parameters: [], return: {} },
6164
inputs: [{ id: "run", property: "clicked" }],
62-
outputs: [{ id: "progress", property: "visible" }],
65+
outputs: [{ id: "progress", property: "hidden" }],
6366
},
6467
],
6568
initialState: {},
@@ -80,29 +83,33 @@ describe("invokeCallbacks", () => {
8083

8184
invokeCallbacks([callbackRequest]);
8285

83-
expect(getProgressComponent().visible).toBe(true);
86+
expect(getProgressComponent().hidden).toBe(true);
8487

85-
deferred.resolve(createCallbackResponse([
86-
{
87-
contribPoint: "panels",
88-
contribIndex: 0,
89-
stateChanges: [{ id: "progress", property: "visible", value: false }],
90-
},
91-
]));
88+
deferred.resolve(
89+
createCallbackResponse([
90+
{
91+
contribPoint: "panels",
92+
contribIndex: 0,
93+
stateChanges: [{ id: "progress", property: "hidden", value: false }],
94+
},
95+
]),
96+
);
9297

9398
await vi.waitFor(() => {
94-
expect(getProgressComponent().visible).toBe(false);
99+
expect(getProgressComponent().hidden).toBe(false);
95100
});
96101
});
97102

98103
it("logs and releases pending progress when a callback fails", async () => {
99104
const deferred = createDeferred<Response>();
100-
const consoleError = vi.spyOn(console, "error").mockImplementation(() => {});
105+
const consoleError = vi
106+
.spyOn(console, "error")
107+
.mockImplementation(() => {});
101108
globalThis.fetch = vi.fn().mockReturnValue(deferred.promise);
102109

103110
invokeCallbacks([callbackRequest]);
104111

105-
expect(getProgressComponent().visible).toBe(true);
112+
expect(getProgressComponent().hidden).toBe(true);
106113

107114
deferred.resolve({
108115
ok: true,
@@ -112,7 +119,7 @@ describe("invokeCallbacks", () => {
112119
} as unknown as Response);
113120

114121
await vi.waitFor(() => {
115-
expect(getProgressComponent().visible).toBe(false);
122+
expect(getProgressComponent().hidden).toBe(false);
116123
});
117124
expect(consoleError).toHaveBeenCalledOnce();
118125
});
@@ -140,4 +147,4 @@ function createCallbackResponse(result: StateChangeRequest[]) {
140147
statusText: "ok",
141148
json: vi.fn().mockResolvedValue({ result }),
142149
} as unknown as Response;
143-
}
150+
}

chartlets.js/packages/lib/src/actions/helpers/pendingProgress.test.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const callbackRequest: CallbackRequest = {
2424
};
2525

2626
function getProgressComponent() {
27-
return (store.getState().contributionsRecord.panels[0].component!
28-
.children![0] as ComponentState);
27+
return store.getState().contributionsRecord.panels[0].component!
28+
.children![0] as ComponentState;
2929
}
3030

3131
describe("pendingProgress", () => {
@@ -47,33 +47,33 @@ describe("pendingProgress", () => {
4747
{
4848
type: "CircularProgress",
4949
id: "progress",
50-
visible: false,
50+
hidden: false,
5151
},
5252
{
5353
type: "Typography",
5454
id: "text",
55-
visible: false,
55+
hidden: false,
5656
},
5757
],
5858
},
5959
callbacks: [
6060
{
6161
function: { name: "calculate", parameters: [], return: {} },
6262
inputs: [{ id: "run", property: "clicked" }],
63-
outputs: [{ id: "progress", property: "visible" }],
63+
outputs: [{ id: "progress", property: "hidden" }],
6464
},
6565
{
6666
function: { name: "duplicate", parameters: [], return: {} },
6767
inputs: [{ id: "run", property: "clicked" }],
6868
outputs: [
69-
{ id: "progress", property: "visible" },
70-
{ id: "progress", property: "visible" },
69+
{ id: "progress", property: "hidden" },
70+
{ id: "progress", property: "hidden" },
7171
],
7272
},
7373
{
7474
function: { name: "text", parameters: [], return: {} },
7575
inputs: [{ id: "run", property: "clicked" }],
76-
outputs: [{ id: "text", property: "visible" }],
76+
outputs: [{ id: "text", property: "hidden" }],
7777
},
7878
{
7979
function: { name: "value", parameters: [], return: {} },
@@ -89,13 +89,13 @@ describe("pendingProgress", () => {
8989
});
9090
});
9191

92-
it("finds progress components targeted by visible callback outputs", () => {
92+
it("finds progress components targeted by hidden callback outputs", () => {
9393
expect(getPendingProgressTargets([callbackRequest])).toEqual([
9494
{
9595
contribPoint: "panels",
9696
contribIndex: 0,
9797
id: "progress",
98-
output: { id: "progress", property: "visible" },
98+
output: { id: "progress", property: "hidden" },
9999
},
100100
]);
101101
});
@@ -108,7 +108,7 @@ describe("pendingProgress", () => {
108108
expect(targets).toHaveLength(1);
109109
});
110110

111-
it("ignores non-progress components and non-visible outputs", () => {
111+
it("ignores non-progress components and non-hidden outputs", () => {
112112
expect(
113113
getPendingProgressTargets([{ ...callbackRequest, callbackIndex: 2 }]),
114114
).toEqual([]);
@@ -137,25 +137,25 @@ describe("pendingProgress", () => {
137137

138138
showPendingProgressTargets(targets);
139139

140-
expect(getProgressComponent().visible).toBe(true);
140+
expect(getProgressComponent().hidden).toBe(true);
141141

142142
releasePendingProgressTargets(targets, false);
143143

144-
expect(getProgressComponent().visible).toBe(false);
144+
expect(getProgressComponent().hidden).toBe(false);
145145
});
146146

147-
it("keeps progress visible until overlapping callbacks have completed", () => {
147+
it("keeps progress hidden until overlapping callbacks have completed", () => {
148148
const targets = getPendingProgressTargets([callbackRequest]);
149149

150150
showPendingProgressTargets(targets);
151151
showPendingProgressTargets(targets);
152152

153153
releasePendingProgressTargets(targets, true);
154154

155-
expect(getProgressComponent().visible).toBe(true);
155+
expect(getProgressComponent().hidden).toBe(true);
156156

157157
releasePendingProgressTargets(targets, false);
158158

159-
expect(getProgressComponent().visible).toBe(false);
159+
expect(getProgressComponent().hidden).toBe(false);
160160
});
161-
});
161+
});

chartlets.js/packages/lib/src/actions/helpers/pendingProgress.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function getPendingProgressTargets(
3939
const callback = contribution?.callbacks?.[callbackIndex];
4040
callback?.outputs?.forEach((output) => {
4141
if (
42-
formatObjPath(output.property) === "visible" &&
42+
formatObjPath(output.property) === "hidden" &&
4343
isProgressComponent(contribution.component, output.id)
4444
) {
4545
const target = { contribPoint, contribIndex, id: output.id, output };
@@ -99,7 +99,7 @@ function decrementPendingProgressCounts(targets: PendingProgressTarget[]) {
9999

100100
function applyPendingProgressTargets(
101101
targets: PendingProgressTarget[],
102-
visible: boolean,
102+
hidden: boolean,
103103
) {
104104
if (targets.length === 0) {
105105
return;
@@ -108,7 +108,7 @@ function applyPendingProgressTargets(
108108
targets.map<StateChangeRequest>((target) => ({
109109
contribPoint: target.contribPoint,
110110
contribIndex: target.contribIndex,
111-
stateChanges: [{ ...target.output, value: visible }],
111+
stateChanges: [{ ...target.output, value: hidden }],
112112
})),
113113
);
114114
}

chartlets.js/packages/lib/src/plugins/mui/CircularProgress.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ describe("CircularProgress", () => {
2323
expect(screen.getByRole("progressbar")).not.toBeUndefined();
2424
});
2525

26-
it("should not render when visible is false", () => {
26+
it("should not render when hidden is false", () => {
2727
render(
2828
<CircularProgress
2929
type="CircularProgress"
3030
id="cp"
31-
visible={false}
31+
hidden={false}
3232
onChange={() => {}}
3333
/>,
3434
);

chartlets.js/packages/lib/src/plugins/mui/CircularProgress.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export const CircularProgress = ({
2222
size,
2323
value,
2424
variant,
25-
visible = true,
25+
hidden = true,
2626
}: CircularProgressProps) => {
27-
if (!visible) {
27+
if (!hidden) {
2828
return null;
2929
}
3030

chartlets.js/packages/lib/src/plugins/mui/LinearProgress.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ describe("LinearProgress", () => {
2323
expect(screen.getByRole("progressbar")).not.toBeUndefined();
2424
});
2525

26-
it("should not render when visible is false", () => {
26+
it("should not render when hidden is false", () => {
2727
render(
2828
<LinearProgress
2929
type="LinearProgress"
3030
id="cp"
31-
visible={false}
31+
hidden={false}
3232
onChange={() => {}}
3333
/>,
3434
);

chartlets.js/packages/lib/src/plugins/mui/LinearProgress.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export const LinearProgress = ({
2121
style,
2222
value,
2323
variant,
24-
visible = true,
24+
hidden = true,
2525
}: LinearProgressProps) => {
26-
if (!visible) {
26+
if (!hidden) {
2727
return null;
2828
}
2929

chartlets.js/packages/lib/src/types/state/component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface ComponentState {
3030
label?: string;
3131
color?: string;
3232
tooltip?: string;
33-
visible?: boolean;
33+
hidden?: boolean;
3434
}
3535

3636
export interface ContainerState extends ComponentState {

chartlets.py/CHANGES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
## Version 0.2.1 (in development)
22

3-
* Added `visible` property to the base `Component` class, so components can
3+
* Added `hidden` property to the base `Component` class, so components can
44
be shown or hidden through callback outputs such as
5-
`Output("progress", "visible")`.
5+
`Output("progress", "hidden")`.
66

77
## Version 0.2.0 (from 2026/03/11)
88

0 commit comments

Comments
 (0)