@central-ui/react 0.1.2 → 0.2.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/LICENSE +49 -0
- package/dist/components/accordion/index.d.ts +4 -3
- package/dist/components/accordion/index.js +7 -4
- package/dist/components/autocomplete/index.d.ts +14 -25
- package/dist/components/autocomplete/index.js +70 -54
- package/dist/components/avatar/index.d.ts +1 -2
- package/dist/components/avatar/index.js +0 -1
- package/dist/components/badge/index.d.ts +0 -1
- package/dist/components/badge/index.js +2 -2
- package/dist/components/banner/index.d.ts +1 -1
- package/dist/components/banner/index.js +23 -25
- package/dist/components/barchart/index.d.ts +106 -0
- package/dist/components/barchart/index.js +122 -0
- package/dist/components/breadcrumb/index.d.ts +0 -1
- package/dist/components/breadcrumb/index.js +6 -7
- package/dist/components/button/index.d.ts +2 -3
- package/dist/components/button/index.js +11 -12
- package/dist/components/card/index.d.ts +0 -1
- package/dist/components/card/index.js +0 -1
- package/dist/components/checkbox/index.d.ts +13 -11
- package/dist/components/checkbox/index.js +51 -31
- package/dist/components/chip/index.d.ts +1 -1
- package/dist/components/chip/index.js +2 -3
- package/dist/components/combobox/index.d.ts +18 -30
- package/dist/components/combobox/index.js +90 -67
- package/dist/components/datepicker/index.d.ts +18 -31
- package/dist/components/datepicker/index.js +81 -99
- package/dist/components/dialog/index.d.ts +14 -27
- package/dist/components/dialog/index.js +17 -18
- package/dist/components/divider/index.d.ts +0 -1
- package/dist/components/divider/index.js +0 -1
- package/dist/components/donutchart/index.d.ts +100 -0
- package/dist/components/donutchart/index.js +178 -0
- package/dist/components/drawer/index.d.ts +12 -21
- package/dist/components/drawer/index.js +34 -36
- package/dist/components/empty/index.d.ts +1 -2
- package/dist/components/empty/index.js +2 -4
- package/dist/components/fileupload/index.d.ts +4 -9
- package/dist/components/fileupload/index.js +26 -38
- package/dist/components/form/index.d.ts +0 -1
- package/dist/components/form/index.js +0 -1
- package/dist/components/horizontalbarchart/index.d.ts +120 -0
- package/dist/components/horizontalbarchart/index.js +193 -0
- package/dist/components/input/index.d.ts +22 -22
- package/dist/components/input/index.js +76 -105
- package/dist/components/linechart/index.d.ts +114 -0
- package/dist/components/linechart/index.js +139 -0
- package/dist/components/menu/index.d.ts +9 -11
- package/dist/components/menu/index.js +42 -39
- package/dist/components/metric/index.d.ts +0 -1
- package/dist/components/metric/index.js +0 -1
- package/dist/components/numberinput/index.d.ts +14 -21
- package/dist/components/numberinput/index.js +40 -53
- package/dist/components/otpinput/index.d.ts +14 -9
- package/dist/components/otpinput/index.js +25 -18
- package/dist/components/page/index.d.ts +0 -1
- package/dist/components/page/index.js +1 -3
- package/dist/components/passwordinput/index.d.ts +14 -11
- package/dist/components/passwordinput/index.js +36 -45
- package/dist/components/popover/index.d.ts +21 -19
- package/dist/components/popover/index.js +34 -15
- package/dist/components/radio/index.d.ts +13 -9
- package/dist/components/radio/index.js +69 -60
- package/dist/components/ratinginput/index.d.ts +13 -8
- package/dist/components/ratinginput/index.js +37 -17
- package/dist/components/select/index.d.ts +25 -28
- package/dist/components/select/index.js +67 -38
- package/dist/components/skeleton/index.d.ts +0 -1
- package/dist/components/skeleton/index.js +0 -1
- package/dist/components/slider/index.d.ts +14 -9
- package/dist/components/slider/index.js +64 -63
- package/dist/components/spinner/index.d.ts +1 -2
- package/dist/components/spinner/index.js +2 -3
- package/dist/components/splitter/index.d.ts +1 -2
- package/dist/components/splitter/index.js +5 -6
- package/dist/components/stepper/index.d.ts +8 -20
- package/dist/components/stepper/index.js +15 -16
- package/dist/components/switch/index.d.ts +12 -10
- package/dist/components/switch/index.js +46 -30
- package/dist/components/table/index.d.ts +3 -3
- package/dist/components/table/index.js +14 -13
- package/dist/components/tabs/index.d.ts +0 -1
- package/dist/components/tabs/index.js +1 -2
- package/dist/components/textarea/index.d.ts +14 -11
- package/dist/components/textarea/index.js +37 -46
- package/dist/components/textlink/index.d.ts +3 -1
- package/dist/components/textlink/index.js +4 -1
- package/dist/components/toast/index.d.ts +8 -14
- package/dist/components/toast/index.js +48 -48
- package/dist/components/toggle/index.d.ts +0 -1
- package/dist/components/toggle/index.js +17 -24
- package/dist/components/tooltip/index.d.ts +11 -13
- package/dist/components/tooltip/index.js +12 -9
- package/dist/components/tour/index.d.ts +154 -0
- package/dist/components/tour/index.js +280 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -1
- package/dist/types/Icon.d.ts +0 -1
- package/dist/types/Icon.js +0 -1
- package/dist/types/Style.d.ts +0 -1
- package/dist/types/Style.js +0 -1
- package/dist/types/Tone.d.ts +0 -1
- package/dist/types/Tone.js +0 -1
- package/dist/types/Validation.d.ts +12 -0
- package/dist/types/Validation.js +1 -0
- package/dist/utils/ArkStateToDataAttributes.d.ts +0 -1
- package/dist/utils/ArkStateToDataAttributes.js +0 -1
- package/dist/utils/Tone.d.ts +0 -1
- package/dist/utils/Tone.js +0 -1
- package/dist/utils/Validation.d.ts +14 -0
- package/dist/utils/Validation.js +23 -0
- package/dist/utils/asChild.d.ts +41 -0
- package/dist/utils/asChild.js +15 -0
- package/dist/utils/icons.d.ts +24 -0
- package/dist/utils/icons.js +160 -0
- package/dist/utils/useForwardClickToInput.d.ts +0 -1
- package/dist/utils/useForwardClickToInput.js +0 -1
- package/dist/utils/virtualization/useVirtualizedAutocomplete.d.ts +0 -1
- package/dist/utils/virtualization/useVirtualizedAutocomplete.js +0 -1
- package/dist/utils/virtualization/useVirtualizedCombobox.d.ts +0 -1
- package/dist/utils/virtualization/useVirtualizedCombobox.js +0 -1
- package/dist/utils/virtualization/useVirtualizedTable.d.ts +0 -1
- package/dist/utils/virtualization/useVirtualizedTable.js +0 -1
- package/package.json +12 -11
- package/src/presets/shopify-polaris/shopify-polaris-autocomplete.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-barchart.css +64 -0
- package/src/presets/shopify-polaris/shopify-polaris-checkbox.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-combobox.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-datepicker.css +4 -4
- package/src/presets/shopify-polaris/shopify-polaris-dialog.css +16 -0
- package/src/presets/shopify-polaris/shopify-polaris-donutchart.css +172 -0
- package/src/presets/shopify-polaris/shopify-polaris-drawer.css +16 -0
- package/src/presets/shopify-polaris/shopify-polaris-fileupload.css +1 -1
- package/src/presets/shopify-polaris/shopify-polaris-horizontalbarchart.css +60 -0
- package/src/presets/shopify-polaris/shopify-polaris-input.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-linechart.css +68 -0
- package/src/presets/shopify-polaris/shopify-polaris-menu.css +16 -0
- package/src/presets/shopify-polaris/shopify-polaris-numberinput.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-otpinput.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-passwordinput.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-popover.css +29 -0
- package/src/presets/shopify-polaris/shopify-polaris-radio.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-ratinginput.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-select.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-slider.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-stepper.css +16 -0
- package/src/presets/shopify-polaris/shopify-polaris-switch.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-textarea.css +2 -2
- package/src/presets/shopify-polaris/shopify-polaris-tooltip.css +16 -0
- package/src/presets/shopify-polaris/shopify-polaris.css +4 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-autocomplete.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-barchart.css +64 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-checkbox.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-combobox.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-datepicker.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-dialog.css +9 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-donutchart.css +172 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-drawer.css +9 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-fileupload.css +1 -1
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-horizontalbarchart.css +60 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-input.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-linechart.css +68 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-menu.css +9 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-numberinput.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-otpinput.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-passwordinput.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-popover.css +22 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-radio.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-ratinginput.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-slider.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-stepper.css +9 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-switch.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-textarea.css +2 -2
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy-tooltip.css +9 -0
- package/src/presets/shopify-polaris-legacy/shopify-polaris-legacy.css +4 -0
- package/dist/components/accordion/index.d.ts.map +0 -1
- package/dist/components/accordion/index.js.map +0 -1
- package/dist/components/autocomplete/index.d.ts.map +0 -1
- package/dist/components/autocomplete/index.js.map +0 -1
- package/dist/components/avatar/index.d.ts.map +0 -1
- package/dist/components/avatar/index.js.map +0 -1
- package/dist/components/badge/index.d.ts.map +0 -1
- package/dist/components/badge/index.js.map +0 -1
- package/dist/components/banner/index.d.ts.map +0 -1
- package/dist/components/banner/index.js.map +0 -1
- package/dist/components/breadcrumb/index.d.ts.map +0 -1
- package/dist/components/breadcrumb/index.js.map +0 -1
- package/dist/components/button/index.d.ts.map +0 -1
- package/dist/components/button/index.js.map +0 -1
- package/dist/components/card/index.d.ts.map +0 -1
- package/dist/components/card/index.js.map +0 -1
- package/dist/components/checkbox/index.d.ts.map +0 -1
- package/dist/components/checkbox/index.js.map +0 -1
- package/dist/components/chip/index.d.ts.map +0 -1
- package/dist/components/chip/index.js.map +0 -1
- package/dist/components/combobox/index.d.ts.map +0 -1
- package/dist/components/combobox/index.js.map +0 -1
- package/dist/components/datepicker/index.d.ts.map +0 -1
- package/dist/components/datepicker/index.js.map +0 -1
- package/dist/components/dialog/index.d.ts.map +0 -1
- package/dist/components/dialog/index.js.map +0 -1
- package/dist/components/divider/index.d.ts.map +0 -1
- package/dist/components/divider/index.js.map +0 -1
- package/dist/components/drawer/index.d.ts.map +0 -1
- package/dist/components/drawer/index.js.map +0 -1
- package/dist/components/empty/index.d.ts.map +0 -1
- package/dist/components/empty/index.js.map +0 -1
- package/dist/components/fileupload/index.d.ts.map +0 -1
- package/dist/components/fileupload/index.js.map +0 -1
- package/dist/components/form/index.d.ts.map +0 -1
- package/dist/components/form/index.js.map +0 -1
- package/dist/components/input/index.d.ts.map +0 -1
- package/dist/components/input/index.js.map +0 -1
- package/dist/components/menu/index.d.ts.map +0 -1
- package/dist/components/menu/index.js.map +0 -1
- package/dist/components/metric/index.d.ts.map +0 -1
- package/dist/components/metric/index.js.map +0 -1
- package/dist/components/numberinput/index.d.ts.map +0 -1
- package/dist/components/numberinput/index.js.map +0 -1
- package/dist/components/otpinput/index.d.ts.map +0 -1
- package/dist/components/otpinput/index.js.map +0 -1
- package/dist/components/page/index.d.ts.map +0 -1
- package/dist/components/page/index.js.map +0 -1
- package/dist/components/passwordinput/index.d.ts.map +0 -1
- package/dist/components/passwordinput/index.js.map +0 -1
- package/dist/components/popover/index.d.ts.map +0 -1
- package/dist/components/popover/index.js.map +0 -1
- package/dist/components/radio/index.d.ts.map +0 -1
- package/dist/components/radio/index.js.map +0 -1
- package/dist/components/ratinginput/index.d.ts.map +0 -1
- package/dist/components/ratinginput/index.js.map +0 -1
- package/dist/components/select/index.d.ts.map +0 -1
- package/dist/components/select/index.js.map +0 -1
- package/dist/components/skeleton/index.d.ts.map +0 -1
- package/dist/components/skeleton/index.js.map +0 -1
- package/dist/components/slider/index.d.ts.map +0 -1
- package/dist/components/slider/index.js.map +0 -1
- package/dist/components/spinner/index.d.ts.map +0 -1
- package/dist/components/spinner/index.js.map +0 -1
- package/dist/components/splitter/index.d.ts.map +0 -1
- package/dist/components/splitter/index.js.map +0 -1
- package/dist/components/stepper/index.d.ts.map +0 -1
- package/dist/components/stepper/index.js.map +0 -1
- package/dist/components/switch/index.d.ts.map +0 -1
- package/dist/components/switch/index.js.map +0 -1
- package/dist/components/table/index.d.ts.map +0 -1
- package/dist/components/table/index.js.map +0 -1
- package/dist/components/tabs/index.d.ts.map +0 -1
- package/dist/components/tabs/index.js.map +0 -1
- package/dist/components/textarea/index.d.ts.map +0 -1
- package/dist/components/textarea/index.js.map +0 -1
- package/dist/components/textlink/index.d.ts.map +0 -1
- package/dist/components/textlink/index.js.map +0 -1
- package/dist/components/toast/index.d.ts.map +0 -1
- package/dist/components/toast/index.js.map +0 -1
- package/dist/components/toggle/index.d.ts.map +0 -1
- package/dist/components/toggle/index.js.map +0 -1
- package/dist/components/tooltip/index.d.ts.map +0 -1
- package/dist/components/tooltip/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types/Icon.d.ts.map +0 -1
- package/dist/types/Icon.js.map +0 -1
- package/dist/types/Style.d.ts.map +0 -1
- package/dist/types/Style.js.map +0 -1
- package/dist/types/Tone.d.ts.map +0 -1
- package/dist/types/Tone.js.map +0 -1
- package/dist/utils/ArkStateToDataAttributes.d.ts.map +0 -1
- package/dist/utils/ArkStateToDataAttributes.js.map +0 -1
- package/dist/utils/Tone.d.ts.map +0 -1
- package/dist/utils/Tone.js.map +0 -1
- package/dist/utils/useForwardClickToInput.d.ts.map +0 -1
- package/dist/utils/useForwardClickToInput.js.map +0 -1
- package/dist/utils/virtualization/useVirtualizedAutocomplete.d.ts.map +0 -1
- package/dist/utils/virtualization/useVirtualizedAutocomplete.js.map +0 -1
- package/dist/utils/virtualization/useVirtualizedCombobox.d.ts.map +0 -1
- package/dist/utils/virtualization/useVirtualizedCombobox.js.map +0 -1
- package/dist/utils/virtualization/useVirtualizedTable.d.ts.map +0 -1
- package/dist/utils/virtualization/useVirtualizedTable.js.map +0 -1
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { asChildStyleAttributes } from "../../utils/asChild.js";
|
|
3
|
+
import { Joyride, ACTIONS, EVENTS, STATUS } from 'react-joyride';
|
|
4
|
+
import { cloneElement, createContext, useContext, useLayoutEffect, useState, } from 'react';
|
|
5
|
+
import { X } from "../../utils/icons.js";
|
|
6
|
+
import { twMerge } from 'tailwind-merge';
|
|
7
|
+
/**
|
|
8
|
+
* A guided tour that highlights elements one by one, each with a popup next to it.
|
|
9
|
+
* Root holds the steps (which element, in which order); Popup holds what every popup shows.
|
|
10
|
+
* Write the popup's frame and buttons once, and put what differs per step in a Content
|
|
11
|
+
* with the step's `value`, like Tabs.Content. Back/Next/Done/Skip/Close are styled buttons that show only when they can act.
|
|
12
|
+
*
|
|
13
|
+
* @example Complete composition, opened from a button
|
|
14
|
+
* import { Button, Tour } from '@central-ui/react'
|
|
15
|
+
*
|
|
16
|
+
* function Example() {
|
|
17
|
+
* const [open, setOpen] = useState(false)
|
|
18
|
+
*
|
|
19
|
+
* return (
|
|
20
|
+
* <>
|
|
21
|
+
* <Button.default onClick={() => setOpen(true)}>Take the tour</Button.default>
|
|
22
|
+
* <div id="search">…</div>
|
|
23
|
+
* <div id="filters">…</div>
|
|
24
|
+
*
|
|
25
|
+
* <Tour.Root
|
|
26
|
+
* steps={[
|
|
27
|
+
* { value: 'search', target: '#search' },
|
|
28
|
+
* { value: 'filters', target: '#filters' },
|
|
29
|
+
* ]}
|
|
30
|
+
* open={open}
|
|
31
|
+
* onOpenChange={setOpen}
|
|
32
|
+
* >
|
|
33
|
+
* <Tour.Popup>
|
|
34
|
+
* <Tour.Content value="search">
|
|
35
|
+
* <Tour.Title>Search</Tour.Title>
|
|
36
|
+
* <Tour.Description>Find any order fast.</Tour.Description>
|
|
37
|
+
* </Tour.Content>
|
|
38
|
+
* <Tour.Content value="filters">
|
|
39
|
+
* <Tour.Title>Filters</Tour.Title>
|
|
40
|
+
* <Tour.Description>Narrow the results.</Tour.Description>
|
|
41
|
+
* </Tour.Content>
|
|
42
|
+
* <Tour.Progress />
|
|
43
|
+
* <Tour.BackButton>Back</Tour.BackButton>
|
|
44
|
+
* <Tour.NextButton>Next</Tour.NextButton>
|
|
45
|
+
* <Tour.DoneButton>Done</Tour.DoneButton>
|
|
46
|
+
* </Tour.Popup>
|
|
47
|
+
* </Tour.Root>
|
|
48
|
+
* </>
|
|
49
|
+
* )
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* @example Start on its own as soon as the page mounts, with no trigger button
|
|
53
|
+
* // Uncontrolled: defaultOpen starts the tour when Root mounts, and Root closes it itself.
|
|
54
|
+
* // Mount Root conditionally (e.g. only for users who haven't seen it) to show it once.
|
|
55
|
+
* ;<Tour.Root steps={steps} defaultOpen onOpenChange={(open) => { if (!open) markTourSeen() }}>
|
|
56
|
+
* <Tour.Popup>…</Tour.Popup>
|
|
57
|
+
* </Tour.Root>
|
|
58
|
+
*
|
|
59
|
+
* @example Content only one step has, like a video
|
|
60
|
+
* // Anything inside a Content shows only on its step; anything outside shows on every step.
|
|
61
|
+
* ;<Tour.Content value="filters">
|
|
62
|
+
* <Tour.Title>Filters</Tour.Title>
|
|
63
|
+
* <video src="/filters.mp4" autoPlay muted />
|
|
64
|
+
* </Tour.Content>
|
|
65
|
+
*
|
|
66
|
+
* @example Let users click the highlighted element during a step
|
|
67
|
+
* ;<Tour.Root steps={[{ value: 'upload', target: '#upload', interactive: true }]}>
|
|
68
|
+
*/
|
|
69
|
+
export function Root(props) {
|
|
70
|
+
// The step the tour starts on, and rewinds to when it ends
|
|
71
|
+
const firstStep = props.defaultStep ?? props.steps[0].value;
|
|
72
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(props.defaultOpen ?? false);
|
|
73
|
+
const [uncontrolledStep, setUncontrolledStep] = useState(firstStep);
|
|
74
|
+
const [placement, setPlacement] = useState({
|
|
75
|
+
side: 'bottom',
|
|
76
|
+
align: 'center',
|
|
77
|
+
});
|
|
78
|
+
// Controlled props win over the internal state, like Base UI's open and value
|
|
79
|
+
const isOpen = props.open ?? uncontrolledOpen;
|
|
80
|
+
const currentStep = props.step ?? uncontrolledStep;
|
|
81
|
+
// Joyride counts steps by position, so the current value becomes its index
|
|
82
|
+
const stepIndex = props.steps.findIndex((step) => step.value === currentStep);
|
|
83
|
+
// Joyride places by one word, so Popup's side and align become e.g. 'left-start'
|
|
84
|
+
const joyridePlacement = placement.align === 'center'
|
|
85
|
+
? placement.side
|
|
86
|
+
: `${placement.side}-${placement.align}`;
|
|
87
|
+
return (_jsx(RootContext.Provider, { value: { children: props.children, steps: props.steps, setPlacement }, children: _jsx(Joyride, { run: isOpen, stepIndex: stepIndex, steps: props.steps.map((step) => ({
|
|
88
|
+
target: step.target,
|
|
89
|
+
id: step.value,
|
|
90
|
+
// The popup's text lives in Content parts, not in data
|
|
91
|
+
content: null,
|
|
92
|
+
placement: joyridePlacement,
|
|
93
|
+
blockTargetInteraction: !step.interactive,
|
|
94
|
+
})),
|
|
95
|
+
// Next moves straight to the following step, as in a classic guided tour
|
|
96
|
+
continuous: true, scrollToFirstStep: true, options: {
|
|
97
|
+
// Steps open directly, without a pulsing dot to click first
|
|
98
|
+
skipBeacon: true,
|
|
99
|
+
// A stray click on the dark overlay never ends the tour
|
|
100
|
+
overlayClickAction: false,
|
|
101
|
+
// Core layout, not overridable: the arrow matches Popover's and Tooltip's 20×10 size
|
|
102
|
+
arrowBase: 20,
|
|
103
|
+
arrowSize: 10,
|
|
104
|
+
}, tooltipComponent: PopupSlot, arrowComponent: Arrow, onEvent: (event) => {
|
|
105
|
+
// Ending the tour and rewinding it, so it restarts from the first step.
|
|
106
|
+
// Stopping `run` is what removes Joyride's overlay.
|
|
107
|
+
const end = () => {
|
|
108
|
+
setUncontrolledOpen(false);
|
|
109
|
+
props.onOpenChange?.(false);
|
|
110
|
+
setUncontrolledStep(firstStep);
|
|
111
|
+
props.onStepChange?.(firstStep);
|
|
112
|
+
};
|
|
113
|
+
// Ending by Skip, Close, or Escape
|
|
114
|
+
if (event.status === STATUS.SKIPPED || event.action === ACTIONS.CLOSE)
|
|
115
|
+
return end();
|
|
116
|
+
// Moving to the next or previous step, or past a target missing from the page.
|
|
117
|
+
// In controlled mode Joyride waits for the new step, so moving past the last one (Done) must end the tour here.
|
|
118
|
+
if (event.type === EVENTS.STEP_AFTER ||
|
|
119
|
+
event.type === EVENTS.TARGET_NOT_FOUND) {
|
|
120
|
+
const nextStep = props.steps[event.index + (event.action === ACTIONS.PREV ? -1 : 1)];
|
|
121
|
+
if (!nextStep)
|
|
122
|
+
return end();
|
|
123
|
+
setUncontrolledStep(nextStep.value);
|
|
124
|
+
props.onStepChange?.(nextStep.value);
|
|
125
|
+
}
|
|
126
|
+
} }) }));
|
|
127
|
+
}
|
|
128
|
+
const RootContext = /* @__PURE__ */ createContext(null);
|
|
129
|
+
/**
|
|
130
|
+
* Popover's arrow, drawn in Joyride's arrow slot. Its white base strip covers the popup's border where they meet,
|
|
131
|
+
* and it overlaps the popup by 2px, so the arrow reads as part of the popup with the border running around both.
|
|
132
|
+
*/
|
|
133
|
+
function Arrow(arrow) {
|
|
134
|
+
// The SVG points up, which fits a popup sitting below its target; other sides rotate it
|
|
135
|
+
const rotation = (() => {
|
|
136
|
+
if (arrow.placement.startsWith('top'))
|
|
137
|
+
return 180;
|
|
138
|
+
if (arrow.placement.startsWith('left'))
|
|
139
|
+
return 90;
|
|
140
|
+
if (arrow.placement.startsWith('right'))
|
|
141
|
+
return -90;
|
|
142
|
+
return 0;
|
|
143
|
+
})();
|
|
144
|
+
return (_jsxs("svg", { "aria-hidden": true, width: "20", height: "10", viewBox: "0 0 20 10", "data-component": "tour-arrow", "data-side": arrow.placement.split('-')[0], className: "pointer-events-none fill-white",
|
|
145
|
+
// Core layout, not overridable: centered in Joyride's slot, rotated to its side, nudged 2px into the popup
|
|
146
|
+
style: {
|
|
147
|
+
position: 'absolute',
|
|
148
|
+
top: '50%',
|
|
149
|
+
left: '50%',
|
|
150
|
+
transform: `translate(-50%, -50%) rotate(${rotation}deg) translateY(2px)`,
|
|
151
|
+
}, children: [_jsx("path", { d: "M9.66437 2.60207L4.80758 6.97318C4.07308 7.63423 3.11989 8 2.13172 8H0V10H20V8H18.5349C17.5468 8 16.5936 7.63423 15.8591 6.97318L11.0023 2.60207C10.622 2.2598 10.0447 2.25979 9.66437 2.60207Z", "data-component": "tour-arrow-1", className: "fill-inherit" }), _jsx("path", { d: "M8.99542 1.85876C9.75604 1.17425 10.9106 1.17422 11.6713 1.85878L16.5281 6.22989C17.0789 6.72568 17.7938 7.00001 18.5349 7.00001L15.89 7L11.0023 2.60207C10.622 2.2598 10.0447 2.2598 9.66436 2.60207L4.77734 7L2.13171 7.00001C2.87284 7.00001 3.58774 6.72568 4.13861 6.22989L8.99542 1.85876Z", "data-component": "tour-arrow-2", className: "fill-neutral-200" }), _jsx("path", { d: "M10.3333 3.34539L5.47654 7.71648C4.55842 8.54279 3.36693 9 2.13172 9H0V8H2.13172C3.11989 8 4.07308 7.63423 4.80758 6.97318L9.66437 2.60207C10.0447 2.25979 10.622 2.2598 11.0023 2.60207L15.8591 6.97318C16.5936 7.63423 17.5468 8 18.5349 8H20V9H18.5349C17.2998 9 16.1083 8.54278 15.1901 7.71648L10.3333 3.34539Z", "data-component": "tour-arrow-3", className: "fill-inherit" })] }));
|
|
152
|
+
}
|
|
153
|
+
const StepContext = /* @__PURE__ */ createContext(null);
|
|
154
|
+
/** Joyride renders this in its popup slot; it shows Root's children with the current step's state. */
|
|
155
|
+
function PopupSlot(joyride) {
|
|
156
|
+
const root = useContext(RootContext);
|
|
157
|
+
if (!root)
|
|
158
|
+
throw new Error('Tour parts must be inside Tour.Root');
|
|
159
|
+
return (_jsx(StepContext.Provider, { value: { value: root.steps[joyride.index].value, joyride }, children: root.children }));
|
|
160
|
+
}
|
|
161
|
+
function useStep(part) {
|
|
162
|
+
const step = useContext(StepContext);
|
|
163
|
+
if (!step)
|
|
164
|
+
throw new Error(`Tour.${part} must be inside Tour.Popup`);
|
|
165
|
+
return step;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The box next to the highlighted element, shown on every step. Write the shared frame and buttons here once.
|
|
169
|
+
* `side` and `align` are where it prefers to sit; Joyride flips it when that side has no room, so it never leaves the screen.
|
|
170
|
+
*/
|
|
171
|
+
export function Popup({ disableStyle, className, side = 'bottom', align = 'center', ...props }) {
|
|
172
|
+
const step = useStep('Popup');
|
|
173
|
+
const root = useContext(RootContext);
|
|
174
|
+
// Handing the preferred placement to Root, which passes it to Joyride
|
|
175
|
+
useLayoutEffect(() => {
|
|
176
|
+
root?.setPlacement({ side, align });
|
|
177
|
+
}, [root?.setPlacement, side, align]);
|
|
178
|
+
return (_jsx("div", { ...props, ...step.joyride.tooltipProps, "data-component": "tour-popup", "data-step": step.value, "data-first": step.joyride.index === 0 ? '' : undefined, "data-last": step.joyride.isLastStep ? '' : undefined, "data-style-disabled": disableStyle ? '' : undefined, className: twMerge(!disableStyle &&
|
|
179
|
+
'relative flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-3 rounded-xl border border-neutral-200 bg-white p-4 text-neutral-950 shadow-lg', className) }));
|
|
180
|
+
}
|
|
181
|
+
/** Shows its children only while its step is showing, like Tabs.Content. Put anything specific to one step here. */
|
|
182
|
+
export function Content({ disableStyle, className, value, ...props }) {
|
|
183
|
+
const step = useStep('Content');
|
|
184
|
+
if (step.value !== value)
|
|
185
|
+
return null;
|
|
186
|
+
return (_jsx("div", { ...props, "data-component": "tour-content", "data-step": value, "data-style-disabled": disableStyle ? '' : undefined, className: twMerge(!disableStyle && 'flex flex-col gap-1', className) }));
|
|
187
|
+
}
|
|
188
|
+
export function Title({ disableStyle, className, ...props }) {
|
|
189
|
+
return (_jsx("h2", { ...props, "data-component": "tour-title", "data-style-disabled": disableStyle ? '' : undefined, className: twMerge(!disableStyle && 'text-sm font-semibold leading-5 text-neutral-950', className) }));
|
|
190
|
+
}
|
|
191
|
+
export function Description({ disableStyle, className, ...props }) {
|
|
192
|
+
return (_jsx("p", { ...props, "data-component": "tour-description", "data-style-disabled": disableStyle ? '' : undefined, className: twMerge(!disableStyle && 'text-sm leading-5 text-neutral-600', className) }));
|
|
193
|
+
}
|
|
194
|
+
/** Shows the position in the tour, like "2 of 5". Pass a function as children to word it differently, e.g. for another language. */
|
|
195
|
+
export function Progress({ disableStyle, className, children, ...props }) {
|
|
196
|
+
const step = useStep('Progress');
|
|
197
|
+
const progress = { step: step.joyride.index + 1, total: step.joyride.size };
|
|
198
|
+
return (_jsx("p", { ...props, "data-component": "tour-progress", "data-last": step.joyride.isLastStep ? '' : undefined, "data-style-disabled": disableStyle ? '' : undefined, className: twMerge(!disableStyle && 'text-xs tabular-nums text-neutral-500', className), children: children ? children(progress) : `${progress.step} of ${progress.total}` }));
|
|
199
|
+
}
|
|
200
|
+
// Shared by every tour button: Polaris Button's base look at its medium size.
|
|
201
|
+
const buttonBase = 'relative flex w-fit min-h-7 cursor-pointer items-center justify-center gap-1.5 rounded-full px-4 py-1 text-[0.8rem] leading-4 font-medium text-nowrap select-none outline-none focus-visible:outline-2 focus-visible:outline-blue-500 active:scale-97 transition-[background-color,box-shadow,transform] duration-400 ease-[cubic-bezier(0.2,0.8,0,1)] motion-reduce:transition-none';
|
|
202
|
+
// Polaris Button's primary variant, neutral tone
|
|
203
|
+
const primaryButton = 'bg-neutral-950 text-white shadow-md hover:bg-black hover:text-neutral-200 focus-visible:bg-black active:bg-black [background-image:radial-gradient(50%_50%_at_50%_0%,_#ffffff33_0%,_#ffffff00_100%),_radial-gradient(49.59%_37.11%_at_50.41%_101.56%,_#ffffff26_0%,_#ffffff00_66.46%)] inset-shadow-[0rem_0rem_.25rem_.0625rem_#101010,0rem_0rem_.25rem_.125rem_#ffffff1a,0rem_0rem_.75rem_-.375rem_#ffffffbf]';
|
|
204
|
+
// Polaris Button's secondary variant, neutral tone
|
|
205
|
+
const secondaryButton = 'bg-neutral-200 text-neutral-950 hover:bg-neutral-300 focus-visible:bg-neutral-300 active:bg-neutral-300';
|
|
206
|
+
// Polaris Button's tertiary variant, neutral tone
|
|
207
|
+
const tertiaryButton = 'bg-transparent text-neutral-950 hover:bg-black/8 focus-visible:bg-black/8 active:bg-black/13';
|
|
208
|
+
/** Spreads Joyride's behavior for one button, keeping the user's own onClick too. With asChild, the consumer's child receives that behavior instead of this part's styled button. */
|
|
209
|
+
function TourButton({ asChild, joyrideProps, part, defaultClassName, disableStyle, className, onClick, children, ...props }) {
|
|
210
|
+
const behaviorProps = {
|
|
211
|
+
...props,
|
|
212
|
+
...joyrideProps,
|
|
213
|
+
onClick: (event) => {
|
|
214
|
+
onClick?.(event);
|
|
215
|
+
joyrideProps.onClick(event);
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
// Giving the behavior to the consumer's child, which keeps its own appearance and onClick
|
|
219
|
+
if (asChild) {
|
|
220
|
+
const child = children;
|
|
221
|
+
return cloneElement(child, {
|
|
222
|
+
...behaviorProps,
|
|
223
|
+
className: twMerge(child.props.className, className),
|
|
224
|
+
onClick: (event) => {
|
|
225
|
+
child.props.onClick?.(event);
|
|
226
|
+
behaviorProps.onClick(event);
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
return (_jsx("button", { type: "button", ...behaviorProps, ...asChildStyleAttributes({ asChild, component: `tour-${part}`, disableStyle }), className: twMerge(!disableStyle && defaultClassName, className), children: children }));
|
|
231
|
+
}
|
|
232
|
+
/** Goes back one step, styled like a secondary Button. Not rendered on the first step, where there's nothing to go back to. Pass asChild to give this behavior to your own button instead. */
|
|
233
|
+
export function BackButton(props) {
|
|
234
|
+
const step = useStep('BackButton');
|
|
235
|
+
if (step.joyride.index === 0)
|
|
236
|
+
return null;
|
|
237
|
+
return (_jsx(TourButton, { ...props, joyrideProps: step.joyride.backProps, part: "backbutton", defaultClassName: `${buttonBase} ${secondaryButton}` }));
|
|
238
|
+
}
|
|
239
|
+
/** Goes to the next step, styled like a primary Button. Not rendered on the last step; DoneButton takes its place there. Pass asChild to give this behavior to your own button instead. */
|
|
240
|
+
export function NextButton(props) {
|
|
241
|
+
const step = useStep('NextButton');
|
|
242
|
+
if (step.joyride.isLastStep)
|
|
243
|
+
return null;
|
|
244
|
+
return (_jsx(TourButton, { ...props, joyrideProps: step.joyride.primaryProps, part: "nextbutton", defaultClassName: `${buttonBase} ${primaryButton}` }));
|
|
245
|
+
}
|
|
246
|
+
/** Finishes the tour, styled like a primary Button. Rendered only on the last step, in NextButton's place. Pass asChild to give this behavior to your own button instead. */
|
|
247
|
+
export function DoneButton(props) {
|
|
248
|
+
const step = useStep('DoneButton');
|
|
249
|
+
if (!step.joyride.isLastStep)
|
|
250
|
+
return null;
|
|
251
|
+
return (_jsx(TourButton, { ...props, joyrideProps: step.joyride.primaryProps, part: "donebutton", defaultClassName: `${buttonBase} ${primaryButton}` }));
|
|
252
|
+
}
|
|
253
|
+
/** Ends the tour early, styled like a tertiary Button. Not rendered on the last step, where Done already ends it. Pass asChild to give this behavior to your own button instead. */
|
|
254
|
+
export function SkipButton(props) {
|
|
255
|
+
const step = useStep('SkipButton');
|
|
256
|
+
if (step.joyride.isLastStep)
|
|
257
|
+
return null;
|
|
258
|
+
return (_jsx(TourButton, { ...props, joyrideProps: step.joyride.skipProps, part: "skipbutton", defaultClassName: `${buttonBase} ${tertiaryButton}` }));
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Ends the tour from any step: the round ✕ in the popup's top-right corner, like Dialog's.
|
|
262
|
+
* Icon-only: put just a CloseButtonIcon inside, never text like "Close". It is already named for screen readers by Joyride.
|
|
263
|
+
* Pass asChild to give this behavior to your own button instead.
|
|
264
|
+
*/
|
|
265
|
+
export function CloseButton(props) {
|
|
266
|
+
const step = useStep('CloseButton');
|
|
267
|
+
return (_jsx(TourButton, { ...props, joyrideProps: step.joyride.closeProps, part: "closebutton", defaultClassName: "absolute top-4 right-4 flex h-7 aspect-square w-7 shrink-0 cursor-pointer items-center justify-center rounded-full border border-neutral-200 bg-white p-0 text-neutral-950 shadow-sm hover:bg-neutral-100 hover:text-neutral-950 active:bg-neutral-200 active:text-neutral-950 focus-visible:outline-2 focus-visible:outline-blue-500" }));
|
|
268
|
+
}
|
|
269
|
+
/** A default ✕ icon is supplied. Omit children for the usual case; pass an icon only to replace that visual. */
|
|
270
|
+
export function CloseButtonIcon({ disableStyle, children, className, ...props }) {
|
|
271
|
+
return cloneElement(children ?? _jsx(X, {}), {
|
|
272
|
+
...props,
|
|
273
|
+
'aria-hidden': true,
|
|
274
|
+
...{
|
|
275
|
+
'data-component': 'tour-closebuttonicon',
|
|
276
|
+
'data-style-disabled': disableStyle ? '' : undefined,
|
|
277
|
+
},
|
|
278
|
+
className: twMerge(!disableStyle && 'h-4 w-fit shrink-0 text-inherit', children?.props.className, className),
|
|
279
|
+
});
|
|
280
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -40,11 +40,14 @@ export * as Spinner from './components/spinner/index.tsx';
|
|
|
40
40
|
export * as Table from './components/table/index.tsx';
|
|
41
41
|
export * as Chip from './components/chip/index.tsx';
|
|
42
42
|
export * as TextLink from './components/textlink/index.tsx';
|
|
43
|
-
export
|
|
43
|
+
export * as Tour from './components/tour/index.tsx';
|
|
44
|
+
export * as BarChart from './components/barchart/index.tsx';
|
|
45
|
+
export * as HorizontalBarChart from './components/horizontalbarchart/index.tsx';
|
|
46
|
+
export * as LineChart from './components/linechart/index.tsx';
|
|
47
|
+
export * as DonutChart from './components/donutchart/index.tsx';
|
|
44
48
|
export { useVirtualizedCombobox, FilteredItemsSync as ComboboxFilteredItemsSync, } from './utils/virtualization/useVirtualizedCombobox.ts';
|
|
45
49
|
export type { UseVirtualizedComboboxOptions } from './utils/virtualization/useVirtualizedCombobox.ts';
|
|
46
50
|
export { useVirtualizedAutocomplete, FilteredItemsSync as AutocompleteFilteredItemsSync, } from './utils/virtualization/useVirtualizedAutocomplete.ts';
|
|
47
51
|
export type { UseVirtualizedAutocompleteOptions } from './utils/virtualization/useVirtualizedAutocomplete.ts';
|
|
48
52
|
export { useVirtualizedTable } from './utils/virtualization/useVirtualizedTable.ts';
|
|
49
53
|
export type { UseVirtualizedTableOptions } from './utils/virtualization/useVirtualizedTable.ts';
|
|
50
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,11 @@ export * as Spinner from "./components/spinner/index.js";
|
|
|
40
40
|
export * as Table from "./components/table/index.js";
|
|
41
41
|
export * as Chip from "./components/chip/index.js";
|
|
42
42
|
export * as TextLink from "./components/textlink/index.js";
|
|
43
|
+
export * as Tour from "./components/tour/index.js";
|
|
44
|
+
export * as BarChart from "./components/barchart/index.js";
|
|
45
|
+
export * as HorizontalBarChart from "./components/horizontalbarchart/index.js";
|
|
46
|
+
export * as LineChart from "./components/linechart/index.js";
|
|
47
|
+
export * as DonutChart from "./components/donutchart/index.js";
|
|
43
48
|
export { useVirtualizedCombobox, FilteredItemsSync as ComboboxFilteredItemsSync, } from "./utils/virtualization/useVirtualizedCombobox.js";
|
|
44
49
|
export { useVirtualizedAutocomplete, FilteredItemsSync as AutocompleteFilteredItemsSync, } from "./utils/virtualization/useVirtualizedAutocomplete.js";
|
|
45
50
|
export { useVirtualizedTable } from "./utils/virtualization/useVirtualizedTable.js";
|
|
46
|
-
//# sourceMappingURL=index.js.map
|
package/dist/types/Icon.d.ts
CHANGED
package/dist/types/Icon.js
CHANGED
package/dist/types/Style.d.ts
CHANGED
package/dist/types/Style.js
CHANGED
package/dist/types/Tone.d.ts
CHANGED
package/dist/types/Tone.js
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The field's validation state, with an optional message: `'error'` styles it as invalid, `['error', 'Email is required']` also shows that message in Error. Same for `'success'` and Success.
|
|
3
|
+
* Error and success never coexist, since a field holds one validation state at a time.
|
|
4
|
+
*/
|
|
5
|
+
export type Validation = 'error' | 'success' | readonly ['error' | 'success', string];
|
|
6
|
+
export type ValidationProps = {
|
|
7
|
+
/**
|
|
8
|
+
* The field's validation state, with an optional message: `'error'` styles it as invalid, `['error', 'Email is required']` also shows that message in Error. Same for `'success'` and Success.
|
|
9
|
+
* Omit it for a neutral field.
|
|
10
|
+
*/
|
|
11
|
+
validation?: Validation;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils/Tone.d.ts
CHANGED
package/dist/utils/Tone.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Validation } from '../types/Validation.ts';
|
|
3
|
+
export declare function readValidation(validation?: Validation): {
|
|
4
|
+
state: "success" | "error" | undefined;
|
|
5
|
+
message: string | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare function validationAttributes(validation: ReturnType<typeof readValidation>): {
|
|
8
|
+
'data-validation': "success" | "error" | undefined;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Message children of Error and Success: omit them to show Root's validation message, pass a function to format that message, or pass content to replace it.
|
|
12
|
+
*/
|
|
13
|
+
export type ValidationMessageChildren = ReactNode | ((message: string) => ReactNode);
|
|
14
|
+
export declare function validationMessageContent(validation: ReturnType<typeof readValidation>, state: 'error' | 'success', children?: ValidationMessageChildren): ReactNode;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Choosing the state and message from the validation prop's two shapes, so parts read one normalized object
|
|
2
|
+
export function readValidation(validation) {
|
|
3
|
+
if (typeof validation === 'string')
|
|
4
|
+
return { state: validation, message: undefined };
|
|
5
|
+
return { state: validation?.[0], message: validation?.[1] };
|
|
6
|
+
}
|
|
7
|
+
// The state attribute carried by every part, so presets can style any part from Root's validation, like [data-validation='error']
|
|
8
|
+
export function validationAttributes(validation) {
|
|
9
|
+
return { 'data-validation': validation.state };
|
|
10
|
+
}
|
|
11
|
+
// Choosing what an Error or Success part shows, or undefined when it should stay hidden
|
|
12
|
+
export function validationMessageContent(validation, state, children) {
|
|
13
|
+
if (validation.state !== state)
|
|
14
|
+
return undefined;
|
|
15
|
+
// Static children show with the state alone, while the message and its formatting function need a message
|
|
16
|
+
if (children !== undefined && typeof children !== 'function')
|
|
17
|
+
return children;
|
|
18
|
+
if (!validation.message)
|
|
19
|
+
return undefined;
|
|
20
|
+
if (typeof children === 'function')
|
|
21
|
+
return children(validation.message);
|
|
22
|
+
return validation.message;
|
|
23
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
/** The asChild prop shared by the library's action parts. */
|
|
3
|
+
export type AsChildProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Gives this part's behavior to your own single child element, like your app's Button, instead of rendering its own button.
|
|
6
|
+
* The child keeps the state data attributes (like data-open or data-disabled) and accessibility props, but none of this part's styling.
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
asChild?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/** Decides the style attributes of an action part: none when asChild, since the consumer's child owns its appearance. */
|
|
12
|
+
export declare function asChildStyleAttributes(props: {
|
|
13
|
+
asChild?: boolean;
|
|
14
|
+
component: string;
|
|
15
|
+
disableStyle?: boolean;
|
|
16
|
+
}): {
|
|
17
|
+
'data-component'?: undefined;
|
|
18
|
+
'data-style-disabled'?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
'data-component': string;
|
|
21
|
+
'data-style-disabled': string | undefined;
|
|
22
|
+
};
|
|
23
|
+
/** Decides what a Base UI action part renders: the consumer's child as the element when asChild, otherwise the part's own styled element. */
|
|
24
|
+
export declare function asChildRendering(props: {
|
|
25
|
+
asChild?: boolean;
|
|
26
|
+
children?: ReactNode;
|
|
27
|
+
component: string;
|
|
28
|
+
disableStyle?: boolean;
|
|
29
|
+
}): {
|
|
30
|
+
render: ReactElement;
|
|
31
|
+
} | {
|
|
32
|
+
'data-component'?: undefined;
|
|
33
|
+
'data-style-disabled'?: undefined;
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
render?: undefined;
|
|
36
|
+
} | {
|
|
37
|
+
'data-component': string;
|
|
38
|
+
'data-style-disabled': string | undefined;
|
|
39
|
+
children: ReactNode;
|
|
40
|
+
render?: undefined;
|
|
41
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Decides the style attributes of an action part: none when asChild, since the consumer's child owns its appearance. */
|
|
2
|
+
export function asChildStyleAttributes(props) {
|
|
3
|
+
if (props.asChild)
|
|
4
|
+
return {};
|
|
5
|
+
return {
|
|
6
|
+
'data-component': props.component,
|
|
7
|
+
'data-style-disabled': props.disableStyle ? '' : undefined,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/** Decides what a Base UI action part renders: the consumer's child as the element when asChild, otherwise the part's own styled element. */
|
|
11
|
+
export function asChildRendering(props) {
|
|
12
|
+
if (props.asChild)
|
|
13
|
+
return { render: props.children };
|
|
14
|
+
return { children: props.children, ...asChildStyleAttributes(props) };
|
|
15
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SVGIconProps } from '../types/Icon.ts';
|
|
2
|
+
export declare const ArrowLeft: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
3
|
+
export declare const CalendarDays: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
4
|
+
export declare const Check: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
5
|
+
export declare const ChevronDown: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
6
|
+
export declare const ChevronLeft: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
7
|
+
export declare const ChevronRight: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
8
|
+
export declare const ChevronUp: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
9
|
+
export declare const ChevronsUpDown: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
10
|
+
export declare const CircleAlert: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
11
|
+
export declare const CircleCheck: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
12
|
+
export declare const Eye: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
13
|
+
export declare const EyeOff: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
14
|
+
export declare const File: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
15
|
+
export declare const FolderOpen: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
16
|
+
export declare const GripVertical: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
17
|
+
export declare const Info: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
18
|
+
export declare const LoaderCircle: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
19
|
+
export declare const Minus: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
20
|
+
export declare const Star: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
21
|
+
export declare const Text: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
22
|
+
export declare const TriangleAlert: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
23
|
+
export declare const Upload: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
24
|
+
export declare const X: import("react").ForwardRefExoticComponent<Omit<SVGIconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|