@workday/canvas-kit-labs-react 14.2.0-0055-next.0 → 14.2.0-0059-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/index.d.ts +1 -0
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +1 -0
- package/dist/commonjs/side-panel/index.d.ts +4 -0
- package/dist/commonjs/side-panel/index.d.ts.map +1 -0
- package/dist/commonjs/side-panel/index.js +19 -0
- package/dist/commonjs/side-panel/lib/SidePanel.d.ts +205 -0
- package/dist/commonjs/side-panel/lib/SidePanel.d.ts.map +1 -0
- package/dist/commonjs/side-panel/lib/SidePanel.js +64 -0
- package/dist/commonjs/side-panel/lib/SidePanelToggleButton.d.ts +95 -0
- package/dist/commonjs/side-panel/lib/SidePanelToggleButton.d.ts.map +1 -0
- package/dist/commonjs/side-panel/lib/SidePanelToggleButton.js +65 -0
- package/dist/commonjs/side-panel/lib/useSidePanelModel.d.ts +514 -0
- package/dist/commonjs/side-panel/lib/useSidePanelModel.d.ts.map +1 -0
- package/dist/commonjs/side-panel/lib/useSidePanelModel.js +134 -0
- package/dist/es6/index.d.ts +1 -0
- package/dist/es6/index.d.ts.map +1 -1
- package/dist/es6/index.js +1 -0
- package/dist/es6/side-panel/index.d.ts +4 -0
- package/dist/es6/side-panel/index.d.ts.map +1 -0
- package/dist/es6/side-panel/index.js +3 -0
- package/dist/es6/side-panel/lib/SidePanel.d.ts +205 -0
- package/dist/es6/side-panel/lib/SidePanel.d.ts.map +1 -0
- package/dist/es6/side-panel/lib/SidePanel.js +61 -0
- package/dist/es6/side-panel/lib/SidePanelToggleButton.d.ts +95 -0
- package/dist/es6/side-panel/lib/SidePanelToggleButton.d.ts.map +1 -0
- package/dist/es6/side-panel/lib/SidePanelToggleButton.js +62 -0
- package/dist/es6/side-panel/lib/useSidePanelModel.d.ts +514 -0
- package/dist/es6/side-panel/lib/useSidePanelModel.d.ts.map +1 -0
- package/dist/es6/side-panel/lib/useSidePanelModel.js +108 -0
- package/index.ts +1 -0
- package/package.json +4 -4
- package/side-panel/index.ts +3 -0
- package/side-panel/lib/SidePanel.tsx +131 -0
- package/side-panel/lib/SidePanelToggleButton.tsx +177 -0
- package/side-panel/lib/useSidePanelModel.ts +128 -0
- package/side-panel/package.json +6 -0
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
package/dist/commonjs/index.js
CHANGED
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./ai-ingress-button"), exports);
|
|
18
18
|
__exportStar(require("./combobox"), exports);
|
|
19
19
|
__exportStar(require("./search-form"), exports);
|
|
20
|
+
__exportStar(require("./side-panel"), exports);
|
|
20
21
|
__exportStar(require("./version"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../side-panel/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./lib/SidePanel"), exports);
|
|
18
|
+
__exportStar(require("./lib/SidePanelToggleButton"), exports);
|
|
19
|
+
__exportStar(require("./lib/useSidePanelModel"), exports);
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Adds the necessary props to the SidePanel container element.
|
|
4
|
+
* This includes the `id` and `aria-labelledby` attributes for accessibility.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useSidePanelContainer: import("@workday/canvas-kit-react/common").BehaviorHook<{
|
|
7
|
+
state: {
|
|
8
|
+
panelId: string;
|
|
9
|
+
labelId: string;
|
|
10
|
+
transitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
11
|
+
initialTransitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
12
|
+
origin: "end" | "start";
|
|
13
|
+
onStateTransition(state: import("./useSidePanelModel").SidePanelTransitionStates): void;
|
|
14
|
+
};
|
|
15
|
+
events: {
|
|
16
|
+
expand(): void;
|
|
17
|
+
collapse(): void;
|
|
18
|
+
handleAnimationEnd(event: React.TransitionEvent<HTMLDivElement>): React.TransitionEvent<HTMLDivElement>;
|
|
19
|
+
handleAnimationStart(): undefined;
|
|
20
|
+
};
|
|
21
|
+
}, {
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly 'aria-labelledby': string;
|
|
24
|
+
readonly onTransitionEnd: (event: React.TransitionEvent<HTMLDivElement>) => React.TransitionEvent<HTMLDivElement>;
|
|
25
|
+
}>;
|
|
26
|
+
export type SidePanelVariant = 'standard' | 'alternate';
|
|
27
|
+
export interface SidePanelProps {
|
|
28
|
+
/**
|
|
29
|
+
* The width of the component (in `px` if it's a `number`) when it is collapsed.
|
|
30
|
+
*
|
|
31
|
+
* @default 64
|
|
32
|
+
*/
|
|
33
|
+
collapsedWidth?: number | string;
|
|
34
|
+
/**
|
|
35
|
+
* The width of the component (in `px` if it's a `number`) when it is expanded.
|
|
36
|
+
*
|
|
37
|
+
* @default 320
|
|
38
|
+
*/
|
|
39
|
+
expandedWidth?: number | string;
|
|
40
|
+
/**
|
|
41
|
+
* The style variant of the side panel. 'standard' uses a lighter gray background (`system.color.bg.alt.softer`), no depth. 'alternate' uses a white background with depth (`system.color.bg.default` and level 5 depth).
|
|
42
|
+
*
|
|
43
|
+
* @default 'standard'
|
|
44
|
+
*/
|
|
45
|
+
variant?: SidePanelVariant;
|
|
46
|
+
children?: React.ReactNode;
|
|
47
|
+
}
|
|
48
|
+
export declare const panelStencil: import("@workday/canvas-kit-styling").Stencil<{
|
|
49
|
+
variant: {
|
|
50
|
+
alternate: {
|
|
51
|
+
backgroundColor: "--cnvs-sys-color-bg-default";
|
|
52
|
+
boxShadow: "--cnvs-sys-depth-5";
|
|
53
|
+
};
|
|
54
|
+
standard: {
|
|
55
|
+
backgroundColor: "--cnvs-sys-color-bg-alt-softer";
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
expanded: {
|
|
59
|
+
expanded: ({ expandedWidth }: {
|
|
60
|
+
expandedWidth: `--${string}`;
|
|
61
|
+
collapsedWidth: `--${string}`;
|
|
62
|
+
} & import("@workday/canvas-kit-styling").StencilVarsParts<{}>) => {
|
|
63
|
+
width: `--${string}`;
|
|
64
|
+
maxWidth: `--${string}`;
|
|
65
|
+
};
|
|
66
|
+
collapsed: ({ collapsedWidth }: {
|
|
67
|
+
expandedWidth: `--${string}`;
|
|
68
|
+
collapsedWidth: `--${string}`;
|
|
69
|
+
} & import("@workday/canvas-kit-styling").StencilVarsParts<{}>) => {
|
|
70
|
+
width: `--${string}`;
|
|
71
|
+
maxWidth: `--${string}`;
|
|
72
|
+
};
|
|
73
|
+
expanding: ({ expandedWidth }: {
|
|
74
|
+
expandedWidth: `--${string}`;
|
|
75
|
+
collapsedWidth: `--${string}`;
|
|
76
|
+
} & import("@workday/canvas-kit-styling").StencilVarsParts<{}>) => {
|
|
77
|
+
width: `--${string}`;
|
|
78
|
+
maxWidth: `--${string}`;
|
|
79
|
+
};
|
|
80
|
+
collapsing: ({ collapsedWidth }: {
|
|
81
|
+
expandedWidth: `--${string}`;
|
|
82
|
+
collapsedWidth: `--${string}`;
|
|
83
|
+
} & import("@workday/canvas-kit-styling").StencilVarsParts<{}>) => {
|
|
84
|
+
width: `--${string}`;
|
|
85
|
+
maxWidth: `--${string}`;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
}, {}, {
|
|
89
|
+
expandedWidth: string;
|
|
90
|
+
collapsedWidth: string;
|
|
91
|
+
}, never, never>;
|
|
92
|
+
export declare const SidePanel: import("@workday/canvas-kit-react/common").ElementComponentM<"section", SidePanelProps & Partial<{
|
|
93
|
+
initialTransitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
94
|
+
origin: "end" | "start";
|
|
95
|
+
panelId: string;
|
|
96
|
+
labelId: string;
|
|
97
|
+
onStateTransition(state: import("./useSidePanelModel").SidePanelTransitionStates): void;
|
|
98
|
+
}> & {
|
|
99
|
+
onExpand?: ((data: undefined, prevState: {
|
|
100
|
+
panelId: string;
|
|
101
|
+
labelId: string;
|
|
102
|
+
transitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
103
|
+
initialTransitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
104
|
+
origin: "end" | "start";
|
|
105
|
+
onStateTransition(state: import("./useSidePanelModel").SidePanelTransitionStates): void;
|
|
106
|
+
}) => void) | undefined;
|
|
107
|
+
onCollapse?: ((data: undefined, prevState: {
|
|
108
|
+
panelId: string;
|
|
109
|
+
labelId: string;
|
|
110
|
+
transitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
111
|
+
initialTransitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
112
|
+
origin: "end" | "start";
|
|
113
|
+
onStateTransition(state: import("./useSidePanelModel").SidePanelTransitionStates): void;
|
|
114
|
+
}) => void) | undefined;
|
|
115
|
+
onHandleAnimationEnd?: ((data: React.TransitionEvent<HTMLDivElement>, prevState: {
|
|
116
|
+
panelId: string;
|
|
117
|
+
labelId: string;
|
|
118
|
+
transitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
119
|
+
initialTransitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
120
|
+
origin: "end" | "start";
|
|
121
|
+
onStateTransition(state: import("./useSidePanelModel").SidePanelTransitionStates): void;
|
|
122
|
+
}) => void) | undefined;
|
|
123
|
+
onHandleAnimationStart?: ((data: undefined, prevState: {
|
|
124
|
+
panelId: string;
|
|
125
|
+
labelId: string;
|
|
126
|
+
transitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
127
|
+
initialTransitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
128
|
+
origin: "end" | "start";
|
|
129
|
+
onStateTransition(state: import("./useSidePanelModel").SidePanelTransitionStates): void;
|
|
130
|
+
}) => void) | undefined;
|
|
131
|
+
} & {
|
|
132
|
+
shouldExpand?: ((data: undefined, state: {
|
|
133
|
+
panelId: string;
|
|
134
|
+
labelId: string;
|
|
135
|
+
transitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
136
|
+
initialTransitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
137
|
+
origin: "end" | "start";
|
|
138
|
+
onStateTransition(state: import("./useSidePanelModel").SidePanelTransitionStates): void;
|
|
139
|
+
}) => boolean) | undefined;
|
|
140
|
+
shouldCollapse?: ((data: undefined, state: {
|
|
141
|
+
panelId: string;
|
|
142
|
+
labelId: string;
|
|
143
|
+
transitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
144
|
+
initialTransitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
145
|
+
origin: "end" | "start";
|
|
146
|
+
onStateTransition(state: import("./useSidePanelModel").SidePanelTransitionStates): void;
|
|
147
|
+
}) => boolean) | undefined;
|
|
148
|
+
shouldHandleAnimationEnd?: ((data: React.TransitionEvent<HTMLDivElement>, state: {
|
|
149
|
+
panelId: string;
|
|
150
|
+
labelId: string;
|
|
151
|
+
transitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
152
|
+
initialTransitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
153
|
+
origin: "end" | "start";
|
|
154
|
+
onStateTransition(state: import("./useSidePanelModel").SidePanelTransitionStates): void;
|
|
155
|
+
}) => boolean) | undefined;
|
|
156
|
+
shouldHandleAnimationStart?: ((data: undefined, state: {
|
|
157
|
+
panelId: string;
|
|
158
|
+
labelId: string;
|
|
159
|
+
transitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
160
|
+
initialTransitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
161
|
+
origin: "end" | "start";
|
|
162
|
+
onStateTransition(state: import("./useSidePanelModel").SidePanelTransitionStates): void;
|
|
163
|
+
}) => boolean) | undefined;
|
|
164
|
+
}, {
|
|
165
|
+
state: {
|
|
166
|
+
panelId: string;
|
|
167
|
+
labelId: string;
|
|
168
|
+
transitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
169
|
+
initialTransitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
170
|
+
origin: "end" | "start";
|
|
171
|
+
onStateTransition(state: import("./useSidePanelModel").SidePanelTransitionStates): void;
|
|
172
|
+
};
|
|
173
|
+
events: {
|
|
174
|
+
expand(): void;
|
|
175
|
+
collapse(): void;
|
|
176
|
+
handleAnimationEnd(event: React.TransitionEvent<HTMLDivElement>): React.TransitionEvent<HTMLDivElement>;
|
|
177
|
+
handleAnimationStart(): undefined;
|
|
178
|
+
};
|
|
179
|
+
}> & {
|
|
180
|
+
/**
|
|
181
|
+
* `SidePanel.ToggleButton` is a control that toggles between expanded and collapsed states.
|
|
182
|
+
* It must be used within the `SidePanel` component as a child. For accessibility purposes,
|
|
183
|
+
* it should be the first focusable element in the panel.
|
|
184
|
+
*
|
|
185
|
+
* The button automatically receives `aria-controls`, `aria-expanded`, and `aria-labelledby`
|
|
186
|
+
* attributes from the model.
|
|
187
|
+
*/
|
|
188
|
+
ToggleButton: import("@workday/canvas-kit-react/common").ElementComponentM<"button", import("./SidePanelToggleButton").SidePanelToggleButtonProps, {
|
|
189
|
+
state: {
|
|
190
|
+
panelId: string;
|
|
191
|
+
labelId: string;
|
|
192
|
+
transitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
193
|
+
initialTransitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
194
|
+
origin: "end" | "start";
|
|
195
|
+
onStateTransition(state: import("./useSidePanelModel").SidePanelTransitionStates): void;
|
|
196
|
+
};
|
|
197
|
+
events: {
|
|
198
|
+
expand(): void;
|
|
199
|
+
collapse(): void;
|
|
200
|
+
handleAnimationEnd(event: React.TransitionEvent<HTMLDivElement>): React.TransitionEvent<HTMLDivElement>;
|
|
201
|
+
handleAnimationStart(): undefined;
|
|
202
|
+
};
|
|
203
|
+
}>;
|
|
204
|
+
};
|
|
205
|
+
//# sourceMappingURL=SidePanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidePanel.d.ts","sourceRoot":"","sources":["../../../../side-panel/lib/SidePanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;EAMhC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,WAAW,CAAC;AAExD,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC;;;;OAIG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAyCvB,CAAC;AAEH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAKlB;;;;;;;OAOG;;;;;;;;;;;;;;;;;CAgCN,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SidePanel = exports.panelStencil = exports.useSidePanelContainer = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
6
|
+
const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
|
|
7
|
+
const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
|
|
8
|
+
const useSidePanelModel_1 = require("./useSidePanelModel");
|
|
9
|
+
const SidePanelToggleButton_1 = require("./SidePanelToggleButton");
|
|
10
|
+
/**
|
|
11
|
+
* Adds the necessary props to the SidePanel container element.
|
|
12
|
+
* This includes the `id` and `aria-labelledby` attributes for accessibility.
|
|
13
|
+
*/
|
|
14
|
+
exports.useSidePanelContainer = (0, common_1.createElemPropsHook)(useSidePanelModel_1.useSidePanelModel)(({ state, events }) => {
|
|
15
|
+
return {
|
|
16
|
+
id: state.panelId,
|
|
17
|
+
'aria-labelledby': state.labelId,
|
|
18
|
+
onTransitionEnd: events.handleAnimationEnd,
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
exports.panelStencil = (0, canvas_kit_styling_1.createStencil)({
|
|
22
|
+
vars: {
|
|
23
|
+
expandedWidth: '',
|
|
24
|
+
collapsedWidth: '',
|
|
25
|
+
},
|
|
26
|
+
base: { name: "23943w", styles: "box-sizing:border-box;overflow:hidden;position:relative;height:100%;outline:0.0625rem solid transparent;transition:width ease-out 200ms, max-width ease-out 200ms;" },
|
|
27
|
+
modifiers: {
|
|
28
|
+
variant: {
|
|
29
|
+
alternate: { name: "2bjjfl", styles: "background-color:var(--cnvs-sys-color-bg-default);box-shadow:var(--cnvs-sys-depth-5);" },
|
|
30
|
+
standard: { name: "1lsdyl", styles: "background-color:var(--cnvs-sys-color-bg-alt-softer);" }
|
|
31
|
+
},
|
|
32
|
+
expanded: {
|
|
33
|
+
expanded: { name: "i9o5v", styles: "width:var(--expandedWidth-panel-46751f);max-width:var(--expandedWidth-panel-46751f);" },
|
|
34
|
+
collapsed: { name: "3tfzp8", styles: "width:var(--collapsedWidth-panel-46751f);max-width:var(--collapsedWidth-panel-46751f);" },
|
|
35
|
+
expanding: { name: "42gyid", styles: "width:var(--expandedWidth-panel-46751f);max-width:var(--expandedWidth-panel-46751f);" },
|
|
36
|
+
collapsing: { name: "mk8xq", styles: "width:var(--collapsedWidth-panel-46751f);max-width:var(--collapsedWidth-panel-46751f);" }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}, "panel-46751f");
|
|
40
|
+
exports.SidePanel = (0, common_1.createContainer)('section')({
|
|
41
|
+
displayName: 'SidePanel',
|
|
42
|
+
modelHook: useSidePanelModel_1.useSidePanelModel,
|
|
43
|
+
elemPropsHook: exports.useSidePanelContainer,
|
|
44
|
+
subComponents: {
|
|
45
|
+
/**
|
|
46
|
+
* `SidePanel.ToggleButton` is a control that toggles between expanded and collapsed states.
|
|
47
|
+
* It must be used within the `SidePanel` component as a child. For accessibility purposes,
|
|
48
|
+
* it should be the first focusable element in the panel.
|
|
49
|
+
*
|
|
50
|
+
* The button automatically receives `aria-controls`, `aria-expanded`, and `aria-labelledby`
|
|
51
|
+
* attributes from the model.
|
|
52
|
+
*/
|
|
53
|
+
ToggleButton: SidePanelToggleButton_1.SidePanelToggleButton,
|
|
54
|
+
},
|
|
55
|
+
})(({ collapsedWidth = 64, expandedWidth = 320, variant = 'standard', children, ...elemProps }, Element, model) => {
|
|
56
|
+
return ((0, jsx_runtime_1.jsx)(Element, { ...(0, canvas_kit_styling_1.handleCsProp)(elemProps, [
|
|
57
|
+
(0, exports.panelStencil)({
|
|
58
|
+
expanded: model.state.transitionState,
|
|
59
|
+
variant,
|
|
60
|
+
expandedWidth: typeof expandedWidth === 'number' ? (0, canvas_kit_styling_1.px2rem)(expandedWidth) : expandedWidth,
|
|
61
|
+
collapsedWidth: typeof collapsedWidth === 'number' ? (0, canvas_kit_styling_1.px2rem)(collapsedWidth) : collapsedWidth,
|
|
62
|
+
}),
|
|
63
|
+
]), children: children }));
|
|
64
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ExtractProps } from '@workday/canvas-kit-react/common';
|
|
3
|
+
import { TertiaryButton } from '@workday/canvas-kit-react/button';
|
|
4
|
+
import { TooltipProps } from '@workday/canvas-kit-react/tooltip';
|
|
5
|
+
export interface SidePanelToggleButtonProps extends ExtractProps<typeof TertiaryButton> {
|
|
6
|
+
/**
|
|
7
|
+
* The tooltip text to expand the side panel
|
|
8
|
+
*/
|
|
9
|
+
tooltipTextExpand?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The tooltip text to collapse the side panel
|
|
12
|
+
*/
|
|
13
|
+
tooltipTextCollapse?: string;
|
|
14
|
+
tooltipProps?: Omit<TooltipProps, 'children'>;
|
|
15
|
+
}
|
|
16
|
+
export declare const sidePanelToggleButtonStencil: import("@workday/canvas-kit-styling").Stencil<{
|
|
17
|
+
state: {
|
|
18
|
+
collapsing: {
|
|
19
|
+
margin: number;
|
|
20
|
+
transform: string;
|
|
21
|
+
':dir(rtl)': {
|
|
22
|
+
transform: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
collapsed: {
|
|
26
|
+
margin: string;
|
|
27
|
+
insetInlineStart: number;
|
|
28
|
+
insetInlineEnd: number;
|
|
29
|
+
transform: string;
|
|
30
|
+
':dir(rtl)': {
|
|
31
|
+
transform: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
expanded: {
|
|
35
|
+
margin: number;
|
|
36
|
+
transform: string;
|
|
37
|
+
':dir(rtl)': {
|
|
38
|
+
transform: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
expanding: {
|
|
42
|
+
margin: number;
|
|
43
|
+
transform: string;
|
|
44
|
+
':dir(rtl)': {
|
|
45
|
+
transform: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
origin: {
|
|
50
|
+
start: {};
|
|
51
|
+
end: {
|
|
52
|
+
transform: string;
|
|
53
|
+
':dir(rtl)': {
|
|
54
|
+
transform: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
}, {}, {}, never, never>;
|
|
59
|
+
export declare const useSidePanelToggleButtonElemProps: import("@workday/canvas-kit-react/common").BehaviorHook<{
|
|
60
|
+
state: {
|
|
61
|
+
panelId: string;
|
|
62
|
+
labelId: string;
|
|
63
|
+
transitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
64
|
+
initialTransitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
65
|
+
origin: "end" | "start";
|
|
66
|
+
onStateTransition(state: import("./useSidePanelModel").SidePanelTransitionStates): void;
|
|
67
|
+
};
|
|
68
|
+
events: {
|
|
69
|
+
expand(): void;
|
|
70
|
+
collapse(): void;
|
|
71
|
+
handleAnimationEnd(event: React.TransitionEvent<HTMLDivElement>): React.TransitionEvent<HTMLDivElement>;
|
|
72
|
+
handleAnimationStart(): undefined;
|
|
73
|
+
};
|
|
74
|
+
}, {
|
|
75
|
+
readonly 'aria-controls': string;
|
|
76
|
+
readonly 'aria-expanded': boolean;
|
|
77
|
+
readonly 'aria-labelledby': string;
|
|
78
|
+
}>;
|
|
79
|
+
export declare const SidePanelToggleButton: import("@workday/canvas-kit-react/common").ElementComponentM<"button", SidePanelToggleButtonProps, {
|
|
80
|
+
state: {
|
|
81
|
+
panelId: string;
|
|
82
|
+
labelId: string;
|
|
83
|
+
transitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
84
|
+
initialTransitionState: import("./useSidePanelModel").SidePanelTransitionStates;
|
|
85
|
+
origin: "end" | "start";
|
|
86
|
+
onStateTransition(state: import("./useSidePanelModel").SidePanelTransitionStates): void;
|
|
87
|
+
};
|
|
88
|
+
events: {
|
|
89
|
+
expand(): void;
|
|
90
|
+
collapse(): void;
|
|
91
|
+
handleAnimationEnd(event: React.TransitionEvent<HTMLDivElement>): React.TransitionEvent<HTMLDivElement>;
|
|
92
|
+
handleAnimationStart(): undefined;
|
|
93
|
+
};
|
|
94
|
+
}>;
|
|
95
|
+
//# sourceMappingURL=SidePanelToggleButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidePanelToggleButton.d.ts","sourceRoot":"","sources":["../../../../side-panel/lib/SidePanelToggleButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAGL,YAAY,EACb,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AAEhE,OAAO,EAAU,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAKxE,MAAM,WAAW,0BAA2B,SAAQ,YAAY,CAAC,OAAO,cAAc,CAAC;IACrF;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;CAC/C;AAED,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA+FvC,CAAC;AAEH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;EAQ7C,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;EA4CjC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SidePanelToggleButton = exports.useSidePanelToggleButtonElemProps = exports.sidePanelToggleButtonStencil = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
6
|
+
const button_1 = require("@workday/canvas-kit-react/button");
|
|
7
|
+
const canvas_system_icons_web_1 = require("@workday/canvas-system-icons-web");
|
|
8
|
+
const tooltip_1 = require("@workday/canvas-kit-react/tooltip");
|
|
9
|
+
const useSidePanelModel_1 = require("./useSidePanelModel");
|
|
10
|
+
const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
|
|
11
|
+
const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
|
|
12
|
+
exports.sidePanelToggleButtonStencil = (0, canvas_kit_styling_1.createStencil)({
|
|
13
|
+
base: { name: "1etqp8", styles: "box-sizing:border-box;position:absolute;top:var(--cnvs-sys-space-x6);width:var(--cnvs-sys-space-x8);inset-inline-end:var(--cnvs-sys-space-x4);" },
|
|
14
|
+
modifiers: {
|
|
15
|
+
state: {
|
|
16
|
+
collapsing: { name: "30y959", styles: "margin:0;transform:scaleX(1);:dir(rtl){transform:scaleX(-1);}" },
|
|
17
|
+
collapsed: { name: "xhos1", styles: "margin:auto;inset-inline-start:0;inset-inline-end:0;transform:scaleX(1);:dir(rtl){transform:scaleX(-1);}" },
|
|
18
|
+
expanded: { name: "1ksb21", styles: "margin:0;transform:scaleX(-1);:dir(rtl){transform:scaleX(1);}" },
|
|
19
|
+
expanding: { name: "2ew0xk", styles: "margin:0;transform:scaleX(-1);:dir(rtl){transform:scaleX(1);}" }
|
|
20
|
+
},
|
|
21
|
+
origin: {
|
|
22
|
+
start: { name: "3x19g6", styles: "" },
|
|
23
|
+
end: { name: "1x1y4h", styles: "transform:scaleX(1);:dir(rtl){transform:scaleX(-1);}" }
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
compound: [
|
|
27
|
+
{
|
|
28
|
+
modifiers: { state: 'collapsed', origin: 'end' },
|
|
29
|
+
styles: { name: "2lkeu7", styles: "transform:scaleX(-1);:dir(rtl){transform:scaleX(1);}" }
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
modifiers: { state: 'collapsing', origin: 'end' },
|
|
33
|
+
styles: { name: "42drd4", styles: "transform:scaleX(-1);inset-inline-start:var(--cnvs-sys-space-x4);:dir(rtl){transform:scaleX(1);inset-inline-end:var(--cnvs-sys-space-x4);}" }
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
modifiers: { state: 'expanded', origin: 'end' },
|
|
37
|
+
styles: { name: "16e0u", styles: "transform:scaleX(1);inset-inline-start:var(--cnvs-sys-space-x4);:dir(rtl){transform:scaleX(-1);inset-inline-end:var(--cnvs-sys-space-x4);}" }
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
modifiers: { state: 'expanding', origin: 'end' },
|
|
41
|
+
styles: { name: "1qlm4j", styles: "transform:scaleX(1);inset-inline-start:var(--cnvs-sys-space-x4);:dir(rtl){transform:scaleX(-1);inset-inline-end:var(--cnvs-sys-space-x4);}" }
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}, "side-panel-toggle-button-2c790f");
|
|
45
|
+
exports.useSidePanelToggleButtonElemProps = (0, common_1.createElemPropsHook)(useSidePanelModel_1.useSidePanelModel)(({ state }) => {
|
|
46
|
+
return {
|
|
47
|
+
'aria-controls': state.panelId,
|
|
48
|
+
'aria-expanded': state.transitionState === 'expanded',
|
|
49
|
+
'aria-labelledby': state.labelId,
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
exports.SidePanelToggleButton = (0, common_1.createSubcomponent)('button')({
|
|
53
|
+
displayName: 'SidePanel.ToggleButton',
|
|
54
|
+
modelHook: useSidePanelModel_1.useSidePanelModel,
|
|
55
|
+
elemPropsHook: exports.useSidePanelToggleButtonElemProps,
|
|
56
|
+
})(({ variant = undefined, icon = canvas_system_icons_web_1.transformationImportIcon, tooltipTextExpand = 'Expand', tooltipTextCollapse = 'Collapse', tooltipProps, ...elemProps }, Element, model) => {
|
|
57
|
+
return ((0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { type: "muted", ...tooltipProps, title: model.state.transitionState === 'collapsed' ? tooltipTextExpand : tooltipTextCollapse, children: (0, jsx_runtime_1.jsx)(button_1.TertiaryButton, { icon: icon, as: Element, variant: variant, ...(0, canvas_kit_styling_1.handleCsProp)(elemProps, (0, exports.sidePanelToggleButtonStencil)({
|
|
58
|
+
state: model.state.transitionState,
|
|
59
|
+
origin: model.state.origin,
|
|
60
|
+
})), onClick: (event) => {
|
|
61
|
+
var _a;
|
|
62
|
+
(_a = elemProps.onClick) === null || _a === void 0 ? void 0 : _a.call(elemProps, event);
|
|
63
|
+
model.events.handleAnimationStart();
|
|
64
|
+
} }) }));
|
|
65
|
+
});
|