reshaped 3.6.0-canary.0 → 3.6.0-canary.1
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/CHANGELOG.md +17 -2
- package/dist/bundle.css +1 -1
- package/dist/bundle.d.ts +1 -1
- package/dist/bundle.js +11 -11
- package/dist/components/Accordion/AccordionControlled.js +1 -1
- package/dist/components/Accordion/AccordionTrigger.js +1 -1
- package/dist/components/ActionBar/ActionBar.js +1 -1
- package/dist/components/Actionable/Actionable.js +1 -1
- package/dist/components/Autocomplete/tests/Autocomplete.stories.js +1 -0
- package/dist/components/Avatar/Avatar.js +1 -1
- package/dist/components/Badge/Badge.js +1 -1
- package/dist/components/Badge/BadgeContainer.js +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js +1 -1
- package/dist/components/Button/Button.js +1 -1
- package/dist/components/Button/ButtonGroup.js +1 -1
- package/dist/components/Calendar/CalendarDate.js +1 -1
- package/dist/components/Card/Card.d.ts +1 -1
- package/dist/components/Card/Card.js +1 -1
- package/dist/components/Card/tests/Card.stories.d.ts +1 -1
- package/dist/components/Card/tests/Card.test.stories.d.ts +1 -1
- package/dist/components/Carousel/Carousel.js +4 -3
- package/dist/components/Carousel/CarouselControl.js +1 -1
- package/dist/components/Checkbox/Checkbox.js +1 -1
- package/dist/components/Checkbox/Checkbox.module.css +1 -1
- package/dist/components/Container/Container.js +1 -1
- package/dist/components/Dismissible/Dismissible.js +1 -1
- package/dist/components/Divider/Divider.js +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +1 -1
- package/dist/components/FileUpload/FileUpload.js +1 -1
- package/dist/components/Flyout/FlyoutContent.js +4 -3
- package/dist/components/Flyout/utilities/calculatePosition.d.ts +1 -1
- package/dist/components/Flyout/utilities/calculatePosition.js +1 -1
- package/dist/components/FormControl/FormControl.context.d.ts +0 -2
- package/dist/components/Grid/Grid.js +1 -1
- package/dist/components/Hidden/Hidden.js +1 -1
- package/dist/components/Hotkey/Hotkey.js +1 -1
- package/dist/components/Icon/Icon.js +1 -1
- package/dist/components/Image/Image.js +1 -1
- package/dist/components/Link/Link.js +1 -1
- package/dist/components/Loader/Loader.js +1 -1
- package/dist/components/MenuItem/MenuItem.js +1 -1
- package/dist/components/Modal/Modal.js +1 -1
- package/dist/components/NumberField/NumberFieldControlled.js +1 -1
- package/dist/components/Overlay/Overlay.js +1 -1
- package/dist/components/PinField/PinFieldControlled.js +1 -1
- package/dist/components/Popover/Popover.js +3 -3
- package/dist/components/Popover/Popover.module.css +1 -1
- package/dist/components/Popover/Popover.types.d.ts +1 -0
- package/dist/components/Popover/tests/Popover.stories.d.ts +46 -7
- package/dist/components/Popover/tests/Popover.stories.js +209 -85
- package/dist/components/Progress/Progress.js +1 -1
- package/dist/components/ProgressIndicator/ProgressIndicator.js +1 -1
- package/dist/components/Radio/Radio.js +1 -1
- package/dist/components/Radio/Radio.module.css +1 -1
- package/dist/components/Reshaped/Reshaped.js +1 -1
- package/dist/components/Resizable/Resizable.js +1 -1
- package/dist/components/Scrim/Scrim.js +1 -1
- package/dist/components/ScrollArea/ScrollArea.js +8 -11
- package/dist/components/ScrollArea/ScrollArea.module.css +1 -1
- package/dist/components/ScrollArea/tests/ScrollArea.stories.d.ts +13 -4
- package/dist/components/ScrollArea/tests/ScrollArea.stories.js +129 -30
- package/dist/components/Select/Select.js +1 -1
- package/dist/components/Skeleton/Skeleton.js +1 -1
- package/dist/components/Slider/Slider.types.d.ts +34 -7
- package/dist/components/Slider/SliderControlled.js +32 -20
- package/dist/components/Slider/SliderThumb.js +4 -4
- package/dist/components/Slider/SliderUncontrolled.js +3 -2
- package/dist/components/Slider/tests/Slider.stories.d.ts +38 -8
- package/dist/components/Slider/tests/Slider.stories.js +268 -54
- package/dist/components/Stepper/Stepper.js +1 -1
- package/dist/components/Switch/Switch.js +1 -1
- package/dist/components/Table/Table.js +6 -3
- package/dist/components/Table/Table.module.css +1 -1
- package/dist/components/Tabs/TabsItem.js +1 -1
- package/dist/components/Tabs/TabsList.js +3 -34
- package/dist/components/Tabs/TabsPanel.js +1 -1
- package/dist/components/Text/Text.js +1 -1
- package/dist/components/TextArea/TextArea.js +1 -1
- package/dist/components/TextField/TextField.js +1 -1
- package/dist/components/Theme/Theme.js +1 -1
- package/dist/components/Timeline/Timeline.js +1 -1
- package/dist/components/Toast/ToastContainer.js +1 -1
- package/dist/components/Toast/ToastRegion.js +1 -1
- package/dist/components/View/View.js +1 -1
- package/dist/components/_private/Aligner/Aligner.js +1 -1
- package/dist/components/_private/Expandable/Expandable.js +1 -1
- package/dist/components/_private/HiddenInput/HiddenInput.js +1 -1
- package/dist/hooks/_private/useFadeSide.d.ts +5 -0
- package/dist/hooks/_private/useFadeSide.js +47 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/styles/align/index.js +1 -1
- package/dist/styles/aspectRatio/index.js +1 -1
- package/dist/styles/bleed/index.js +1 -1
- package/dist/styles/border/index.js +1 -1
- package/dist/styles/height/index.js +1 -1
- package/dist/styles/inset/index.js +1 -1
- package/dist/styles/justify/index.js +1 -1
- package/dist/styles/maxHeight/index.js +1 -1
- package/dist/styles/maxWidth/index.js +1 -1
- package/dist/styles/minHeight/index.js +1 -1
- package/dist/styles/minWidth/index.js +1 -1
- package/dist/styles/padding/index.js +1 -1
- package/dist/styles/position/index.js +1 -1
- package/dist/styles/radius/index.js +1 -1
- package/dist/styles/textAlign/index.js +1 -1
- package/dist/styles/width/index.js +1 -1
- package/dist/utilities/dom/event.d.ts +7 -0
- package/dist/utilities/dom/event.js +11 -0
- package/dist/utilities/dom/index.d.ts +1 -0
- package/dist/utilities/dom/index.js +1 -0
- package/dist/utilities/helpers.d.ts +1 -15
- package/dist/utilities/helpers.js +11 -133
- package/dist/utilities/props.d.ts +13 -0
- package/dist/utilities/props.js +83 -0
- package/package.json +25 -26
- package/dist/components/Popover/tests/Popover.test.stories.d.ts +0 -39
- package/dist/components/Popover/tests/Popover.test.stories.js +0 -167
- package/dist/components/ScrollArea/tests/ScrollArea.test.stories.d.ts +0 -23
- package/dist/components/ScrollArea/tests/ScrollArea.test.stories.js +0 -66
- package/dist/components/Slider/tests/Slider.test.stories.d.ts +0 -38
- package/dist/components/Slider/tests/Slider.test.stories.js +0 -150
@@ -1,7 +1,8 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { expect, fireEvent, fn } from "@storybook/test";
|
1
3
|
import { Example } from "../../../utilities/storybook/index.js";
|
2
4
|
import Slider from "../index.js";
|
3
5
|
import View from "../../View/index.js";
|
4
|
-
import FormControl from "../../FormControl/index.js";
|
5
6
|
import Modal from "../../Modal/index.js";
|
6
7
|
import useToggle from "../../../hooks/useToggle.js";
|
7
8
|
export default {
|
@@ -13,59 +14,272 @@ export default {
|
|
13
14
|
},
|
14
15
|
},
|
15
16
|
};
|
16
|
-
export const base =
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
17
|
+
export const base = {
|
18
|
+
name: "name, minName, maxName, range",
|
19
|
+
render: () => (<Example>
|
20
|
+
<Example.Item title="single, name">
|
21
|
+
<Slider name="slider-single" defaultValue={30}/>
|
22
|
+
</Example.Item>
|
23
|
+
<Example.Item title="range, name">
|
24
|
+
<Slider range name="slider-range" defaultMinValue={30} defaultMaxValue={85}/>
|
25
|
+
</Example.Item>
|
26
|
+
<Example.Item title="range, minName, maxName">
|
27
|
+
<Slider range minName="slider-min" maxName="slider-max" defaultMinValue={30} defaultMaxValue={85}/>
|
28
|
+
</Example.Item>
|
29
|
+
<div style={{ height: 2000 }}/>
|
30
|
+
</Example>),
|
31
|
+
play: ({ canvas }) => {
|
32
|
+
const inputs = canvas.getAllByRole("slider");
|
33
|
+
expect(inputs[0]).toHaveAttribute("name", "slider-single");
|
34
|
+
expect(inputs[1]).toHaveAttribute("name", "slider-range");
|
35
|
+
expect(inputs[2]).toHaveAttribute("name", "slider-range");
|
36
|
+
expect(inputs[3]).toHaveAttribute("name", "slider-min");
|
37
|
+
expect(inputs[4]).toHaveAttribute("name", "slider-max");
|
38
|
+
},
|
39
|
+
};
|
40
|
+
export const orientation = {
|
41
|
+
name: "orientation",
|
42
|
+
render: () => (<Example>
|
43
|
+
<Example.Item title="orientation: vertical">
|
44
|
+
<View height="200px">
|
45
|
+
<Slider range name="slider" defaultMinValue={30} defaultMaxValue={85} orientation="vertical"/>
|
46
|
+
</View>
|
47
|
+
</Example.Item>
|
27
48
|
<View height="2000px"/>
|
28
|
-
</Example
|
29
|
-
|
30
|
-
export const
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
49
|
+
</Example>),
|
50
|
+
};
|
51
|
+
export const minMax = {
|
52
|
+
name: "min, max",
|
53
|
+
render: () => (<Example>
|
54
|
+
<Example.Item title="min, max">
|
55
|
+
<Slider name="name" min={50} max={70} defaultValue={60}/>
|
56
|
+
</Example.Item>
|
57
|
+
<Example.Item title="min, max, value < min">
|
58
|
+
<Slider name="name" min={50} max={70} defaultValue={30}/>
|
59
|
+
</Example.Item>
|
60
|
+
<Example.Item title="min, max, value > max">
|
61
|
+
<Slider name="name" min={50} max={70} defaultValue={80}/>
|
62
|
+
</Example.Item>
|
63
|
+
</Example>),
|
64
|
+
play: async ({ canvas }) => {
|
65
|
+
const inputs = canvas.getAllByRole("slider");
|
66
|
+
expect(inputs[0]).toHaveAttribute("min", "50");
|
67
|
+
expect(inputs[0]).toHaveAttribute("max", "70");
|
68
|
+
expect(inputs[0]).toHaveValue("60");
|
69
|
+
fireEvent.change(inputs[0], { target: { value: 30 } });
|
70
|
+
expect(inputs[0]).toHaveValue("50");
|
71
|
+
fireEvent.change(inputs[0], { target: { value: 80 } });
|
72
|
+
expect(inputs[0]).toHaveValue("70");
|
73
|
+
expect(inputs[1]).toHaveValue("50");
|
74
|
+
expect(inputs[2]).toHaveValue("70");
|
75
|
+
},
|
76
|
+
};
|
77
|
+
export const step = {
|
78
|
+
name: "step",
|
79
|
+
render: () => (<Example>
|
80
|
+
<Example.Item title="step: 5">
|
81
|
+
<Slider name="slider" defaultValue={30} step={5}/>
|
82
|
+
</Example.Item>
|
83
|
+
|
84
|
+
<Example.Item title="step: 5, defaultValue: 31, rounded down to 30">
|
85
|
+
<Slider name="slider" defaultValue={31} step={5}/>
|
86
|
+
</Example.Item>
|
87
|
+
|
88
|
+
<Example.Item title="step: 0.01, float">
|
89
|
+
<Slider name="slider" defaultValue={30} step={0.01}/>
|
90
|
+
</Example.Item>
|
91
|
+
</Example>),
|
92
|
+
play: ({ canvas }) => {
|
93
|
+
const inputs = canvas.getAllByRole("slider");
|
94
|
+
expect(inputs[0]).toHaveValue("30");
|
95
|
+
fireEvent.change(inputs[0], { target: { value: 31 } });
|
96
|
+
expect(inputs[0]).toHaveValue("30");
|
97
|
+
fireEvent.change(inputs[0], { target: { value: 34 } });
|
98
|
+
expect(inputs[0]).toHaveValue("35");
|
99
|
+
expect(inputs[1]).toHaveValue("30");
|
100
|
+
},
|
101
|
+
};
|
102
|
+
export const disabled = {
|
103
|
+
name: "disabled",
|
104
|
+
render: () => (<Example>
|
105
|
+
<Example.Item title="disabled">
|
106
|
+
<Slider name="slider" defaultValue={30} disabled/>
|
107
|
+
</Example.Item>
|
58
108
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
109
|
+
<Example.Item title="disabled, range">
|
110
|
+
<Slider name="slider" range defaultMinValue={30} defaultMaxValue={80} disabled/>
|
111
|
+
</Example.Item>
|
112
|
+
</Example>),
|
113
|
+
play: async ({ canvas }) => {
|
114
|
+
const inputs = canvas.getAllByRole("slider");
|
115
|
+
expect(inputs[0]).toBeDisabled();
|
116
|
+
expect(inputs[1]).toBeDisabled();
|
117
|
+
},
|
118
|
+
};
|
119
|
+
export const renderValue = {
|
120
|
+
name: "renderValue",
|
121
|
+
render: () => (<Example>
|
122
|
+
<Example.Item title="renderValue: $">
|
123
|
+
<Slider name="name" defaultValue={50} renderValue={(args) => `$${args.value}`}/>
|
124
|
+
</Example.Item>
|
125
|
+
<Example.Item title="renderValue: false">
|
126
|
+
<Slider name="name" defaultValue={50} renderValue={false}/>
|
127
|
+
</Example.Item>
|
128
|
+
</Example>),
|
129
|
+
play: async ({ canvas }) => {
|
130
|
+
const tooltip = canvas.getByText("$50");
|
131
|
+
const hiddenTooltip = canvas.queryByText("50");
|
132
|
+
expect(tooltip).toBeInTheDocument();
|
133
|
+
expect(hiddenTooltip).not.toBeInTheDocument();
|
134
|
+
},
|
135
|
+
};
|
136
|
+
export const defaultValue = {
|
137
|
+
name: "defaultValue, onChange, onChangeCommit",
|
138
|
+
args: {
|
139
|
+
handleChange: fn(),
|
140
|
+
handleChangeCommit: fn(),
|
141
|
+
},
|
142
|
+
render: (args) => (<View paddingTop={10}>
|
143
|
+
<Slider name="test-name" defaultValue={50} onChange={args.handleChange} onChangeCommit={args.handleChangeCommit}/>
|
144
|
+
</View>),
|
145
|
+
play: async ({ canvas, args }) => {
|
146
|
+
const input = canvas.getByRole("slider");
|
147
|
+
expect(input).toHaveValue("50");
|
148
|
+
fireEvent.change(input, { target: { value: 51 } });
|
149
|
+
expect(args.handleChange).toHaveBeenCalledTimes(1);
|
150
|
+
expect(args.handleChange).toHaveBeenCalledWith({ value: 51, name: "test-name" });
|
151
|
+
expect(input).toHaveValue("51");
|
152
|
+
},
|
153
|
+
};
|
154
|
+
export const value = {
|
155
|
+
name: "value, onChange, onChangeCommit",
|
156
|
+
args: {
|
157
|
+
handleChange: fn(),
|
158
|
+
handleChangeCommit: fn(),
|
159
|
+
},
|
160
|
+
render: (args) => (<View paddingTop={10}>
|
161
|
+
<Slider name="test-name" value={50} onChange={args.handleChange} onChangeCommit={args.handleChangeCommit}/>
|
162
|
+
</View>),
|
163
|
+
play: async ({ canvas, args }) => {
|
164
|
+
const input = canvas.getByRole("slider");
|
165
|
+
expect(input).toHaveValue("50");
|
166
|
+
fireEvent.change(input, { target: { value: 51 } });
|
167
|
+
expect(args.handleChange).toHaveBeenCalledTimes(1);
|
168
|
+
expect(args.handleChange).toHaveBeenCalledWith({ value: 51, name: "test-name" });
|
169
|
+
expect(input).toHaveValue("50");
|
170
|
+
},
|
171
|
+
};
|
172
|
+
export const rangeDefaultValue = {
|
173
|
+
name: "range, defaultValue, onChange, onChangeCommit",
|
174
|
+
args: {
|
175
|
+
handleChange: fn(),
|
176
|
+
handleChangeCommit: fn(),
|
177
|
+
},
|
178
|
+
render: (args) => (<View paddingTop={10}>
|
179
|
+
<Slider range name="test-name" defaultMinValue={50} defaultMaxValue={70} onChange={args.handleChange} onChangeCommit={args.handleChangeCommit}/>
|
180
|
+
</View>),
|
181
|
+
play: async ({ canvas, args }) => {
|
182
|
+
const [minInput, maxInput] = canvas.getAllByRole("slider");
|
183
|
+
expect(minInput).toHaveValue("50");
|
184
|
+
expect(maxInput).toHaveValue("70");
|
185
|
+
fireEvent.change(minInput, { target: { value: 51 } });
|
186
|
+
expect(args.handleChange).toHaveBeenCalledTimes(1);
|
187
|
+
expect(args.handleChange).toHaveBeenCalledWith({
|
188
|
+
minValue: 51,
|
189
|
+
maxValue: 70,
|
190
|
+
name: "test-name",
|
191
|
+
minName: "test-name",
|
192
|
+
maxName: "test-name",
|
193
|
+
});
|
194
|
+
expect(minInput).toHaveValue("51");
|
195
|
+
expect(maxInput).toHaveValue("70");
|
196
|
+
},
|
197
|
+
};
|
198
|
+
export const rangeValue = {
|
199
|
+
name: "range, value, onChange, onChangeCommit, minName, maxName",
|
200
|
+
args: {
|
201
|
+
handleChange: fn(),
|
202
|
+
handleChangeCommit: fn(),
|
203
|
+
},
|
204
|
+
render: (args) => (<View paddingTop={10}>
|
205
|
+
<Slider range minName="test-name-min" maxName="test-name-max" minValue={50} maxValue={70} onChange={args.handleChange} onChangeCommit={args.handleChangeCommit}/>
|
206
|
+
</View>),
|
207
|
+
play: async ({ canvas, args }) => {
|
208
|
+
const [minInput, maxInput] = canvas.getAllByRole("slider");
|
209
|
+
expect(minInput).toHaveValue("50");
|
210
|
+
expect(maxInput).toHaveValue("70");
|
211
|
+
fireEvent.change(minInput, { target: { value: 51 } });
|
212
|
+
expect(args.handleChange).toHaveBeenCalledTimes(1);
|
213
|
+
expect(args.handleChange).toHaveBeenCalledWith({
|
214
|
+
minValue: 51,
|
215
|
+
maxValue: 70,
|
216
|
+
minName: "test-name-min",
|
217
|
+
maxName: "test-name-max",
|
218
|
+
});
|
219
|
+
expect(minInput).toHaveValue("50");
|
220
|
+
expect(maxInput).toHaveValue("70");
|
221
|
+
},
|
222
|
+
};
|
223
|
+
export const className = {
|
224
|
+
name: "className, attributes",
|
225
|
+
render: () => (<div data-testid="root">
|
226
|
+
<Slider name="name" className="test-classname" attributes={{ id: "test-id" }}/>
|
227
|
+
</div>),
|
228
|
+
play: async ({ canvas }) => {
|
229
|
+
const root = canvas.getByTestId("root").firstChild;
|
230
|
+
expect(root).toHaveClass("test-classname");
|
231
|
+
expect(root).toHaveAttribute("id", "test-id");
|
232
|
+
},
|
233
|
+
};
|
234
|
+
export const testForm = {
|
235
|
+
name: "test: form onChange",
|
236
|
+
args: {
|
237
|
+
handleFormChange: fn(),
|
238
|
+
handleFormInit: fn(),
|
239
|
+
},
|
240
|
+
render: (args) => {
|
241
|
+
const formRef = React.useRef(null);
|
242
|
+
const [data, setData] = React.useState([]);
|
243
|
+
const handleChange = (e) => {
|
244
|
+
const formData = new FormData(e.currentTarget);
|
245
|
+
const nextState = [...formData.entries()];
|
246
|
+
args.handleFormChange({ formData: nextState });
|
247
|
+
setData(nextState);
|
248
|
+
};
|
249
|
+
React.useEffect(() => {
|
250
|
+
const formData = new FormData(formRef.current);
|
251
|
+
const nextState = [...formData.entries()];
|
252
|
+
args.handleFormInit({ formData: nextState });
|
253
|
+
setData(nextState);
|
254
|
+
}, []);
|
255
|
+
return (<View paddingTop={10} gap={4}>
|
256
|
+
<form onChange={handleChange} ref={formRef}>
|
257
|
+
<Slider range minName="slider-min" maxName="slider-max" defaultMinValue={30} defaultMaxValue={50}/>
|
258
|
+
</form>
|
259
|
+
|
260
|
+
{data.map((v) => v.join(": ")).join(", ")}
|
261
|
+
</View>);
|
262
|
+
},
|
263
|
+
play: async () => {
|
264
|
+
/**
|
265
|
+
* Placeholder
|
266
|
+
*
|
267
|
+
* No way to test dragging here without calling fireEvent.change
|
268
|
+
* Which defeats the purpose of testing custom emitted events
|
269
|
+
*
|
270
|
+
* Test this behavior manually in Storybook by dragging the thumbs
|
271
|
+
*/
|
272
|
+
},
|
273
|
+
};
|
274
|
+
export const testSwipe = {
|
275
|
+
name: "test: prevents parent swipe",
|
276
|
+
render: () => {
|
277
|
+
const toggle = useToggle(true);
|
278
|
+
return (<Modal active={toggle.active} onClose={toggle.deactivate} position="end">
|
279
|
+
<View gap={4}>
|
280
|
+
<Modal.Title>Modal</Modal.Title>
|
281
|
+
<Slider name="slider" defaultValue={30}/>
|
282
|
+
</View>
|
283
|
+
</Modal>);
|
284
|
+
},
|
71
285
|
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import React from "react";
|
3
|
-
import { responsivePropDependency } from "../../utilities/
|
3
|
+
import { responsivePropDependency } from "../../utilities/props.js";
|
4
4
|
import Expandable from "../_private/Expandable/index.js";
|
5
5
|
import View from "../View/index.js";
|
6
6
|
import Text from "../Text/index.js";
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use client";
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
3
|
-
import { classNames, responsiveClassNames, responsivePropDependency } from "../../utilities/
|
3
|
+
import { classNames, responsiveClassNames, responsivePropDependency } from "../../utilities/props.js";
|
4
4
|
import { useFormControl } from "../FormControl/index.js";
|
5
5
|
import Text from "../Text/index.js";
|
6
6
|
import useElementId from "../../hooks/useElementId.js";
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
2
|
import React from "react";
|
3
|
-
import { classNames, responsiveVariables } from "../../utilities/
|
3
|
+
import { classNames, responsiveVariables } from "../../utilities/props.js";
|
4
4
|
import getWidthStyles from "../../styles/width/index.js";
|
5
5
|
import getMinWidthStyles from "../../styles/minWidth/index.js";
|
6
6
|
import s from "./Table.module.css";
|
7
|
+
import useFadeSide from "../../hooks/_private/useFadeSide.js";
|
7
8
|
const TableCellPrivate = (props) => {
|
8
9
|
const { minWidth, rowSpan, colSpan, align, verticalAlign, tagName: TagName, padding, paddingInline, paddingBlock, children, className, attributes, } = props;
|
9
10
|
const width = props.width === "auto" ? "0px" : props.width;
|
@@ -40,9 +41,11 @@ const TableHead = (props) => {
|
|
40
41
|
};
|
41
42
|
const Table = (props) => {
|
42
43
|
const { children, border, columnBorder, className, attributes } = props;
|
43
|
-
const
|
44
|
+
const rootRef = React.useRef(null);
|
45
|
+
const fadeSide = useFadeSide(rootRef);
|
46
|
+
const rootClassNames = classNames(s.root, className, border && s["--border-outer"], columnBorder && s["--border-column"], (fadeSide === "start" || fadeSide === "both") && s["--fade-start"], (fadeSide === "end" || fadeSide === "both") && s["--fade-end"]);
|
44
47
|
const [firstChild] = React.Children.toArray(children);
|
45
|
-
return (_jsx("div", { ...attributes, className: rootClassNames, children: _jsx("table", { className: s.table, children: React.isValidElement(firstChild) &&
|
48
|
+
return (_jsx("div", { ...attributes, className: rootClassNames, ref: rootRef, children: _jsx("table", { className: s.table, children: React.isValidElement(firstChild) &&
|
46
49
|
(firstChild.type === TableBody || firstChild.type === TableHead) ? (children) : (_jsx(TableBody, { children: children })) }) }));
|
47
50
|
};
|
48
51
|
Table.Cell = TableCell;
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
@property --rs-table-fade-start{syntax:"<length>";initial-value:0;inherits:false}@property --rs-table-fade-end{syntax:"<length>";initial-value:0;inherits:false}.root{mask-image:linear-gradient(to right,transparent 0,#000 var(--rs-table-fade-start),#000 calc(100% - var(--rs-table-fade-end)),transparent 100%);overflow:auto;transition:var(--rs-duration-medium) var(--rs-easing-decelerate);transition-property:--rs-table-fade-start,--rs-table-fade-end}.table{border-collapse:separate;min-width:100%;overflow:hidden}.row{transition:background-color var(--rs-duration-fast) var(--rs-easing-standard)}.row[tabindex]{cursor:pointer}[data-rs-keyboard] .row:focus{box-shadow:var(--rs-focus-inset-shadow);outline:none;z-index:var(--rs-z-index-raised)}.cell{--rs-table-p-vertical-s:3;--rs-table-p-horizontal-s:4;padding:calc(var(--rs-unit-x1) * var(--rs-table-p-vertical-s)) calc(var(--rs-unit-x1) * var(--rs-table-p-horizontal-s));text-align:start;vertical-align:top}.cell:not(:last-child){padding-inline-end:0}.head+.body .row:first-child .cell,.row:not(:first-child) .cell{border-top:1px solid var(--rs-color-border-neutral-faded)}.cell--align-start{text-align:start}.cell--align-center{text-align:center}.cell--align-end{text-align:end}.cell--valign-start{vertical-align:top}.cell--valign-center{vertical-align:middle}.cell--valign-end{vertical-align:bottom}.cell--width-auto{white-space:nowrap}.--row-highlighted{background-color:rgba(var(--rs-color-rgb-background-neutral),24%)}.--border-outer .table{border:1px solid var(--rs-color-border-neutral-faded);border-radius:var(--rs-radius-medium)}.--border-column .cell:not(:first-child){border-inline-start:1px solid var(--rs-color-border-neutral-faded)}.--border-column .cell:not(:last-child){padding-inline-end:calc(var(--rs-unit-x1) * var(--rs-table-p-horizontal-s))}.--fade-start,[dir=rtl] .--fade-end{--rs-table-fade-start:var(--rs-unit-x4)}.--fade-end,[dir=rtl] .--fade-start{--rs-table-fade-end:var(--rs-unit-x4)}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client";
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
3
3
|
import React from "react";
|
4
|
-
import { classNames } from "../../utilities/
|
4
|
+
import { classNames } from "../../utilities/props.js";
|
5
5
|
import HiddenInput from "../_private/HiddenInput/index.js";
|
6
6
|
import Actionable from "../Actionable/index.js";
|
7
7
|
import Icon from "../Icon/index.js";
|
@@ -1,11 +1,12 @@
|
|
1
1
|
"use client";
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
3
3
|
import React from "react";
|
4
|
-
import { classNames
|
4
|
+
import { classNames } from "../../utilities/props.js";
|
5
5
|
import useRTL from "../../hooks/useRTL.js";
|
6
6
|
import { focusNextElement, focusPreviousElement, focusFirstElement, focusLastElement, } from "../../utilities/a11y/index.js";
|
7
7
|
import useIsomorphicLayoutEffect from "../../hooks/useIsomorphicLayoutEffect.js";
|
8
8
|
import useHotkeys from "../../hooks/useHotkeys.js";
|
9
|
+
import useFadeSide from "../../hooks/_private/useFadeSide.js";
|
9
10
|
import Actionable from "../Actionable/index.js";
|
10
11
|
import Icon from "../Icon/index.js";
|
11
12
|
import IconChevronRight from "../../icons/ChevronRight.js";
|
@@ -24,7 +25,7 @@ const TabsList = (props) => {
|
|
24
25
|
const { children, className, attributes } = props;
|
25
26
|
const { value, setDefaultValue, itemWidth, variant, name, direction, size, selection, setSelection, elActiveRef, elPrevActiveRef, elScrollableRef, } = useTabs();
|
26
27
|
const [rtl] = useRTL();
|
27
|
-
const
|
28
|
+
const fadeSide = useFadeSide(elScrollableRef);
|
28
29
|
const rootClassNames = classNames(s.root, size && s[`--size-${size}`], direction && s[`--direction-${direction}`], itemWidth && s[`--item-width-${itemWidth}`], variant && s[`--variant-${variant}`], (fadeSide === "start" || fadeSide === "both") && s["--fade-start"], (fadeSide === "end" || fadeSide === "both") && s["--fade-end"], className);
|
29
30
|
const selectorClassNames = classNames(s.selector, selection.status === "idle" && s["--selector-hidden"], selection.status === "animated" && s["--selector-animated"]);
|
30
31
|
const handleNextClick = () => {
|
@@ -105,38 +106,6 @@ const TabsList = (props) => {
|
|
105
106
|
return;
|
106
107
|
setSelection({ ...selectionStyle, status: "animated" });
|
107
108
|
}, [selection]);
|
108
|
-
useIsomorphicLayoutEffect(() => {
|
109
|
-
const elScrollable = elScrollableRef.current;
|
110
|
-
if (!elScrollable || direction === "column")
|
111
|
-
return;
|
112
|
-
const updateArrowNav = () => {
|
113
|
-
const isScrollable = elScrollable.clientWidth < elScrollable.scrollWidth;
|
114
|
-
if (!isScrollable)
|
115
|
-
setFadeSide(null);
|
116
|
-
// scrollLeft in RTL starts from 1 instead of 0, so we compare values using this delta
|
117
|
-
const scrollLeft = elScrollable.scrollLeft * (rtl ? -1 : 1);
|
118
|
-
const cutOffStart = scrollLeft > 1;
|
119
|
-
const cutOffEnd = scrollLeft + elScrollable.clientWidth < elScrollable.scrollWidth - 1;
|
120
|
-
if (cutOffEnd && cutOffStart)
|
121
|
-
return setFadeSide("both");
|
122
|
-
if (cutOffStart)
|
123
|
-
return setFadeSide("start");
|
124
|
-
if (cutOffEnd)
|
125
|
-
return setFadeSide("end");
|
126
|
-
};
|
127
|
-
const debouncedUpdateArrowNav = throttle(updateArrowNav, 16);
|
128
|
-
// Use RaF when scroll to have scrollWidth calculated correctly on the first effect
|
129
|
-
// For example: And edge case inside the complex flexbox layout
|
130
|
-
requestAnimationFrame(() => {
|
131
|
-
updateArrowNav();
|
132
|
-
});
|
133
|
-
window.addEventListener("resize", debouncedUpdateArrowNav);
|
134
|
-
elScrollable.addEventListener("scroll", debouncedUpdateArrowNav);
|
135
|
-
return () => {
|
136
|
-
window.removeEventListener("resize", debouncedUpdateArrowNav);
|
137
|
-
elScrollable.removeEventListener("scroll", debouncedUpdateArrowNav);
|
138
|
-
};
|
139
|
-
}, [rtl]);
|
140
109
|
return (_jsxs("div", { ...attributes, className: rootClassNames, children: [_jsx("div", { className: s.inner, ref: elScrollableRef, children: _jsxs("div", { className: s.list, role: "tablist", ref: hotkeysRef, children: [React.Children.map(children, (child, index) => {
|
141
110
|
if (!React.isValidElement(child))
|
142
111
|
return null;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use client";
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
3
|
-
import { classNames } from "../../utilities/
|
3
|
+
import { classNames } from "../../utilities/props.js";
|
4
4
|
import { useTabs } from "./TabsContext.js";
|
5
5
|
import s from "./Tabs.module.css";
|
6
6
|
const TabsPanel = (props) => {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
-
import { classNames, responsiveClassNames } from "../../utilities/
|
2
|
+
import { classNames, responsiveClassNames } from "../../utilities/props.js";
|
3
3
|
import getTextAlignStyles from "../../styles/textAlign/index.js";
|
4
4
|
import s from "./Text.module.css";
|
5
5
|
const tagMap = {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client";
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
3
3
|
import React from "react";
|
4
|
-
import { classNames, responsiveClassNames } from "../../utilities/
|
4
|
+
import { classNames, responsiveClassNames } from "../../utilities/props.js";
|
5
5
|
import { useFormControl } from "../FormControl/index.js";
|
6
6
|
import Aligner from "../_private/Aligner/index.js";
|
7
7
|
import useElementId from "../../hooks/useElementId.js";
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client";
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
3
3
|
import React from "react";
|
4
|
-
import { classNames, responsiveClassNames, responsivePropDependency } from "../../utilities/
|
4
|
+
import { classNames, responsiveClassNames, responsivePropDependency } from "../../utilities/props.js";
|
5
5
|
import useElementId from "../../hooks/useElementId.js";
|
6
6
|
import { useFormControl } from "../FormControl/index.js";
|
7
7
|
import Icon from "../Icon/index.js";
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client";
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
3
3
|
import React from "react";
|
4
|
-
import { classNames } from "../../utilities/
|
4
|
+
import { classNames } from "../../utilities/props.js";
|
5
5
|
import useIsomorphicLayoutEffect from "../../hooks/useIsomorphicLayoutEffect.js";
|
6
6
|
import { ThemeContext } from "./Theme.context.js";
|
7
7
|
import { getRootThemeEl } from "./Theme.utilities.js";
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import React from "react";
|
3
|
-
import { classNames } from "../../utilities/
|
3
|
+
import { classNames } from "../../utilities/props.js";
|
4
4
|
import View from "../View/index.js";
|
5
5
|
import s from "./Timeline.module.css";
|
6
6
|
const TimelineItem = (props) => {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client";
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
3
3
|
import React from "react";
|
4
|
-
import { classNames } from "../../utilities/
|
4
|
+
import { classNames } from "../../utilities/props.js";
|
5
5
|
import { onNextFrame } from "../../utilities/animation.js";
|
6
6
|
import { checkKeyboardMode, TrapFocus } from "../../utilities/a11y/index.js";
|
7
7
|
import Toast from "./Toast.js";
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client";
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
3
3
|
import React from "react";
|
4
|
-
import { classNames } from "../../utilities/
|
4
|
+
import { classNames } from "../../utilities/props.js";
|
5
5
|
import { focusableSelector } from "../../utilities/a11y/index.js";
|
6
6
|
import ToastContainer from "./ToastContainer.js";
|
7
7
|
import ToastContext from "./Toast.context.js";
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { createElement as _createElement } from "react";
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
3
3
|
import React from "react";
|
4
|
-
import { classNames, responsiveClassNames, responsiveVariables } from "../../utilities/
|
4
|
+
import { classNames, responsiveClassNames, responsiveVariables } from "../../utilities/props.js";
|
5
5
|
import Divider from "../Divider/index.js";
|
6
6
|
import Hidden from "../Hidden/index.js";
|
7
7
|
import s from "./View.module.css";
|
@@ -7,7 +7,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
* It relies on using a data-rs-aligner-target attribute in other components and works based
|
8
8
|
* on the --rs-p, --rs-p-v and --rs-p-h css variables
|
9
9
|
*/
|
10
|
-
import { classNames } from "../../../utilities/
|
10
|
+
import { classNames } from "../../../utilities/props.js";
|
11
11
|
import s from "./Aligner.module.css";
|
12
12
|
const Aligner = (props) => {
|
13
13
|
const { side: passedSide = "all", children, className, attributes } = props;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client";
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
3
3
|
import React from "react";
|
4
|
-
import { classNames } from "../../../utilities/
|
4
|
+
import { classNames } from "../../../utilities/props.js";
|
5
5
|
import { onNextFrame } from "../../../utilities/animation.js";
|
6
6
|
import useIsomorphicLayoutEffect from "../../../hooks/useIsomorphicLayoutEffect.js";
|
7
7
|
import s from "./Expandable.module.css";
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
-
import { classNames } from "../../../utilities/
|
2
|
+
import { classNames } from "../../../utilities/props.js";
|
3
3
|
import s from "./HiddenInput.module.css";
|
4
4
|
const HiddenInput = (props) => {
|
5
5
|
const { name, value, type, onChange, onFocus, onBlur, checked, defaultChecked, disabled, className, attributes, } = props;
|
@@ -0,0 +1,47 @@
|
|
1
|
+
"use client";
|
2
|
+
import React from "react";
|
3
|
+
import useRTL from "../useRTL.js";
|
4
|
+
import useIsomorphicLayoutEffect from "../useIsomorphicLayoutEffect.js";
|
5
|
+
import { rafThrottle } from "../../utilities/helpers.js";
|
6
|
+
const useFadeSide = (scrollableRef, options = {}) => {
|
7
|
+
const { disabled } = options;
|
8
|
+
const [rtl] = useRTL();
|
9
|
+
const [fadeSide, setFadeSide] = React.useState(null);
|
10
|
+
const updateFade = React.useCallback(() => {
|
11
|
+
const elScrollable = scrollableRef.current;
|
12
|
+
if (!elScrollable)
|
13
|
+
return;
|
14
|
+
const isScrollable = elScrollable.clientWidth < elScrollable.scrollWidth;
|
15
|
+
if (!isScrollable)
|
16
|
+
setFadeSide(null);
|
17
|
+
// scrollLeft in RTL starts from 1 instead of 0, so we compare values using this delta
|
18
|
+
const scrollLeft = elScrollable.scrollLeft * (rtl ? -1 : 1);
|
19
|
+
const cutOffStart = scrollLeft > 1;
|
20
|
+
const cutOffEnd = scrollLeft + elScrollable.clientWidth < elScrollable.scrollWidth - 1;
|
21
|
+
if (cutOffEnd && cutOffStart)
|
22
|
+
return setFadeSide("both");
|
23
|
+
if (cutOffStart)
|
24
|
+
return setFadeSide("start");
|
25
|
+
if (cutOffEnd)
|
26
|
+
return setFadeSide("end");
|
27
|
+
}, [rtl, scrollableRef]);
|
28
|
+
useIsomorphicLayoutEffect(() => {
|
29
|
+
const elScrollable = scrollableRef.current;
|
30
|
+
if (!elScrollable)
|
31
|
+
return;
|
32
|
+
if (disabled)
|
33
|
+
return;
|
34
|
+
const debouncedUpdate = rafThrottle(updateFade);
|
35
|
+
// Use RaF when scroll to have scrollWidth calculated correctly on the first effect
|
36
|
+
// For example: And edge case inside the complex flexbox layout
|
37
|
+
requestAnimationFrame(() => updateFade());
|
38
|
+
window.addEventListener("resize", debouncedUpdate);
|
39
|
+
elScrollable.addEventListener("scroll", debouncedUpdate);
|
40
|
+
return () => {
|
41
|
+
window.removeEventListener("resize", debouncedUpdate);
|
42
|
+
elScrollable.removeEventListener("scroll", debouncedUpdate);
|
43
|
+
};
|
44
|
+
}, [rtl, disabled]);
|
45
|
+
return fadeSide;
|
46
|
+
};
|
47
|
+
export default useFadeSide;
|