@shipfox/react-ui 0.25.0 → 0.26.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/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/slider/index.js +3 -0
- package/dist/components/slider/slider.d.ts +10 -0
- package/dist/components/slider/slider.js +38 -0
- package/dist/styles.css +1 -1
- package/package.json +4 -4
- package/dist/colors.stories.js +0 -61
- package/dist/components/alert/alert.stories.js +0 -227
- package/dist/components/avatar/avatar.stories.js +0 -267
- package/dist/components/badge/badge.stories.js +0 -802
- package/dist/components/button/button-link.stories.js +0 -127
- package/dist/components/button/button.stories.js +0 -187
- package/dist/components/button/icon-button.stories.js +0 -344
- package/dist/components/button-group/button-group.stories.js +0 -644
- package/dist/components/card/card.stories.js +0 -216
- package/dist/components/checkbox/checkbox.stories.js +0 -566
- package/dist/components/code-block/code-block.stories.js +0 -341
- package/dist/components/combobox/combobox.stories.js +0 -191
- package/dist/components/command/command.stories.js +0 -228
- package/dist/components/confetti/confetti.stories.js +0 -41
- package/dist/components/count-up/count-up.stories.js +0 -568
- package/dist/components/dashboard/components/charts/bar-chart.stories.js +0 -287
- package/dist/components/dashboard/components/charts/line-chart.stories.js +0 -257
- package/dist/components/dashboard/dashboard.stories.js +0 -23
- package/dist/components/date-picker/date-picker.stories.js +0 -349
- package/dist/components/dropdown-input/dropdown-input.stories.js +0 -240
- package/dist/components/dropdown-menu/dropdown-menu.stories.js +0 -462
- package/dist/components/dynamic-item/dynamic-item.stories.js +0 -385
- package/dist/components/empty-state/empty-state.stories.js +0 -74
- package/dist/components/form/form.stories.js +0 -587
- package/dist/components/icon/icon.stories.js +0 -38
- package/dist/components/inline-tips/inline-tips.stories.js +0 -219
- package/dist/components/input/input.stories.js +0 -265
- package/dist/components/interval-selector/interval-selector.stories.js +0 -232
- package/dist/components/item/item.stories.js +0 -239
- package/dist/components/kbd/kbd.stories.js +0 -119
- package/dist/components/label/label.stories.js +0 -105
- package/dist/components/modal/modal.stories.js +0 -566
- package/dist/components/search/search.stories.js +0 -630
- package/dist/components/select/select.stories.js +0 -393
- package/dist/components/sheet/sheet.stories.js +0 -368
- package/dist/components/skeleton/skeleton.stories.js +0 -345
- package/dist/components/table/table.stories.js +0 -302
- package/dist/components/tabs/tabs.stories.js +0 -179
- package/dist/components/textarea/textarea.stories.js +0 -339
- package/dist/components/toast/toast.stories.js +0 -326
- package/dist/components/tooltip/tooltip.stories.js +0 -560
- package/dist/components/typography/code.stories.js +0 -54
- package/dist/components/typography/header.stories.js +0 -34
- package/dist/components/typography/text.stories.js +0 -105
- package/dist/onboarding/sign-in.stories.js +0 -101
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { argosScreenshot } from '@argos-ci/storybook/vitest';
|
|
3
|
-
import { within } from '@testing-library/react';
|
|
4
|
-
import userEvent from '@testing-library/user-event';
|
|
5
|
-
import { subDays } from 'date-fns';
|
|
6
|
-
import { useState } from 'react';
|
|
7
|
-
import { DateTimeRangePicker } from '../date-time-range-picker/date-time-range-picker.js';
|
|
8
|
-
import { DatePicker } from './date-picker.js';
|
|
9
|
-
const meta = {
|
|
10
|
-
title: 'Components/DatePicker',
|
|
11
|
-
component: DatePicker,
|
|
12
|
-
parameters: {
|
|
13
|
-
layout: 'centered'
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
export default meta;
|
|
17
|
-
const OPEN_CALENDAR_REGEX = /open calendar/i;
|
|
18
|
-
const isTestEnvironment = ()=>typeof navigator !== 'undefined' && navigator.webdriver === true;
|
|
19
|
-
async function openCalendarAndScreenshot(ctx, screenshotName) {
|
|
20
|
-
const { canvasElement, step } = ctx;
|
|
21
|
-
const canvas = within(canvasElement);
|
|
22
|
-
const user = userEvent.setup();
|
|
23
|
-
let triggerButton = null;
|
|
24
|
-
await step('Open the calendar popover', async ()=>{
|
|
25
|
-
triggerButton = canvas.getByRole('button', {
|
|
26
|
-
name: OPEN_CALENDAR_REGEX
|
|
27
|
-
});
|
|
28
|
-
await user.click(triggerButton);
|
|
29
|
-
});
|
|
30
|
-
await step('Wait for calendar to appear and render', async ()=>{
|
|
31
|
-
await new Promise((resolve)=>setTimeout(resolve, 300));
|
|
32
|
-
if (isTestEnvironment() && triggerButton instanceof HTMLElement) {
|
|
33
|
-
triggerButton.style.display = 'none';
|
|
34
|
-
}
|
|
35
|
-
await new Promise((resolve)=>setTimeout(resolve, 100));
|
|
36
|
-
});
|
|
37
|
-
await argosScreenshot(ctx, screenshotName);
|
|
38
|
-
}
|
|
39
|
-
export const DatePickerStory = {
|
|
40
|
-
play: (ctx)=>openCalendarAndScreenshot(ctx, 'DatePicker Calendar Open'),
|
|
41
|
-
render: ()=>{
|
|
42
|
-
const [date, setDate] = useState(new Date());
|
|
43
|
-
return /*#__PURE__*/ _jsx("div", {
|
|
44
|
-
className: "relative flex h-600 w-500 items-center justify-center rounded-16 bg-background-subtle-base shadow-tooltip overflow-visible",
|
|
45
|
-
children: /*#__PURE__*/ _jsx(DatePicker, {
|
|
46
|
-
date: date,
|
|
47
|
-
onDateSelect: setDate,
|
|
48
|
-
onClear: ()=>setDate(undefined),
|
|
49
|
-
placeholder: "DD/MM/YYYY"
|
|
50
|
-
})
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
export const DatePickerWithThresholdStory = {
|
|
55
|
-
play: (ctx)=>openCalendarAndScreenshot(ctx, 'DatePicker With Threshold Calendar Open'),
|
|
56
|
-
render: ()=>{
|
|
57
|
-
const [date, setDate] = useState(new Date());
|
|
58
|
-
return /*#__PURE__*/ _jsx("div", {
|
|
59
|
-
className: "relative flex h-600 w-500 items-center justify-center rounded-16 bg-background-subtle-base shadow-tooltip overflow-visible",
|
|
60
|
-
children: /*#__PURE__*/ _jsx(DatePicker, {
|
|
61
|
-
date: date,
|
|
62
|
-
onDateSelect: setDate,
|
|
63
|
-
onClear: ()=>setDate(undefined),
|
|
64
|
-
placeholder: "DD/MM/YYYY",
|
|
65
|
-
maxDisabledOffsetDays: 30
|
|
66
|
-
})
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
export const DateRangePickerStory = {
|
|
71
|
-
play: (ctx)=>openCalendarAndScreenshot(ctx, 'DateRangePicker Calendar Open'),
|
|
72
|
-
render: ()=>{
|
|
73
|
-
const [dateRange, setDateRange] = useState({
|
|
74
|
-
start: new Date(),
|
|
75
|
-
end: subDays(new Date(), -30)
|
|
76
|
-
});
|
|
77
|
-
return /*#__PURE__*/ _jsx("div", {
|
|
78
|
-
className: "relative flex h-600 w-800 items-center justify-center rounded-16 bg-background-subtle-base shadow-tooltip overflow-visible",
|
|
79
|
-
children: /*#__PURE__*/ _jsx(DateTimeRangePicker, {
|
|
80
|
-
dateRange: dateRange,
|
|
81
|
-
onDateRangeSelect: setDateRange,
|
|
82
|
-
onClear: ()=>setDateRange(undefined),
|
|
83
|
-
placeholder: "DD/MM/YYYY - DD/MM/YYYY",
|
|
84
|
-
className: "min-w-280"
|
|
85
|
-
})
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
export const AllStates = {
|
|
90
|
-
render: ()=>{
|
|
91
|
-
const now = new Date();
|
|
92
|
-
const past = subDays(now, 30);
|
|
93
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
94
|
-
className: "flex flex-col gap-32 p-32 min-w-350",
|
|
95
|
-
children: [
|
|
96
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
97
|
-
children: [
|
|
98
|
-
/*#__PURE__*/ _jsx("h3", {
|
|
99
|
-
className: "text-lg font-semibold mb-16 text-foreground-neutral-base",
|
|
100
|
-
children: "Single Date Picker"
|
|
101
|
-
}),
|
|
102
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
103
|
-
className: "flex flex-col gap-16",
|
|
104
|
-
children: [
|
|
105
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
106
|
-
children: [
|
|
107
|
-
/*#__PURE__*/ _jsx("p", {
|
|
108
|
-
className: "text-xs text-foreground-neutral-subtle mb-8 font-mono",
|
|
109
|
-
children: "DEFAULT"
|
|
110
|
-
}),
|
|
111
|
-
/*#__PURE__*/ _jsx(DatePicker, {
|
|
112
|
-
placeholder: "DD/MM/YYYY"
|
|
113
|
-
})
|
|
114
|
-
]
|
|
115
|
-
}),
|
|
116
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
117
|
-
children: [
|
|
118
|
-
/*#__PURE__*/ _jsx("p", {
|
|
119
|
-
className: "text-xs text-foreground-neutral-subtle mb-8 font-mono",
|
|
120
|
-
children: "FILLED"
|
|
121
|
-
}),
|
|
122
|
-
/*#__PURE__*/ _jsx(DatePicker, {
|
|
123
|
-
date: new Date(),
|
|
124
|
-
onClear: ()=>{
|
|
125
|
-
/* noop for demo */ },
|
|
126
|
-
placeholder: "DD/MM/YYYY"
|
|
127
|
-
})
|
|
128
|
-
]
|
|
129
|
-
}),
|
|
130
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
131
|
-
children: [
|
|
132
|
-
/*#__PURE__*/ _jsx("p", {
|
|
133
|
-
className: "text-xs text-foreground-neutral-subtle mb-8 font-mono",
|
|
134
|
-
children: "ERROR"
|
|
135
|
-
}),
|
|
136
|
-
/*#__PURE__*/ _jsx(DatePicker, {
|
|
137
|
-
date: new Date(),
|
|
138
|
-
onClear: ()=>{
|
|
139
|
-
/* noop for demo */ },
|
|
140
|
-
state: "error",
|
|
141
|
-
placeholder: "DD/MM/YYYY"
|
|
142
|
-
})
|
|
143
|
-
]
|
|
144
|
-
}),
|
|
145
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
146
|
-
children: [
|
|
147
|
-
/*#__PURE__*/ _jsx("p", {
|
|
148
|
-
className: "text-xs text-foreground-neutral-subtle mb-8 font-mono",
|
|
149
|
-
children: "DISABLED"
|
|
150
|
-
}),
|
|
151
|
-
/*#__PURE__*/ _jsx(DatePicker, {
|
|
152
|
-
placeholder: "DD/MM/YYYY",
|
|
153
|
-
state: "disabled"
|
|
154
|
-
})
|
|
155
|
-
]
|
|
156
|
-
}),
|
|
157
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
158
|
-
children: [
|
|
159
|
-
/*#__PURE__*/ _jsx("p", {
|
|
160
|
-
className: "text-xs text-foreground-neutral-subtle mb-8 font-mono",
|
|
161
|
-
children: "SMALL"
|
|
162
|
-
}),
|
|
163
|
-
/*#__PURE__*/ _jsx(DatePicker, {
|
|
164
|
-
size: "small",
|
|
165
|
-
placeholder: "DD/MM/YYYY"
|
|
166
|
-
})
|
|
167
|
-
]
|
|
168
|
-
}),
|
|
169
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
170
|
-
children: [
|
|
171
|
-
/*#__PURE__*/ _jsx("p", {
|
|
172
|
-
className: "text-xs text-foreground-neutral-subtle mb-8 font-mono",
|
|
173
|
-
children: "COMPONENT VARIANT"
|
|
174
|
-
}),
|
|
175
|
-
/*#__PURE__*/ _jsx(DatePicker, {
|
|
176
|
-
variant: "component",
|
|
177
|
-
placeholder: "DD/MM/YYYY"
|
|
178
|
-
})
|
|
179
|
-
]
|
|
180
|
-
})
|
|
181
|
-
]
|
|
182
|
-
})
|
|
183
|
-
]
|
|
184
|
-
}),
|
|
185
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
186
|
-
children: [
|
|
187
|
-
/*#__PURE__*/ _jsx("h3", {
|
|
188
|
-
className: "text-lg font-semibold mb-16 text-foreground-neutral-base",
|
|
189
|
-
children: "Date Range Picker"
|
|
190
|
-
}),
|
|
191
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
192
|
-
className: "flex flex-col gap-16",
|
|
193
|
-
children: [
|
|
194
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
195
|
-
children: [
|
|
196
|
-
/*#__PURE__*/ _jsx("p", {
|
|
197
|
-
className: "text-xs text-foreground-neutral-subtle mb-8 font-mono",
|
|
198
|
-
children: "DEFAULT"
|
|
199
|
-
}),
|
|
200
|
-
/*#__PURE__*/ _jsx(DateTimeRangePicker, {
|
|
201
|
-
placeholder: "DD/MM/YYYY - DD/MM/YYYY"
|
|
202
|
-
})
|
|
203
|
-
]
|
|
204
|
-
}),
|
|
205
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
206
|
-
children: [
|
|
207
|
-
/*#__PURE__*/ _jsx("p", {
|
|
208
|
-
className: "text-xs text-foreground-neutral-subtle mb-8 font-mono",
|
|
209
|
-
children: "FILLED"
|
|
210
|
-
}),
|
|
211
|
-
/*#__PURE__*/ _jsx(DateTimeRangePicker, {
|
|
212
|
-
dateRange: {
|
|
213
|
-
start: past,
|
|
214
|
-
end: now
|
|
215
|
-
},
|
|
216
|
-
onClear: ()=>{
|
|
217
|
-
/* noop for demo */ },
|
|
218
|
-
placeholder: "DD/MM/YYYY - DD/MM/YYYY"
|
|
219
|
-
})
|
|
220
|
-
]
|
|
221
|
-
}),
|
|
222
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
223
|
-
children: [
|
|
224
|
-
/*#__PURE__*/ _jsx("p", {
|
|
225
|
-
className: "text-xs text-foreground-neutral-subtle mb-8 font-mono",
|
|
226
|
-
children: "ERROR"
|
|
227
|
-
}),
|
|
228
|
-
/*#__PURE__*/ _jsx(DateTimeRangePicker, {
|
|
229
|
-
dateRange: {
|
|
230
|
-
start: past,
|
|
231
|
-
end: now
|
|
232
|
-
},
|
|
233
|
-
onClear: ()=>{
|
|
234
|
-
/* noop for demo */ },
|
|
235
|
-
state: "error",
|
|
236
|
-
placeholder: "DD/MM/YYYY - DD/MM/YYYY"
|
|
237
|
-
})
|
|
238
|
-
]
|
|
239
|
-
}),
|
|
240
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
241
|
-
children: [
|
|
242
|
-
/*#__PURE__*/ _jsx("p", {
|
|
243
|
-
className: "text-xs text-foreground-neutral-subtle mb-8 font-mono",
|
|
244
|
-
children: "DISABLED"
|
|
245
|
-
}),
|
|
246
|
-
/*#__PURE__*/ _jsx(DateTimeRangePicker, {
|
|
247
|
-
placeholder: "DD/MM/YYYY - DD/MM/YYYY",
|
|
248
|
-
state: "disabled"
|
|
249
|
-
})
|
|
250
|
-
]
|
|
251
|
-
}),
|
|
252
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
253
|
-
children: [
|
|
254
|
-
/*#__PURE__*/ _jsx("p", {
|
|
255
|
-
className: "text-xs text-foreground-neutral-subtle mb-8 font-mono",
|
|
256
|
-
children: "SMALL"
|
|
257
|
-
}),
|
|
258
|
-
/*#__PURE__*/ _jsx(DateTimeRangePicker, {
|
|
259
|
-
size: "small",
|
|
260
|
-
placeholder: "DD/MM/YYYY - DD/MM/YYYY"
|
|
261
|
-
})
|
|
262
|
-
]
|
|
263
|
-
}),
|
|
264
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
265
|
-
children: [
|
|
266
|
-
/*#__PURE__*/ _jsx("p", {
|
|
267
|
-
className: "text-xs text-foreground-neutral-subtle mb-8 font-mono",
|
|
268
|
-
children: "COMPONENT VARIANT"
|
|
269
|
-
}),
|
|
270
|
-
/*#__PURE__*/ _jsx(DateTimeRangePicker, {
|
|
271
|
-
variant: "component",
|
|
272
|
-
placeholder: "DD/MM/YYYY - DD/MM/YYYY"
|
|
273
|
-
})
|
|
274
|
-
]
|
|
275
|
-
})
|
|
276
|
-
]
|
|
277
|
-
})
|
|
278
|
-
]
|
|
279
|
-
})
|
|
280
|
-
]
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
export const DateFormats = {
|
|
285
|
-
render: ()=>{
|
|
286
|
-
const [date, setDate] = useState(new Date());
|
|
287
|
-
const formats = [
|
|
288
|
-
{
|
|
289
|
-
format: 'MMMM dd, yyyy',
|
|
290
|
-
placeholder: 'Month DD, YYYY',
|
|
291
|
-
label: 'MMMM dd, yyyy'
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
format: 'MMMM d, yyyy',
|
|
295
|
-
placeholder: 'Month D, YYYY',
|
|
296
|
-
label: 'MMMM d, yyyy'
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
format: 'MMM dd, yyyy',
|
|
300
|
-
placeholder: 'Mon DD, YYYY',
|
|
301
|
-
label: 'MMM dd, yyyy'
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
format: 'dd/MM/yyyy',
|
|
305
|
-
placeholder: 'DD/MM/YYYY',
|
|
306
|
-
label: 'dd/MM/yyyy'
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
format: 'MM/dd/yyyy',
|
|
310
|
-
placeholder: 'MM/DD/YYYY',
|
|
311
|
-
label: 'MM/dd/yyyy'
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
format: 'yyyy-MM-dd',
|
|
315
|
-
placeholder: 'YYYY-MM-DD',
|
|
316
|
-
label: 'yyyy-MM-dd'
|
|
317
|
-
}
|
|
318
|
-
];
|
|
319
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
320
|
-
className: "flex flex-col gap-32 p-32 min-w-350",
|
|
321
|
-
children: [
|
|
322
|
-
/*#__PURE__*/ _jsx("h3", {
|
|
323
|
-
className: "text-lg font-semibold mb-16 text-foreground-neutral-base",
|
|
324
|
-
children: "Date Format Examples"
|
|
325
|
-
}),
|
|
326
|
-
/*#__PURE__*/ _jsx("div", {
|
|
327
|
-
className: "flex flex-col gap-16",
|
|
328
|
-
children: formats.map(({ format, placeholder, label })=>/*#__PURE__*/ _jsxs("div", {
|
|
329
|
-
children: [
|
|
330
|
-
/*#__PURE__*/ _jsx("p", {
|
|
331
|
-
className: "text-xs text-foreground-neutral-subtle mb-8 font-mono",
|
|
332
|
-
children: label
|
|
333
|
-
}),
|
|
334
|
-
/*#__PURE__*/ _jsx(DatePicker, {
|
|
335
|
-
date: date,
|
|
336
|
-
onDateSelect: setDate,
|
|
337
|
-
onClear: ()=>setDate(undefined),
|
|
338
|
-
dateFormat: format,
|
|
339
|
-
placeholder: placeholder
|
|
340
|
-
})
|
|
341
|
-
]
|
|
342
|
-
}, format))
|
|
343
|
-
})
|
|
344
|
-
]
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
//# sourceMappingURL=date-picker.stories.js.map
|
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, ButtonLink } from '../../components/button/index.js';
|
|
3
|
-
import { DropdownInput } from '../../components/dropdown-input/index.js';
|
|
4
|
-
import { Icon } from '../../components/icon/index.js';
|
|
5
|
-
import { Label } from '../../components/label/index.js';
|
|
6
|
-
import { useMemo, useRef, useState } from 'react';
|
|
7
|
-
const sampleItems = [
|
|
8
|
-
{
|
|
9
|
-
id: 'apache',
|
|
10
|
-
label: 'apache',
|
|
11
|
-
value: 'apache'
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
id: 'apache-superset',
|
|
15
|
-
label: 'apache-superset',
|
|
16
|
-
value: 'apache-superset'
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
id: 'apaleo',
|
|
20
|
-
label: 'apaleo',
|
|
21
|
-
value: 'apaleo'
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
id: 'apollo',
|
|
25
|
-
label: 'apollo',
|
|
26
|
-
value: 'apollo'
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
id: 'apple',
|
|
30
|
-
label: 'apple',
|
|
31
|
-
value: 'apple'
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
id: 'apache-kafka',
|
|
35
|
-
label: 'apache-kafka',
|
|
36
|
-
value: 'apache-kafka'
|
|
37
|
-
}
|
|
38
|
-
];
|
|
39
|
-
const meta = {
|
|
40
|
-
title: 'Components/DropdownInput',
|
|
41
|
-
component: DropdownInput,
|
|
42
|
-
tags: [
|
|
43
|
-
'autodocs'
|
|
44
|
-
],
|
|
45
|
-
parameters: {
|
|
46
|
-
layout: 'centered'
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
export default meta;
|
|
50
|
-
function CustomEmptyStateContent({ value, onValueChange, onOpenChange, contactSupportHref, inputRef }) {
|
|
51
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
52
|
-
className: "flex flex-col items-start justify-center",
|
|
53
|
-
children: [
|
|
54
|
-
/*#__PURE__*/ _jsxs(Button, {
|
|
55
|
-
type: "button",
|
|
56
|
-
variant: "transparent",
|
|
57
|
-
className: "!px-4 w-full justify-start",
|
|
58
|
-
onClick: ()=>{
|
|
59
|
-
onValueChange(value);
|
|
60
|
-
onOpenChange(false);
|
|
61
|
-
inputRef.current?.blur();
|
|
62
|
-
},
|
|
63
|
-
children: [
|
|
64
|
-
/*#__PURE__*/ _jsx(Icon, {
|
|
65
|
-
name: "addLine",
|
|
66
|
-
className: "size-16 text-foreground-neutral-subtle"
|
|
67
|
-
}),
|
|
68
|
-
/*#__PURE__*/ _jsx("span", {
|
|
69
|
-
className: "truncate",
|
|
70
|
-
children: value
|
|
71
|
-
})
|
|
72
|
-
]
|
|
73
|
-
}),
|
|
74
|
-
/*#__PURE__*/ _jsxs("p", {
|
|
75
|
-
className: "px-8 whitespace-pre-wrap",
|
|
76
|
-
children: [
|
|
77
|
-
"Repository list is limited to 100. Enter the full repository path or",
|
|
78
|
-
' ',
|
|
79
|
-
/*#__PURE__*/ _jsx(ButtonLink, {
|
|
80
|
-
variant: "base",
|
|
81
|
-
underline: true,
|
|
82
|
-
href: contactSupportHref,
|
|
83
|
-
target: "_blank",
|
|
84
|
-
rel: "noopener noreferrer",
|
|
85
|
-
className: "!font-regular",
|
|
86
|
-
children: "contact support"
|
|
87
|
-
}),
|
|
88
|
-
"."
|
|
89
|
-
]
|
|
90
|
-
})
|
|
91
|
-
]
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
export const Default = {
|
|
95
|
-
args: {},
|
|
96
|
-
render: ()=>{
|
|
97
|
-
const [value, setValue] = useState('');
|
|
98
|
-
const [open, setOpen] = useState(false);
|
|
99
|
-
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
100
|
-
const [selectedItem, setSelectedItem] = useState(null);
|
|
101
|
-
const inputRef = useRef(null);
|
|
102
|
-
const items = useMemo(()=>{
|
|
103
|
-
if (value.length < 1) return sampleItems;
|
|
104
|
-
const lowerQuery = value.toLowerCase();
|
|
105
|
-
return sampleItems.filter((item)=>item.label.toLowerCase().includes(lowerQuery));
|
|
106
|
-
}, [
|
|
107
|
-
value
|
|
108
|
-
]);
|
|
109
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
110
|
-
className: "w-[80vw] md:w-500",
|
|
111
|
-
children: [
|
|
112
|
-
/*#__PURE__*/ _jsx(Label, {
|
|
113
|
-
htmlFor: "dropdown-input",
|
|
114
|
-
children: "Search repositories"
|
|
115
|
-
}),
|
|
116
|
-
/*#__PURE__*/ _jsx(DropdownInput, {
|
|
117
|
-
id: "dropdown-input",
|
|
118
|
-
value: value,
|
|
119
|
-
onValueChange: (newValue)=>{
|
|
120
|
-
setValue(newValue);
|
|
121
|
-
if (selectedItem && selectedItem.label !== newValue) {
|
|
122
|
-
setSelectedItem(null);
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
onSelect: (item)=>{
|
|
126
|
-
setSelectedItem(item);
|
|
127
|
-
},
|
|
128
|
-
selectedItem: selectedItem,
|
|
129
|
-
items: items,
|
|
130
|
-
open: open,
|
|
131
|
-
onOpenChange: setOpen,
|
|
132
|
-
focusedIndex: focusedIndex,
|
|
133
|
-
onFocusedIndexChange: setFocusedIndex,
|
|
134
|
-
placeholder: "Type to search...",
|
|
135
|
-
emptyPlaceholder: /*#__PURE__*/ _jsx(CustomEmptyStateContent, {
|
|
136
|
-
value: value,
|
|
137
|
-
onValueChange: setValue,
|
|
138
|
-
onOpenChange: setOpen,
|
|
139
|
-
contactSupportHref: "https://support.example.com",
|
|
140
|
-
inputRef: inputRef
|
|
141
|
-
})
|
|
142
|
-
})
|
|
143
|
-
]
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
export const EmptyState = {
|
|
148
|
-
args: {},
|
|
149
|
-
render: ()=>{
|
|
150
|
-
const [value, setValue] = useState('abcxyz');
|
|
151
|
-
const [open, setOpen] = useState(true);
|
|
152
|
-
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
153
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
154
|
-
className: "w-[80vw] md:w-500",
|
|
155
|
-
children: [
|
|
156
|
-
/*#__PURE__*/ _jsx(Label, {
|
|
157
|
-
htmlFor: "dropdown-empty",
|
|
158
|
-
children: "No results"
|
|
159
|
-
}),
|
|
160
|
-
/*#__PURE__*/ _jsx(DropdownInput, {
|
|
161
|
-
id: "dropdown-empty",
|
|
162
|
-
value: value,
|
|
163
|
-
onValueChange: setValue,
|
|
164
|
-
items: [],
|
|
165
|
-
open: open,
|
|
166
|
-
onOpenChange: setOpen,
|
|
167
|
-
focusedIndex: focusedIndex,
|
|
168
|
-
onFocusedIndexChange: setFocusedIndex,
|
|
169
|
-
placeholder: "Type to search...",
|
|
170
|
-
emptyPlaceholder: "No results found"
|
|
171
|
-
})
|
|
172
|
-
]
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
export const LoadingState = {
|
|
177
|
-
args: {},
|
|
178
|
-
render: ()=>{
|
|
179
|
-
const [value, setValue] = useState('apache');
|
|
180
|
-
const [open, setOpen] = useState(true);
|
|
181
|
-
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
182
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
183
|
-
className: "w-[80vw] md:w-500",
|
|
184
|
-
children: [
|
|
185
|
-
/*#__PURE__*/ _jsx(Label, {
|
|
186
|
-
htmlFor: "dropdown-loading",
|
|
187
|
-
children: "Loading"
|
|
188
|
-
}),
|
|
189
|
-
/*#__PURE__*/ _jsx(DropdownInput, {
|
|
190
|
-
id: "dropdown-loading",
|
|
191
|
-
value: value,
|
|
192
|
-
onValueChange: setValue,
|
|
193
|
-
items: [],
|
|
194
|
-
iconRight: /*#__PURE__*/ _jsx(Icon, {
|
|
195
|
-
name: "spinner",
|
|
196
|
-
className: "size-16 text-foreground-neutral-base"
|
|
197
|
-
}),
|
|
198
|
-
open: open,
|
|
199
|
-
onOpenChange: setOpen,
|
|
200
|
-
focusedIndex: focusedIndex,
|
|
201
|
-
onFocusedIndexChange: setFocusedIndex,
|
|
202
|
-
placeholder: "Type to search...",
|
|
203
|
-
emptyPlaceholder: "Fetching..."
|
|
204
|
-
})
|
|
205
|
-
]
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
export const DisabledState = {
|
|
210
|
-
args: {},
|
|
211
|
-
render: ()=>{
|
|
212
|
-
const [value, setValue] = useState('apache');
|
|
213
|
-
const [open, setOpen] = useState(false);
|
|
214
|
-
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
215
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
216
|
-
className: "w-[80vw] md:w-500",
|
|
217
|
-
children: [
|
|
218
|
-
/*#__PURE__*/ _jsx(Label, {
|
|
219
|
-
htmlFor: "dropdown-disabled",
|
|
220
|
-
children: "Disabled"
|
|
221
|
-
}),
|
|
222
|
-
/*#__PURE__*/ _jsx(DropdownInput, {
|
|
223
|
-
id: "dropdown-disabled",
|
|
224
|
-
value: value,
|
|
225
|
-
onValueChange: setValue,
|
|
226
|
-
items: sampleItems,
|
|
227
|
-
disabled: true,
|
|
228
|
-
open: open,
|
|
229
|
-
onOpenChange: setOpen,
|
|
230
|
-
focusedIndex: focusedIndex,
|
|
231
|
-
onFocusedIndexChange: setFocusedIndex,
|
|
232
|
-
placeholder: "Disabled input",
|
|
233
|
-
emptyPlaceholder: "No results found"
|
|
234
|
-
})
|
|
235
|
-
]
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
//# sourceMappingURL=dropdown-input.stories.js.map
|