@economic/taco 1.23.1 → 1.25.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Button/Button.d.ts +13 -0
- package/dist/components/Dialog/Dialog.d.ts +1 -1
- package/dist/components/Dialog/components/DialogDrawer.d.ts +10 -0
- package/dist/components/Drawer/Context.d.ts +18 -0
- package/dist/components/Drawer/Drawer.d.ts +51 -0
- package/dist/components/Drawer/components/Content.d.ts +53 -0
- package/dist/components/Drawer/components/Trigger.d.ts +3 -0
- package/dist/components/Drawer/images.d.ts +1 -0
- package/dist/components/Drawer/types.d.ts +2 -0
- package/dist/components/Drawer/util.d.ts +7 -0
- package/dist/components/Header/Header.d.ts +28 -0
- package/dist/components/Header/components/AgreementSelector.d.ts +18 -0
- package/dist/components/Header/components/Agreements/AgreementDetails.d.ts +20 -0
- package/dist/components/Header/components/Button.d.ts +11 -0
- package/dist/components/Header/components/Link.d.ts +21 -0
- package/dist/components/Header/components/Logo.d.ts +3 -0
- package/dist/components/Header/components/MenuButton.d.ts +5 -0
- package/dist/components/Header/components/PrimaryNavigation.d.ts +3 -0
- package/dist/components/Header/components/SecondaryNavigation.d.ts +3 -0
- package/dist/components/Layout/Layout.d.ts +16 -0
- package/dist/components/Layout/components/Content.d.ts +3 -0
- package/dist/components/Layout/components/Context.d.ts +6 -0
- package/dist/components/Layout/components/Page.d.ts +3 -0
- package/dist/components/Layout/components/Sidebar.d.ts +3 -0
- package/dist/components/Layout/components/Top.d.ts +7 -0
- package/dist/components/Navigation2/Navigation2.d.ts +17 -0
- package/dist/components/Navigation2/components/Content.d.ts +3 -0
- package/dist/components/Navigation2/components/Group.d.ts +9 -0
- package/dist/components/Navigation2/components/Link.d.ts +24 -0
- package/dist/components/Navigation2/components/Section.d.ts +7 -0
- package/dist/components/Navigation2/components/util.d.ts +1 -0
- package/dist/components/Provider/Localization.d.ts +32 -16
- package/dist/esm/packages/taco/src/components/Button/Button.js +2 -0
- package/dist/esm/packages/taco/src/components/Button/Button.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Button/util.js +5 -0
- package/dist/esm/packages/taco/src/components/Button/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Card/Card.js +1 -1
- package/dist/esm/packages/taco/src/components/Card/Card.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Dialog/Dialog.js +3 -3
- package/dist/esm/packages/taco/src/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Dialog/components/{Drawer.js → DialogDrawer.js} +4 -4
- package/dist/esm/packages/taco/src/components/Dialog/components/DialogDrawer.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Drawer/Context.js +19 -0
- package/dist/esm/packages/taco/src/components/Drawer/Context.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Drawer/Drawer.js +102 -0
- package/dist/esm/packages/taco/src/components/Drawer/Drawer.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Drawer/components/Content.js +292 -0
- package/dist/esm/packages/taco/src/components/Drawer/components/Content.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Drawer/components/Trigger.js +12 -0
- package/dist/esm/packages/taco/src/components/Drawer/components/Trigger.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Drawer/util.js +37 -0
- package/dist/esm/packages/taco/src/components/Drawer/util.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/Header.js +30 -0
- package/dist/esm/packages/taco/src/components/Header/Header.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js +136 -0
- package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/components/Agreements/AgreementDetails.js +73 -0
- package/dist/esm/packages/taco/src/components/Header/components/Agreements/AgreementDetails.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/components/Button.js +24 -0
- package/dist/esm/packages/taco/src/components/Header/components/Button.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/components/Link.js +49 -0
- package/dist/esm/packages/taco/src/components/Header/components/Link.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/components/Logo.js +73 -0
- package/dist/esm/packages/taco/src/components/Header/components/Logo.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/components/MenuButton.js +17 -0
- package/dist/esm/packages/taco/src/components/Header/components/MenuButton.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js +134 -0
- package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/components/SecondaryNavigation.js +13 -0
- package/dist/esm/packages/taco/src/components/Header/components/SecondaryNavigation.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Layout/Layout.js +28 -0
- package/dist/esm/packages/taco/src/components/Layout/Layout.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Content.js +13 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Content.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Context.js +9 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Context.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Page.js +13 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Page.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js +83 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Top.js +15 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Top.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Menu/Menu.js +2 -2
- package/dist/esm/packages/taco/src/components/Menu/components/Content.js +1 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Header.js +1 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Item.js +1 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Link.js +1 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Trigger.js +1 -1
- package/dist/esm/packages/taco/src/components/Navigation2/Navigation2.js +31 -0
- package/dist/esm/packages/taco/src/components/Navigation2/Navigation2.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/Content.js +20 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/Content.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/Group.js +46 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/Group.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/Link.js +72 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/Link.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/Section.js +25 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/Section.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/util.js +12 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/util.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Provider/Localization.js +20 -10
- package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
- package/dist/esm/packages/taco/src/components/SearchInput/SearchInput.js +4 -1
- package/dist/esm/packages/taco/src/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +1 -1
- package/dist/esm/packages/taco/src/components/Table/util/renderRow.js +1 -1
- package/dist/esm/packages/taco/src/components/Table2/components/EditModeButton.js +1 -1
- package/dist/esm/packages/taco/src/components/Table2/components/Search.js +1 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/FiltersButton.js +1 -1
- package/dist/esm/packages/taco/src/hooks/useBoundaryOverflowDetection.js +3 -1
- package/dist/esm/packages/taco/src/hooks/useBoundaryOverflowDetection.js.map +1 -1
- package/dist/esm/packages/taco/src/hooks/useIsLargeScreen.js +6 -0
- package/dist/esm/packages/taco/src/hooks/useIsLargeScreen.js.map +1 -0
- package/dist/esm/packages/taco/src/hooks/useMatchMedia.js +18 -0
- package/dist/esm/packages/taco/src/hooks/useMatchMedia.js.map +1 -0
- package/dist/esm/packages/taco/src/index.js +11 -1
- package/dist/esm/packages/taco/src/index.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Collection/Collection.js +3 -0
- package/dist/esm/packages/taco/src/primitives/Collection/Collection.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js +4 -1
- package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Listbox2/components/Root.js +1 -0
- package/dist/esm/packages/taco/src/primitives/Listbox2/components/Root.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/hooks/useDraggable.js +8 -1
- package/dist/esm/packages/taco/src/utils/hooks/useDraggable.js.map +1 -1
- package/dist/hooks/useIsLargeScreen.d.ts +1 -0
- package/dist/hooks/useMatchMedia.d.ts +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/taco.cjs.development.js +1981 -737
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +3 -2
- package/tailwind.config.js +1 -0
- package/types.json +936 -182
- package/dist/components/Accordion/Accordion.stories.d.ts +0 -26
- package/dist/components/Alert/Alert.stories.d.ts +0 -36
- package/dist/components/AlertDialog/AlertDialog.stories.d.ts +0 -10
- package/dist/components/Backdrop/Backdrop.stories.d.ts +0 -7
- package/dist/components/BadgeIcon/BadgeIcon.stories.d.ts +0 -12
- package/dist/components/Banner/Banner.stories.d.ts +0 -5
- package/dist/components/Button/Button.stories.d.ts +0 -77
- package/dist/components/Calendar/Calendar.stories.d.ts +0 -13
- package/dist/components/Card/Card.stories.d.ts +0 -12
- package/dist/components/Datepicker/Datepicker.stories.d.ts +0 -43
- package/dist/components/Dialog/Dialog.stories.d.ts +0 -57
- package/dist/components/Dialog/components/Drawer.d.ts +0 -10
- package/dist/components/Field/Field.stories.d.ts +0 -14
- package/dist/components/Form/Form.stories.d.ts +0 -14
- package/dist/components/Group/Group.stories.d.ts +0 -23
- package/dist/components/Hanger/Hanger.stories.d.ts +0 -11
- package/dist/components/HoverCard/HoverCard.stories.d.ts +0 -16
- package/dist/components/Icon/Icon.stories.d.ts +0 -8
- package/dist/components/IconButton/IconButton.stories.d.ts +0 -12
- package/dist/components/Input/Input.stories.d.ts +0 -17
- package/dist/components/Listbox/Listbox.stories.d.ts +0 -44
- package/dist/components/Menu/Menu.stories.d.ts +0 -73
- package/dist/components/Navigation/Navigation.stories.d.ts +0 -7
- package/dist/components/Pagination/Pagination.stories.d.ts +0 -28
- package/dist/components/Popover/Popover.stories.d.ts +0 -29
- package/dist/components/Progress/Progress.stories.d.ts +0 -9
- package/dist/components/RadioGroup/RadioGroup.stories.d.ts +0 -49
- package/dist/components/ScrollArea/ScrollArea.stories.d.ts +0 -8
- package/dist/components/SearchInput/SearchInput.stories.d.ts +0 -38
- package/dist/components/Select/Select.stories.d.ts +0 -35
- package/dist/components/Select2/Select2.stories.d.ts +0 -57
- package/dist/components/Spinner/Spinner.stories.d.ts +0 -15
- package/dist/components/Table/Table.stories.d.ts +0 -32
- package/dist/components/Table2/Table2.stories.d.ts +0 -48
- package/dist/components/Tabs/Tabs.stories.d.ts +0 -19
- package/dist/components/Tag/Tag.stories.d.ts +0 -9
- package/dist/components/Textarea/Textarea.stories.d.ts +0 -40
- package/dist/components/Toast/Toast.stories.d.ts +0 -12
- package/dist/components/Tooltip/Tooltip.stories.d.ts +0 -26
- package/dist/components/Tour/Tour.stories.d.ts +0 -11
- package/dist/css/Typography.stories.d.ts +0 -6
- package/dist/esm/packages/taco/src/components/Dialog/components/Drawer.js.map +0 -1
- package/dist/hooks/useIsRefOverflowing.d.ts +0 -2
- package/dist/primitives/Collection/Collection.stories.d.ts +0 -8
- package/dist/primitives/Listbox2/Listbox2.stories.d.ts +0 -16
- package/dist/primitives/Sortable/Sortable.stories.d.ts +0 -14
@@ -7,6 +7,7 @@ import { PaginationTexts } from '../Pagination/Pagination';
|
|
7
7
|
import { ListboxTexts } from '../Listbox/Listbox';
|
8
8
|
import { ToastsTexts } from '../Toast/Toast';
|
9
9
|
import { DatepickerTexts } from '../Datepicker/Datepicker';
|
10
|
+
import { HeaderTexts } from '../Header/Header';
|
10
11
|
import { HangerTexts } from '../Hanger/Hanger';
|
11
12
|
import { SelectTexts } from '../Select/Select';
|
12
13
|
import { TourTexts } from '../Tour/Tour';
|
@@ -15,27 +16,32 @@ import { Table2Texts } from '../Table2/Table2';
|
|
15
16
|
import { SearchInputTexts } from '../SearchInput/SearchInput';
|
16
17
|
import { Select2Texts } from '../Select2/Select2';
|
17
18
|
import { BannerTexts } from '../Banner/Banner';
|
19
|
+
import { DrawerTexts } from '../Drawer/Drawer';
|
18
20
|
export declare type LocalizationTexts = {
|
21
|
+
/** Localized texts and aria-labels for [Banner](component:banner) component */
|
22
|
+
banner: BannerTexts;
|
19
23
|
/** Localized texts and aria-labels for [Calendar](component:calendar) component */
|
20
24
|
calendar: CalendarTexts;
|
21
25
|
/** Localized texts and aria-labels for [Combobox](component:combobox) component */
|
22
26
|
combobox: ComboboxTexts;
|
23
27
|
/** Localized texts and aria-labels for [DatePicker](component:datepicker) component */
|
24
28
|
datepicker: DatepickerTexts;
|
29
|
+
/** Localized texts and aria-labels for [Dialog](component:dialog) component */
|
30
|
+
dialog: DialogTexts;
|
25
31
|
/** Localized texts and aria-labels for [Hanger](component:hanger) component */
|
26
32
|
hanger: HangerTexts;
|
27
|
-
/** Localized texts and aria-labels for [
|
28
|
-
|
33
|
+
/** Localized texts and aria-labels for [Header](component:header) component */
|
34
|
+
header: HeaderTexts;
|
29
35
|
/** Localized texts and aria-labels for [Listbox](component:listbox) component */
|
30
36
|
listbox: ListboxTexts;
|
31
|
-
/** Localized texts and aria-labels for [Dialog](component:dialog) component */
|
32
|
-
dialog: DialogTexts;
|
33
37
|
/** Localized texts and aria-labels for [Pagination](component:pagination) component */
|
34
38
|
pagination: PaginationTexts;
|
35
39
|
/** Localized texts and aria-labels for [Table](component:table) component */
|
36
40
|
table: TableTexts;
|
37
41
|
/** Localized texts and aria-labels for [Table2](component:table2) component */
|
38
42
|
table2: Table2Texts;
|
43
|
+
/** Localized texts and aria-labels for [SearchInput](component:searchinput) component */
|
44
|
+
searchInput: SearchInputTexts;
|
39
45
|
/** Localized texts and aria-labels for [Select](component:select) component */
|
40
46
|
select: SelectTexts;
|
41
47
|
/** Localized texts and aria-labels for [Select2](component:select2) component */
|
@@ -44,8 +50,8 @@ export declare type LocalizationTexts = {
|
|
44
50
|
toasts: ToastsTexts;
|
45
51
|
/** Localized texts and aria-labels for [Tour](component:tour) component */
|
46
52
|
tour: TourTexts;
|
47
|
-
/** Localized texts and aria-labels for [
|
48
|
-
|
53
|
+
/** Localized texts and aria-labels for [Drawer](component:drawer) component */
|
54
|
+
drawer: DrawerTexts;
|
49
55
|
};
|
50
56
|
export declare type Localization = {
|
51
57
|
/**
|
@@ -62,6 +68,9 @@ export declare type Localization = {
|
|
62
68
|
};
|
63
69
|
};
|
64
70
|
export declare const defaultLocalisationTexts: {
|
71
|
+
banner: {
|
72
|
+
close: string;
|
73
|
+
};
|
65
74
|
calendar: {
|
66
75
|
months: string[];
|
67
76
|
weekdaysShort: string[];
|
@@ -82,21 +91,25 @@ export declare const defaultLocalisationTexts: {
|
|
82
91
|
expand: string;
|
83
92
|
shortcuts: string;
|
84
93
|
};
|
85
|
-
|
94
|
+
dialog: {
|
86
95
|
close: string;
|
96
|
+
drag: string;
|
87
97
|
};
|
88
|
-
|
98
|
+
hanger: {
|
89
99
|
close: string;
|
90
100
|
};
|
101
|
+
header: {
|
102
|
+
addAgreement: string;
|
103
|
+
logout: string;
|
104
|
+
more: string;
|
105
|
+
new: string;
|
106
|
+
search: string;
|
107
|
+
};
|
91
108
|
listbox: {
|
92
109
|
loading: string;
|
93
110
|
empty: string;
|
94
111
|
allOption: string;
|
95
112
|
};
|
96
|
-
dialog: {
|
97
|
-
close: string;
|
98
|
-
drag: string;
|
99
|
-
};
|
100
113
|
pagination: {
|
101
114
|
label: string;
|
102
115
|
pageSize: string;
|
@@ -207,6 +220,11 @@ export declare const defaultLocalisationTexts: {
|
|
207
220
|
collapseRow: string;
|
208
221
|
};
|
209
222
|
};
|
223
|
+
searchInput: {
|
224
|
+
button: string;
|
225
|
+
placeholder: string;
|
226
|
+
clear: string;
|
227
|
+
};
|
210
228
|
select: {
|
211
229
|
allOptionsSelected: string;
|
212
230
|
};
|
@@ -232,10 +250,8 @@ export declare const defaultLocalisationTexts: {
|
|
232
250
|
next: string;
|
233
251
|
open: string;
|
234
252
|
};
|
235
|
-
|
236
|
-
|
237
|
-
placeholder: string;
|
238
|
-
clear: string;
|
253
|
+
drawer: {
|
254
|
+
close: string;
|
239
255
|
};
|
240
256
|
};
|
241
257
|
export declare const LocalizationContext: React.Context<Localization>;
|
@@ -21,6 +21,7 @@ const Base = /*#__PURE__*/forwardRef(function ButtonBase(props, ref) {
|
|
21
21
|
const Button = /*#__PURE__*/forwardRef(function Button(props, ref) {
|
22
22
|
const {
|
23
23
|
dialog,
|
24
|
+
drawer,
|
24
25
|
hanger,
|
25
26
|
menu,
|
26
27
|
popover,
|
@@ -42,6 +43,7 @@ const Button = /*#__PURE__*/forwardRef(function Button(props, ref) {
|
|
42
43
|
}), children);
|
43
44
|
return createButtonWithOverlays({
|
44
45
|
dialog,
|
46
|
+
drawer,
|
45
47
|
hanger,
|
46
48
|
menu,
|
47
49
|
popover
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../../../../../src/components/Button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { Appearance } from '../../types';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { getAppearanceClasses, getButtonClasses, createButtonWithTooltip, createButtonWithOverlays } from './util';\nimport { HangerProps } from '../Hanger/Hanger';\nimport { MenuProps } from '../Menu/Menu';\nimport { DialogProps } from '../Dialog/Dialog';\nimport { PopoverProps } from '../Popover/Popover';\nimport './Button.css';\nimport { Icon } from '../Icon/Icon';\n\nexport type ButtonProps = ButtonPrimitive.ButtonProps & {\n /** Appearance will change the style of the button */\n appearance?: Appearance;\n /**\n * Dialog component associated with the button, clicking the button will open the dialog.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated dialog when clicked.\n */\n dialog?: (props: Partial<DialogProps>) => JSX.Element;\n /** If fluid, button expands to the width of it's container */\n fluid?: boolean;\n /** Hanger component associated with the button. */\n hanger?: (props: Partial<HangerProps>) => JSX.Element;\n /** Menu component associated with the button. */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n /**\n * Popover component associated with the button, clicking the button will open the popover.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated popover when clicked.\n */\n popover?: (props: Partial<PopoverProps>) => JSX.Element;\n /** A tooltip to show when hovering over the button */\n tooltip?: string | JSX.Element;\n};\n\nconst Base = React.forwardRef(function ButtonBase(props: ButtonProps, ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>) {\n const { fluid, ...otherProps } = props;\n const className = cn(\n getButtonClasses(),\n getAppearanceClasses(otherProps.appearance),\n 'rounded px-3',\n {\n 'cursor-not-allowed opacity-50': props.disabled,\n 'focus:yt-focus active:focus:yt-focus': !props.disabled,\n 'w-full': fluid,\n },\n props.className\n );\n\n return createButtonWithTooltip({ ...otherProps, 'data-taco': 'button' }, className, ref);\n});\n\nexport const Button = React.forwardRef(function Button(\n props: ButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n) {\n const { dialog, hanger, menu, popover, ...buttonProps } = props;\n\n let children = buttonProps.children;\n\n // add a chevron icon to menu buttons\n if (typeof menu === 'function') {\n children = Array.isArray(children)\n ? [...children, <Icon key=\"chevron-down\" name=\"chevron-down\" />]\n : [children, <Icon key=\"chevron-down\" name=\"chevron-down\" />];\n }\n\n const button = (\n <Base {...buttonProps} ref={ref}>\n {children}\n </Base>\n );\n\n return createButtonWithOverlays({ dialog, hanger, menu, popover }, button);\n});\n"],"names":["Base","React","ButtonBase","props","ref","fluid","otherProps","className","cn","getButtonClasses","getAppearanceClasses","appearance","disabled","createButtonWithTooltip","Button","dialog","hanger","menu","popover","buttonProps","children","Array","isArray","Icon","key","name","button","createButtonWithOverlays"],"mappings":";;;;;
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../../../../../src/components/Button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { Appearance } from '../../types';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { getAppearanceClasses, getButtonClasses, createButtonWithTooltip, createButtonWithOverlays } from './util';\nimport { HangerProps } from '../Hanger/Hanger';\nimport { MenuProps } from '../Menu/Menu';\nimport { DialogProps } from '../Dialog/Dialog';\nimport { PopoverProps } from '../Popover/Popover';\nimport './Button.css';\nimport { Icon } from '../Icon/Icon';\nimport { DrawerProps } from '../Drawer/Drawer';\n\nexport type ButtonProps = ButtonPrimitive.ButtonProps & {\n /** Appearance will change the style of the button */\n appearance?: Appearance;\n /**\n * Dialog component associated with the button, clicking the button will open the dialog.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated dialog when clicked.\n */\n dialog?: (props: Partial<DialogProps>) => JSX.Element;\n /**\n * Drawer component associated with the button, clicking the button will open the drawer.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated drawer when clicked.\n */\n drawer?: (props: Partial<DrawerProps>) => JSX.Element;\n /** If fluid, button expands to the width of it's container */\n fluid?: boolean;\n /** Hanger component associated with the button. */\n hanger?: (props: Partial<HangerProps>) => JSX.Element;\n /** Menu component associated with the button. */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n /**\n * Popover component associated with the button, clicking the button will open the popover.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated popover when clicked.\n */\n popover?: (props: Partial<PopoverProps>) => JSX.Element;\n /** A tooltip to show when hovering over the button */\n tooltip?: string | JSX.Element;\n};\n\nconst Base = React.forwardRef(function ButtonBase(props: ButtonProps, ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>) {\n const { fluid, ...otherProps } = props;\n const className = cn(\n getButtonClasses(),\n getAppearanceClasses(otherProps.appearance),\n 'rounded px-3',\n {\n 'cursor-not-allowed opacity-50': props.disabled,\n 'focus:yt-focus active:focus:yt-focus': !props.disabled,\n 'w-full': fluid,\n },\n props.className\n );\n\n return createButtonWithTooltip({ ...otherProps, 'data-taco': 'button' }, className, ref);\n});\n\nexport const Button = React.forwardRef(function Button(\n props: ButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n) {\n const { dialog, drawer, hanger, menu, popover, ...buttonProps } = props;\n\n let children = buttonProps.children;\n\n // add a chevron icon to menu buttons\n if (typeof menu === 'function') {\n children = Array.isArray(children)\n ? [...children, <Icon key=\"chevron-down\" name=\"chevron-down\" />]\n : [children, <Icon key=\"chevron-down\" name=\"chevron-down\" />];\n }\n\n const button = (\n <Base {...buttonProps} ref={ref}>\n {children}\n </Base>\n );\n\n return createButtonWithOverlays({ dialog, drawer, hanger, menu, popover }, button);\n});\n"],"names":["Base","React","ButtonBase","props","ref","fluid","otherProps","className","cn","getButtonClasses","getAppearanceClasses","appearance","disabled","createButtonWithTooltip","Button","dialog","drawer","hanger","menu","popover","buttonProps","children","Array","isArray","Icon","key","name","button","createButtonWithOverlays"],"mappings":";;;;;AA4CA,MAAMA,IAAI,gBAAGC,UAAgB,CAAC,SAASC,UAAU,CAACC,KAAkB,EAAEC,GAAqD;EACvH,MAAM;IAAEC,KAAK;IAAE,GAAGC;GAAY,GAAGH,KAAK;EACtC,MAAMI,SAAS,GAAGC,EAAE,CAChBC,gBAAgB,EAAE,EAClBC,oBAAoB,CAACJ,UAAU,CAACK,UAAU,CAAC,EAC3C,cAAc,EACd;IACI,+BAA+B,EAAER,KAAK,CAACS,QAAQ;IAC/C,sCAAsC,EAAE,CAACT,KAAK,CAACS,QAAQ;IACvD,QAAQ,EAAEP;GACb,EACDF,KAAK,CAACI,SAAS,CAClB;EAED,OAAOM,uBAAuB,CAAC;IAAE,GAAGP,UAAU;IAAE,WAAW,EAAE;GAAU,EAAEC,SAAS,EAAEH,GAAG,CAAC;AAC5F,CAAC,CAAC;MAEWU,MAAM,gBAAGb,UAAgB,CAAC,SAASa,MAAM,CAClDX,KAAkB,EAClBC,GAAqD;EAErD,MAAM;IAAEW,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAE,GAAGC;GAAa,GAAGjB,KAAK;EAEvE,IAAIkB,QAAQ,GAAGD,WAAW,CAACC,QAAQ;;EAGnC,IAAI,OAAOH,IAAI,KAAK,UAAU,EAAE;IAC5BG,QAAQ,GAAGC,KAAK,CAACC,OAAO,CAACF,QAAQ,CAAC,GAC5B,CAAC,GAAGA,QAAQ,eAAEpB,cAACuB,IAAI;MAACC,GAAG,EAAC,cAAc;MAACC,IAAI,EAAC;MAAiB,CAAC,GAC9D,CAACL,QAAQ,eAAEpB,cAACuB,IAAI;MAACC,GAAG,EAAC,cAAc;MAACC,IAAI,EAAC;MAAiB,CAAC;;EAGrE,MAAMC,MAAM,gBACR1B,cAACD,IAAI,oBAAKoB,WAAW;IAAEhB,GAAG,EAAEA;MACvBiB,QAAQ,CAEhB;EAED,OAAOO,wBAAwB,CAAC;IAAEb,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC,IAAI;IAAEC;GAAS,EAAEQ,MAAM,CAAC;AACtF,CAAC;;;;"}
|
@@ -43,6 +43,7 @@ const createButtonWithTooltip = (props, className, ref) => {
|
|
43
43
|
const createButtonWithOverlays = (props, buttonBase) => {
|
44
44
|
const {
|
45
45
|
dialog,
|
46
|
+
drawer,
|
46
47
|
hanger,
|
47
48
|
menu,
|
48
49
|
popover
|
@@ -52,6 +53,10 @@ const createButtonWithOverlays = (props, buttonBase) => {
|
|
52
53
|
button = dialog({
|
53
54
|
trigger: button
|
54
55
|
});
|
56
|
+
} else if (typeof drawer === 'function') {
|
57
|
+
button = drawer({
|
58
|
+
trigger: button
|
59
|
+
});
|
55
60
|
} else if (typeof menu === 'function') {
|
56
61
|
button = menu({
|
57
62
|
trigger: button
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"util.js","sources":["../../../../../../../src/components/Button/util.tsx"],"sourcesContent":["import React from 'react';\nimport { Appearance } from '../../types';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { Tooltip } from '../Tooltip/Tooltip';\n\nexport const getButtonClasses = () => {\n return 'flex-shrink-0 min-h-[theme(spacing.8)] min-w-[theme(spacing.8)] gap-1 h-max leading-5 inline-flex items-center justify-center';\n};\n\nexport const getAppearanceClasses = (value: Appearance | undefined, icon = false): string => {\n switch (value) {\n case 'primary':\n return `wcag-blue-500 focus:bg-blue-500 focus:text-white focus:yt-focus active:bg-blue-700 active:text-white hover:bg-blue-300 hover:text-white hover:focus:bg-blue-300 hover:focus:border-blue-300 hover:focus:text-white disabled:hover:wcag-blue-500 disabled:hover:hover:border-blue-500`;\n\n case 'danger':\n return `wcag-red-500 focus:bg-red-500 focus:text-white focus:yt-focus-red active:bg-red-700 active:text-white hover:bg-red-300 hover:text-white hover:focus:bg-red-300 hover:focus:text-white disabled:hover:wcag-red-500`;\n\n case 'ghost':\n return `bg-white shadow-[inset_0_0_0_1px_theme(colors.blue.500)] text-blue-500 focus:bg-transparent focus:text-blue-500 active:bg-blue-100 focus:!shadow-[inset_0_0_0_1px_theme(colors.blue.500),0_0_0_2px_rgba(0,99,255,0.25)] active:text-blue-700 hover:bg-blue-100 hover:shadow-[inset_0_0_0_1px_theme(colors.blue.300)] hover:text-blue-300 hover:focus:bg-blue-100 hover:focus:!shadow-[inset_0_0_0_1px_theme(colors.blue.300),0_0_0_2px_rgba(0,99,255,0.25)] hover:focus:text-blue-300`;\n\n case 'discrete': {\n if (icon) {\n return `bg-transparent text-black border-transparent focus:text-black focus:yt-focus active:text-black hover:text-grey-700 hover:focus:text-grey-700 disabled:hover:text-black `;\n }\n\n return `yt-transparent focus:text-blue-500 focus:yt-focus active:text-blue-700 hover:text-blue-300 hover:focus:text-blue-300 disabled:hover:yt-transparent`;\n }\n\n default:\n return `wcag-grey-200 focus:bg-grey-200 focus:yt-focus active:bg-grey-300 active:text-black hover:bg-grey-100 hover:text-grey-700 hover:focus:bg-grey-100 hover:focus:text-grey-700 disabled:hover:wcag-grey-200`;\n }\n};\n\nexport const createButtonWithTooltip = (\n props: any,\n className: string,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n): JSX.Element => {\n const { tooltip, ...buttonProps } = props;\n const button = <ButtonPrimitive.Button {...buttonProps} className={className} ref={ref} />;\n\n if (tooltip) {\n return <Tooltip title={tooltip}>{button}</Tooltip>;\n }\n\n return button;\n};\n\nexport const createButtonWithOverlays = (props: any, buttonBase: JSX.Element) => {\n const { dialog, hanger, menu, popover } = props;\n let button = buttonBase;\n\n if (typeof dialog === 'function') {\n button = dialog({ trigger: button });\n } else if (typeof menu === 'function') {\n button = menu({ trigger: button });\n } else if (typeof popover === 'function') {\n button = popover({ trigger: button });\n }\n\n if (typeof hanger === 'function') {\n button = hanger({ anchor: button });\n }\n\n return button;\n};\n"],"names":["getButtonClasses","getAppearanceClasses","value","icon","createButtonWithTooltip","props","className","ref","tooltip","buttonProps","button","React","ButtonPrimitive","Tooltip","title","createButtonWithOverlays","buttonBase","dialog","hanger","menu","popover","trigger","anchor"],"mappings":";;;;MAKaA,gBAAgB,GAAG;EAC5B,OAAO,+HAA+H;AAC1I;MAEaC,oBAAoB,GAAG,CAACC,KAA6B,EAAEC,IAAI,GAAG,KAAK;EAC5E,QAAQD,KAAK;IACT,KAAK,SAAS;MACV,6RAA6R;IAEjS,KAAK,QAAQ;MACT,0NAA0N;IAE9N,KAAK,OAAO;MACR,8dAA8d;IAEle,KAAK,UAAU;MAAE;QACb,IAAIC,IAAI,EAAE;UACN,gLAAgL;;QAGpL,2JAA2J;;IAG/J;MACI,iNAAiN;;AAE7N;MAEaC,uBAAuB,GAAG,CACnCC,KAAU,EACVC,SAAiB,EACjBC,GAAqD;EAErD,MAAM;IAAEC,OAAO;IAAE,GAAGC;GAAa,GAAGJ,KAAK;EACzC,MAAMK,MAAM,gBAAGC,6BAACC,MAAsB,oBAAKH,WAAW;IAAEH,SAAS,EAAEA,SAAS;IAAEC,GAAG,EAAEA;KAAO;EAE1F,IAAIC,OAAO,EAAE;IACT,oBAAOG,6BAACE,OAAO;MAACC,KAAK,EAAEN;OAAUE,MAAM,CAAW;;EAGtD,OAAOA,MAAM;AACjB;MAEaK,wBAAwB,GAAG,CAACV,KAAU,EAAEW,UAAuB;EACxE,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC,IAAI;IAAEC;GAAS,
|
1
|
+
{"version":3,"file":"util.js","sources":["../../../../../../../src/components/Button/util.tsx"],"sourcesContent":["import React from 'react';\nimport { Appearance } from '../../types';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { Tooltip } from '../Tooltip/Tooltip';\n\nexport const getButtonClasses = () => {\n return 'flex-shrink-0 min-h-[theme(spacing.8)] min-w-[theme(spacing.8)] gap-1 h-max leading-5 inline-flex items-center justify-center';\n};\n\nexport const getAppearanceClasses = (value: Appearance | undefined, icon = false): string => {\n switch (value) {\n case 'primary':\n return `wcag-blue-500 focus:bg-blue-500 focus:text-white focus:yt-focus active:bg-blue-700 active:text-white hover:bg-blue-300 hover:text-white hover:focus:bg-blue-300 hover:focus:border-blue-300 hover:focus:text-white disabled:hover:wcag-blue-500 disabled:hover:hover:border-blue-500`;\n\n case 'danger':\n return `wcag-red-500 focus:bg-red-500 focus:text-white focus:yt-focus-red active:bg-red-700 active:text-white hover:bg-red-300 hover:text-white hover:focus:bg-red-300 hover:focus:text-white disabled:hover:wcag-red-500`;\n\n case 'ghost':\n return `bg-white shadow-[inset_0_0_0_1px_theme(colors.blue.500)] text-blue-500 focus:bg-transparent focus:text-blue-500 active:bg-blue-100 focus:!shadow-[inset_0_0_0_1px_theme(colors.blue.500),0_0_0_2px_rgba(0,99,255,0.25)] active:text-blue-700 hover:bg-blue-100 hover:shadow-[inset_0_0_0_1px_theme(colors.blue.300)] hover:text-blue-300 hover:focus:bg-blue-100 hover:focus:!shadow-[inset_0_0_0_1px_theme(colors.blue.300),0_0_0_2px_rgba(0,99,255,0.25)] hover:focus:text-blue-300`;\n\n case 'discrete': {\n if (icon) {\n return `bg-transparent text-black border-transparent focus:text-black focus:yt-focus active:text-black hover:text-grey-700 hover:focus:text-grey-700 disabled:hover:text-black `;\n }\n\n return `yt-transparent focus:text-blue-500 focus:yt-focus active:text-blue-700 hover:text-blue-300 hover:focus:text-blue-300 disabled:hover:yt-transparent`;\n }\n\n default:\n return `wcag-grey-200 focus:bg-grey-200 focus:yt-focus active:bg-grey-300 active:text-black hover:bg-grey-100 hover:text-grey-700 hover:focus:bg-grey-100 hover:focus:text-grey-700 disabled:hover:wcag-grey-200`;\n }\n};\n\nexport const createButtonWithTooltip = (\n props: any,\n className: string,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n): JSX.Element => {\n const { tooltip, ...buttonProps } = props;\n const button = <ButtonPrimitive.Button {...buttonProps} className={className} ref={ref} />;\n\n if (tooltip) {\n return <Tooltip title={tooltip}>{button}</Tooltip>;\n }\n\n return button;\n};\n\nexport const createButtonWithOverlays = (props: any, buttonBase: JSX.Element) => {\n const { dialog, drawer, hanger, menu, popover } = props;\n let button = buttonBase;\n\n if (typeof dialog === 'function') {\n button = dialog({ trigger: button });\n } else if (typeof drawer === 'function') {\n button = drawer({ trigger: button });\n } else if (typeof menu === 'function') {\n button = menu({ trigger: button });\n } else if (typeof popover === 'function') {\n button = popover({ trigger: button });\n }\n\n if (typeof hanger === 'function') {\n button = hanger({ anchor: button });\n }\n\n return button;\n};\n"],"names":["getButtonClasses","getAppearanceClasses","value","icon","createButtonWithTooltip","props","className","ref","tooltip","buttonProps","button","React","ButtonPrimitive","Tooltip","title","createButtonWithOverlays","buttonBase","dialog","drawer","hanger","menu","popover","trigger","anchor"],"mappings":";;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OW,OAAO,KAAK,UAAU,EAAE;IACtCX,MAAM,GAAGW,OAAO,CAAC;MAAEC,OAAO,EAAEZ;KAAQ,CAAC;;EAGzC,IAAI,OAAOS,MAAM,KAAK,UAAU,EAAE;IAC9BT,MAAM,GAAGS,MAAM,CAAC;MAAEI,MAAM,EAAEb;KAAQ,CAAC;;EAGvC,OAAOA,MAAM;AACjB;;;;"}
|
@@ -21,7 +21,7 @@ const Card = /*#__PURE__*/forwardRef(function Card(props, ref) {
|
|
21
21
|
menu,
|
22
22
|
children
|
23
23
|
} = props;
|
24
|
-
const className = cn('bg-white flex flex-col rounded-xl
|
24
|
+
const className = cn('bg-white flex flex-col rounded-xl border border-solid border-radius-[12px] border-grey-300 hover:border-grey-500', props.className);
|
25
25
|
return /*#__PURE__*/createElement("div", {
|
26
26
|
className: className,
|
27
27
|
"data-taco": "card",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Card.js","sources":["../../../../../../../src/components/Card/Card.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\n\nimport { MenuProps } from '../Menu/Menu';\nimport { IconButton } from '../IconButton/IconButton';\n\nexport type CardContentProps = React.HTMLAttributes<HTMLDivElement> & {\n noPadding?: boolean;\n};\n\nconst Content = React.forwardRef<HTMLDivElement, CardContentProps>(function CardContent(externalProps, ref) {\n const { noPadding, ...props } = externalProps;\n const className = cn(\n 'flex-grow overflow-auto',\n {\n 'mx-4 mb-4': !noPadding,\n },\n props.className\n );\n return <div {...props} className={className} ref={ref} />;\n});\n\nexport type CardProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Title of the Card */\n title: string | React.ReactElement;\n /** Menu component associated with the Card */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n};\n\nexport const Card = React.forwardRef<HTMLDivElement, CardProps>(function Card(props, ref) {\n const { title, menu, children } = props;\n const className = cn(\n 'bg-white flex flex-col rounded-xl
|
1
|
+
{"version":3,"file":"Card.js","sources":["../../../../../../../src/components/Card/Card.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\n\nimport { MenuProps } from '../Menu/Menu';\nimport { IconButton } from '../IconButton/IconButton';\n\nexport type CardContentProps = React.HTMLAttributes<HTMLDivElement> & {\n noPadding?: boolean;\n};\n\nconst Content = React.forwardRef<HTMLDivElement, CardContentProps>(function CardContent(externalProps, ref) {\n const { noPadding, ...props } = externalProps;\n const className = cn(\n 'flex-grow overflow-auto',\n {\n 'mx-4 mb-4': !noPadding,\n },\n props.className\n );\n return <div {...props} className={className} ref={ref} />;\n});\n\nexport type CardProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Title of the Card */\n title: string | React.ReactElement;\n /** Menu component associated with the Card */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n};\n\nexport const Card = React.forwardRef<HTMLDivElement, CardProps>(function Card(props, ref) {\n const { title, menu, children } = props;\n const className = cn(\n 'bg-white flex flex-col rounded-xl border border-solid border-radius-[12px] border-grey-300 hover:border-grey-500',\n props.className\n );\n\n return (\n <div className={className} data-taco=\"card\" ref={ref}>\n <div className=\"mx-4 mt-4 mb-2 flex\">\n {title && <h4 className=\"mb-0 flex-grow text-left\">{title}</h4>}\n {menu ? <IconButton icon=\"ellipsis-horizontal\" appearance=\"discrete\" menu={menu} className=\"-mt-[4px]\" /> : null}\n </div>\n {children}\n </div>\n );\n}) as React.ForwardRefExoticComponent<CardProps> & {\n Content: React.ForwardRefExoticComponent<CardContentProps>;\n};\nCard.Content = Content;\n"],"names":["Content","React","CardContent","externalProps","ref","noPadding","props","className","cn","Card","title","menu","children","IconButton","icon","appearance"],"mappings":";;;;AAUA,MAAMA,OAAO,gBAAGC,UAAgB,CAAmC,SAASC,WAAW,CAACC,aAAa,EAAEC,GAAG;EACtG,MAAM;IAAEC,SAAS;IAAE,GAAGC;GAAO,GAAGH,aAAa;EAC7C,MAAMI,SAAS,GAAGC,EAAE,CAChB,yBAAyB,EACzB;IACI,WAAW,EAAE,CAACH;GACjB,EACDC,KAAK,CAACC,SAAS,CAClB;EACD,oBAAON,uCAASK,KAAK;IAAEC,SAAS,EAAEA,SAAS;IAAEH,GAAG,EAAEA;KAAO;AAC7D,CAAC,CAAC;MASWK,IAAI,gBAAGR,UAAgB,CAA4B,SAASQ,IAAI,CAACH,KAAK,EAAEF,GAAG;EACpF,MAAM;IAAEM,KAAK;IAAEC,IAAI;IAAEC;GAAU,GAAGN,KAAK;EACvC,MAAMC,SAAS,GAAGC,EAAE,CAChB,kHAAkH,EAClHF,KAAK,CAACC,SAAS,CAClB;EAED,oBACIN;IAAKM,SAAS,EAAEA,SAAS;iBAAY,MAAM;IAACH,GAAG,EAAEA;kBAC7CH;IAAKM,SAAS,EAAC;KACVG,KAAK,iBAAIT;IAAIM,SAAS,EAAC;KAA4BG,KAAK,CAAM,EAC9DC,IAAI,gBAAGV,cAACY,UAAU;IAACC,IAAI,EAAC,qBAAqB;IAACC,UAAU,EAAC,UAAU;IAACJ,IAAI,EAAEA,IAAI;IAAEJ,SAAS,EAAC;IAAc,GAAG,IAAI,CAC9G,EACLK,QAAQ,CACP;AAEd,CAAC;AAGDH,IAAI,CAACT,OAAO,GAAGA,OAAO;;;;"}
|
@@ -3,7 +3,7 @@ import { Root } from '@radix-ui/react-dialog';
|
|
3
3
|
import { DialogContext } from './Context.js';
|
4
4
|
import { Trigger } from './components/Trigger.js';
|
5
5
|
import { Content, Title, Footer, Close } from './components/Content.js';
|
6
|
-
import {
|
6
|
+
import { DialogDrawer } from './components/DialogDrawer.js';
|
7
7
|
import { Extra } from './components/Extra.js';
|
8
8
|
|
9
9
|
const useSeparatedChildren = initialChildren => {
|
@@ -13,7 +13,7 @@ const useSeparatedChildren = initialChildren => {
|
|
13
13
|
let extra;
|
14
14
|
Children.toArray(initialChildren).forEach(child => {
|
15
15
|
var _child$type, _child$type2;
|
16
|
-
if (((_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.displayName) ===
|
16
|
+
if (((_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.displayName) === DialogDrawer.displayName) {
|
17
17
|
drawer = child;
|
18
18
|
} else if (((_child$type2 = child.type) === null || _child$type2 === void 0 ? void 0 : _child$type2.displayName) === Extra.displayName) {
|
19
19
|
extra = child;
|
@@ -70,7 +70,7 @@ Dialog.Content = Content;
|
|
70
70
|
Dialog.Title = Title;
|
71
71
|
Dialog.Footer = Footer;
|
72
72
|
Dialog.Extra = Extra;
|
73
|
-
Dialog.Drawer =
|
73
|
+
Dialog.Drawer = DialogDrawer;
|
74
74
|
Dialog.Close = Close;
|
75
75
|
|
76
76
|
export { Dialog };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Dialog.js","sources":["../../../../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport './Dialog.css';\nimport { DialogTriggerProps, Trigger } from './components/Trigger';\nimport {\n Content,\n Title,\n Footer,\n Close,\n DialogContentProps,\n DialogContentRenderProps,\n DialogContentDrawerRenderProps,\n DialogTitleProps,\n DialogFooterProps,\n DialogCloseProps,\n} from './components/Content';\nimport { DialogDrawerProps, DialogDrawerRenderProps,
|
1
|
+
{"version":3,"file":"Dialog.js","sources":["../../../../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport './Dialog.css';\nimport { DialogTriggerProps, Trigger } from './components/Trigger';\nimport {\n Content,\n Title,\n Footer,\n Close,\n DialogContentProps,\n DialogContentRenderProps,\n DialogContentDrawerRenderProps,\n DialogTitleProps,\n DialogFooterProps,\n DialogCloseProps,\n} from './components/Content';\nimport { DialogDrawerProps, DialogDrawerRenderProps, DialogDrawer } from './components/DialogDrawer';\nimport { DialogExtraProps, Extra } from './components/Extra';\nimport { DialogContext } from './Context';\nimport { DialogSize } from './types';\n\nexport type {\n DialogCloseProps,\n DialogContentDrawerRenderProps,\n DialogContentProps,\n DialogContentRenderProps,\n DialogDrawerProps,\n DialogDrawerRenderProps,\n DialogFooterProps,\n DialogSize,\n DialogTitleProps,\n};\n\nexport type DialogTexts = {\n /**\n * Aria-label for close icon button in dialog.\n * To read more about how to provide the text, see [Provider](component:provider) component\n */\n close: string;\n drag: string;\n};\n\nexport type DialogProps = {\n children: React.ReactNode | React.ReactNode[];\n /** When `true`, pressing escape will close the dialog */\n closeOnEscape?: boolean;\n /** Set whether the dialog is open by default or not */\n defaultOpen?: boolean;\n /** Allows dragging the dialog around the screen (window constrained) */\n draggable?: boolean;\n /** Handler called when dialog closes by user interaction */\n onClose?: () => void;\n /** Called when the dialog opens or closes, must be used in conjunction with open */\n onChange?: (open: boolean) => void;\n /** Control the open state of the dialog from outside the component */\n open?: boolean;\n /** Shows the close icon button of the dialog */\n showCloseButton?: boolean;\n /** Size of the dialog. This is the recommended way to set a size for dialog component. */\n size?: DialogSize;\n /** A trigger to be used for the dialog, should not be set if `children` already contains a trigger */\n trigger?: JSX.Element;\n};\n\nconst useSeparatedChildren = initialChildren => {\n return React.useMemo(() => {\n const children: any[] = [];\n let drawer;\n let extra;\n\n React.Children.toArray(initialChildren).forEach((child: any) => {\n if (child.type?.displayName === DialogDrawer.displayName) {\n drawer = child;\n } else if (child.type?.displayName === Extra.displayName) {\n extra = child;\n } else {\n children.push(child);\n }\n });\n\n return [children, drawer, extra];\n }, [initialChildren]);\n};\n\nexport type ForwardedDialogWithStatics = React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<HTMLElement>> & {\n Trigger: React.ForwardRefExoticComponent<DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;\n Content: React.ForwardRefExoticComponent<DialogContentProps & React.RefAttributes<HTMLDivElement>>;\n Title: React.ForwardRefExoticComponent<DialogTitleProps & React.RefAttributes<HTMLHeadingElement>>;\n Footer: React.ForwardRefExoticComponent<DialogFooterProps & React.RefAttributes<HTMLDivElement>>;\n Extra: React.ForwardRefExoticComponent<DialogExtraProps & React.RefAttributes<HTMLDivElement>>;\n Drawer: React.ForwardRefExoticComponent<DialogDrawerProps & React.RefAttributes<HTMLDivElement>>;\n Close: React.ForwardRefExoticComponent<DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;\n};\n\nexport const Dialog = React.forwardRef(function Dialog(props: DialogProps, ref: React.Ref<HTMLElement>) {\n const {\n children: initialChildren,\n closeOnEscape = true,\n defaultOpen,\n draggable = false,\n onChange,\n onClose,\n open,\n showCloseButton = true,\n size = 'sm',\n trigger,\n ...otherProps\n } = props;\n const [children, drawer, extra] = useSeparatedChildren(initialChildren);\n const [drawerOpen, setDrawerOpen] = React.useState(false);\n\n const context = React.useMemo(\n () => ({\n closeOnEscape,\n draggable,\n drawer: {\n open: drawerOpen,\n toggle: () => setDrawerOpen(isDrawerOpen => !isDrawerOpen),\n },\n elements: {\n drawer,\n extra,\n },\n onClose,\n props: otherProps,\n showCloseButton,\n size,\n ref,\n }),\n [closeOnEscape, drawerOpen, draggable, drawer, extra, open, otherProps, showCloseButton]\n );\n\n return (\n <DialogContext.Provider value={context}>\n <DialogPrimitive.Root defaultOpen={defaultOpen} open={open} onOpenChange={onChange}>\n {trigger && <Trigger>{trigger}</Trigger>}\n {children}\n </DialogPrimitive.Root>\n </DialogContext.Provider>\n );\n}) as ForwardedDialogWithStatics;\n\nDialog.Trigger = Trigger;\nDialog.Content = Content;\nDialog.Title = Title;\nDialog.Footer = Footer;\nDialog.Extra = Extra;\nDialog.Drawer = DialogDrawer;\nDialog.Close = Close;\n"],"names":["useSeparatedChildren","initialChildren","React","children","drawer","extra","toArray","forEach","child","type","displayName","DialogDrawer","Extra","push","Dialog","props","ref","closeOnEscape","defaultOpen","draggable","onChange","onClose","open","showCloseButton","size","trigger","otherProps","drawerOpen","setDrawerOpen","context","toggle","isDrawerOpen","elements","DialogContext","Provider","value","DialogPrimitive","onOpenChange","Trigger","Content","Title","Footer","Drawer","Close"],"mappings":";;;;;;;;AAgEA,MAAMA,oBAAoB,GAAGC,eAAe;EACxC,OAAOC,OAAa,CAAC;IAC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AAE;MACN5B,MAAM;MACNC;KACH;IACDgB,OAAO;IACPN,KAAK,EAAEW,UAAU;IACjBH,eAAe;IACfC,IAAI;IACJR;GACH,CAAC,EACF,CAACC,aAAa,EAAEU,UAAU,EAAER,SAAS,EAAEf,MAAM,EAAEC,KAAK,EAAEiB,IAAI,EAAEI,UAAU,EAAEH,eAAe,CAAC,CAC3F;EAED,oBACIrB,cAAC+B,aAAa,CAACC,QAAQ;IAACC,KAAK,EAAEN;kBAC3B3B,cAACkC,IAAoB;IAAClB,WAAW,EAAEA,WAAW;IAAEI,IAAI,EAAEA,IAAI;IAAEe,YAAY,EAAEjB;KACrEK,OAAO,iBAAIvB,cAACoC,OAAO,QAAEb,OAAO,CAAW,EACvCtB,QAAQ,CACU,CACF;AAEjC,CAAC;AAEDW,MAAM,CAACwB,OAAO,GAAGA,OAAO;AACxBxB,MAAM,CAACyB,OAAO,GAAGA,OAAO;AACxBzB,MAAM,CAAC0B,KAAK,GAAGA,KAAK;AACpB1B,MAAM,CAAC2B,MAAM,GAAGA,MAAM;AACtB3B,MAAM,CAACF,KAAK,GAAGA,KAAK;AACpBE,MAAM,CAAC4B,MAAM,GAAG/B,YAAY;AAC5BG,MAAM,CAAC6B,KAAK,GAAGA,KAAK;;;;"}
|
package/dist/esm/packages/taco/src/components/Dialog/components/{Drawer.js → DialogDrawer.js}
RENAMED
@@ -3,7 +3,7 @@ import cn from 'classnames';
|
|
3
3
|
import { useCurrentDialog } from '../Context.js';
|
4
4
|
import { motion } from 'framer-motion';
|
5
5
|
|
6
|
-
const
|
6
|
+
const DialogDrawer = /*#__PURE__*/forwardRef(function DialogDrawer(props, ref) {
|
7
7
|
var _dialog$drawer, _dialog$drawer2;
|
8
8
|
const dialog = useCurrentDialog();
|
9
9
|
const className = cn('absolute top-0 -ml-[4px] hidden h-full w-full overflow-y-auto rounded-r bg-white p-6 text-left', props.className);
|
@@ -35,7 +35,7 @@ const Drawer = /*#__PURE__*/forwardRef(function DialogDrawer(props, ref) {
|
|
35
35
|
ref: ref
|
36
36
|
}), typeof props.children === 'function' ? props.children(dialog.drawer) : props.children);
|
37
37
|
});
|
38
|
-
|
38
|
+
DialogDrawer.displayName = 'DialogDrawer';
|
39
39
|
|
40
|
-
export {
|
41
|
-
//# sourceMappingURL=
|
40
|
+
export { DialogDrawer };
|
41
|
+
//# sourceMappingURL=DialogDrawer.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"DialogDrawer.js","sources":["../../../../../../../../src/components/Dialog/components/DialogDrawer.tsx"],"sourcesContent":["import * as React from 'react';\nimport { motion } from 'framer-motion';\nimport cn from 'classnames';\nimport { DialogContext, useCurrentDialog } from '../Context';\n\nexport type DialogDrawerRenderProps = DialogContext['drawer'];\n\nexport type DialogDrawerProps = Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onAnimationStart' | 'onDragStart' | 'onDragEnd' | 'onDrag'\n> & {\n children: Omit<React.ReactNode, 'Function'> | ((props: DialogDrawerRenderProps) => React.ReactNode);\n};\n\nconst DialogDrawer = React.forwardRef(function DialogDrawer(props: DialogDrawerProps, ref: React.Ref<HTMLDivElement>) {\n const dialog = useCurrentDialog();\n const className = cn(\n 'absolute top-0 -ml-[4px] hidden h-full w-full overflow-y-auto rounded-r bg-white p-6 text-left',\n props.className\n );\n\n return (\n <motion.div\n {...props}\n className={className}\n data-taco=\"dialog-drawer\"\n aria-hidden={!dialog.drawer?.open}\n variants={{\n visible: {\n left: '100%',\n display: 'block',\n transition: { ease: 'easeOut', duration: 0.2 },\n },\n hidden: {\n left: '0%',\n transition: { ease: 'easeOut', duration: 0.2 },\n transitionEnd: {\n display: 'none',\n },\n },\n }}\n animate={dialog.drawer?.open ? 'visible' : 'hidden'}\n ref={ref}>\n {typeof props.children === 'function' ? props.children(dialog.drawer) : props.children}\n </motion.div>\n );\n});\nDialogDrawer.displayName = 'DialogDrawer';\n\nexport { DialogDrawer };\n"],"names":["DialogDrawer","React","props","ref","dialog","useCurrentDialog","className","cn","motion","div","drawer","open","variants","visible","left","display","transition","ease","duration","hidden","transitionEnd","animate","children","displayName"],"mappings":";;;;;MAcMA,YAAY,gBAAGC,UAAgB,CAAC,SAASD,YAAY,CAACE,KAAwB,EAAEC,GAA8B;;EAChH,MAAMC,MAAM,GAAGC,gBAAgB,EAAE;EACjC,MAAMC,SAAS,GAAGC,EAAE,CAChB,iGAAiG,EACjGL,KAAK,CAACI,SAAS,CAClB;EAED,oBACIL,cAACO,MAAM,CAACC,GAAG,oBACHP,KAAK;IACTI,SAAS,EAAEA,SAAS;iBACV,eAAe;mBACZ,oBAACF,MAAM,CAACM,MAAM,2CAAb,eAAeC,IAAI;IACjCC,QAAQ,EAAE;MACNC,OAAO,EAAE;QACLC,IAAI,EAAE,MAAM;QACZC,OAAO,EAAE,OAAO;QAChBC,UAAU,EAAE;UAAEC,IAAI,EAAE,SAAS;UAAEC,QAAQ,EAAE;;OAC5C;MACDC,MAAM,EAAE;QACJL,IAAI,EAAE,IAAI;QACVE,UAAU,EAAE;UAAEC,IAAI,EAAE,SAAS;UAAEC,QAAQ,EAAE;SAAK;QAC9CE,aAAa,EAAE;UACXL,OAAO,EAAE;;;KAGpB;IACDM,OAAO,EAAE,mBAAAjB,MAAM,CAACM,MAAM,4CAAb,gBAAeC,IAAI,GAAG,SAAS,GAAG,QAAQ;IACnDR,GAAG,EAAEA;MACJ,OAAOD,KAAK,CAACoB,QAAQ,KAAK,UAAU,GAAGpB,KAAK,CAACoB,QAAQ,CAAClB,MAAM,CAACM,MAAM,CAAC,GAAGR,KAAK,CAACoB,QAAQ,CAC7E;AAErB,CAAC;AACDtB,YAAY,CAACuB,WAAW,GAAG,cAAc;;;;"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { createContext, useContext } from 'react';
|
2
|
+
|
3
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
4
|
+
const DrawerContext = /*#__PURE__*/createContext({
|
5
|
+
closeOnEscape: true,
|
6
|
+
showCloseButton: true,
|
7
|
+
onClose: () => {},
|
8
|
+
onResize: () => {},
|
9
|
+
props: {},
|
10
|
+
ref: null,
|
11
|
+
size: 'md',
|
12
|
+
variant: 'embedded'
|
13
|
+
});
|
14
|
+
const useCurrentDrawer = () => {
|
15
|
+
return useContext(DrawerContext);
|
16
|
+
};
|
17
|
+
|
18
|
+
export { DrawerContext, useCurrentDrawer };
|
19
|
+
//# sourceMappingURL=Context.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Context.js","sources":["../../../../../../../src/components/Drawer/Context.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-function */\nimport * as React from 'react';\nimport { DrawerSize, DrawerVariant } from './types';\n\nexport type DrawerContext = {\n closeOnEscape: boolean;\n showCloseButton: boolean;\n onClose?: () => void;\n onResize?: (delta: number) => void;\n props: {};\n ref: React.Ref<HTMLElement>;\n size: DrawerSize;\n open?: boolean;\n setOpen?: (open: boolean) => void;\n variant: DrawerVariant;\n focusTrap?: boolean;\n outlet?: HTMLElement;\n};\n\nexport const DrawerContext = React.createContext<DrawerContext>({\n closeOnEscape: true,\n showCloseButton: true,\n onClose: () => {},\n onResize: () => {},\n props: {},\n ref: null,\n size: 'md',\n variant: 'embedded',\n});\n\nexport const useCurrentDrawer = () => {\n return React.useContext(DrawerContext);\n};\n"],"names":["DrawerContext","React","closeOnEscape","showCloseButton","onClose","onResize","props","ref","size","variant","useCurrentDrawer"],"mappings":";;AAAA;MAmBaA,aAAa,gBAAGC,aAAmB,CAAgB;EAC5DC,aAAa,EAAE,IAAI;EACnBC,eAAe,EAAE,IAAI;EACrBC,OAAO,EAAE,QAAQ;EACjBC,QAAQ,EAAE,QAAQ;EAClBC,KAAK,EAAE,EAAE;EACTC,GAAG,EAAE,IAAI;EACTC,IAAI,EAAE,IAAI;EACVC,OAAO,EAAE;CACZ;MAEYC,gBAAgB,GAAG;EAC5B,OAAOT,UAAgB,CAACD,aAAa,CAAC;AAC1C;;;;"}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import { forwardRef, useState, useMemo, useCallback, useEffect, createElement } from 'react';
|
2
|
+
import cn from 'classnames';
|
3
|
+
import { Root } from '@radix-ui/react-dialog';
|
4
|
+
import { DrawerContext } from './Context.js';
|
5
|
+
import { Content, InnerContent, Title, Footer, Close, Actions } from './components/Content.js';
|
6
|
+
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
7
|
+
import { Trigger } from './components/Trigger.js';
|
8
|
+
|
9
|
+
const Outlet = /*#__PURE__*/forwardRef(function Outlet(props, ref) {
|
10
|
+
const className = cn('h-full ml-auto overflow-hidden flex-shrink-0', props.className);
|
11
|
+
return /*#__PURE__*/createElement("div", Object.assign({}, props, {
|
12
|
+
className: className,
|
13
|
+
"data-taco": "drawer-outlet",
|
14
|
+
ref: ref
|
15
|
+
}));
|
16
|
+
});
|
17
|
+
// drawerStack getting set by previous drawer instance, to be able to close previous instance, when new instance getting opened.
|
18
|
+
let drawerStack;
|
19
|
+
const Drawer = /*#__PURE__*/forwardRef(function Drawer(props, ref) {
|
20
|
+
const {
|
21
|
+
open: openProp,
|
22
|
+
defaultOpen: defaultOpenProp,
|
23
|
+
// if onChange is not provided, then replace it with empty function, needed for useControllableState
|
24
|
+
onChange = () => {
|
25
|
+
// do nothing.
|
26
|
+
},
|
27
|
+
variant = 'embedded',
|
28
|
+
className,
|
29
|
+
closeOnEscape = true,
|
30
|
+
onResize,
|
31
|
+
onClose,
|
32
|
+
size = 'md',
|
33
|
+
trigger,
|
34
|
+
children,
|
35
|
+
focusTrap = props.focusTrap === undefined && props.variant === 'overlay' ? true : props.focusTrap,
|
36
|
+
showCloseButton = true,
|
37
|
+
...otherProps
|
38
|
+
} = props;
|
39
|
+
const [open, setOpen] = useControllableState({
|
40
|
+
prop: openProp,
|
41
|
+
defaultProp: defaultOpenProp,
|
42
|
+
onChange
|
43
|
+
});
|
44
|
+
const [outlet, setOutlet] = useState();
|
45
|
+
const context = useMemo(() => ({
|
46
|
+
closeOnEscape,
|
47
|
+
onClose,
|
48
|
+
onResize,
|
49
|
+
props: otherProps,
|
50
|
+
size,
|
51
|
+
ref,
|
52
|
+
open,
|
53
|
+
setOpen,
|
54
|
+
variant,
|
55
|
+
focusTrap,
|
56
|
+
showCloseButton,
|
57
|
+
outlet
|
58
|
+
}), [closeOnEscape, open, setOpen, otherProps, variant, onResize, onClose, size, focusTrap, showCloseButton, outlet]);
|
59
|
+
// this prevents two drawers being open at once and used when one drawer getting opened before another one got closed.
|
60
|
+
const close = useCallback(() => {
|
61
|
+
setOpen(false);
|
62
|
+
onClose && onClose();
|
63
|
+
}, []);
|
64
|
+
useEffect(() => {
|
65
|
+
var _document$querySelect;
|
66
|
+
const outletElement = (_document$querySelect = document.querySelector('[data-taco="drawer-outlet"]')) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.body;
|
67
|
+
setOutlet(outletElement);
|
68
|
+
}, []);
|
69
|
+
useEffect(() => {
|
70
|
+
if (open) {
|
71
|
+
// if drawerStack is defined, this means that another drawer was opened before
|
72
|
+
if (drawerStack) {
|
73
|
+
drawerStack();
|
74
|
+
}
|
75
|
+
drawerStack = close;
|
76
|
+
} else {
|
77
|
+
// if drawerStack is equal to current close callback,
|
78
|
+
// this means that drawer getting closed completely instead of getting closed on re-open
|
79
|
+
if (drawerStack === close) {
|
80
|
+
drawerStack = undefined;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}, [open]);
|
84
|
+
return /*#__PURE__*/createElement(DrawerContext.Provider, {
|
85
|
+
value: context
|
86
|
+
}, /*#__PURE__*/createElement(Root, {
|
87
|
+
modal: variant === 'overlay' ? true : false,
|
88
|
+
open: open,
|
89
|
+
onOpenChange: setOpen
|
90
|
+
}, trigger && /*#__PURE__*/createElement(Trigger, null, trigger), children));
|
91
|
+
});
|
92
|
+
Drawer.Trigger = Trigger;
|
93
|
+
Drawer.Content = Content;
|
94
|
+
Drawer.InnerContent = InnerContent;
|
95
|
+
Drawer.Title = Title;
|
96
|
+
Drawer.Footer = Footer;
|
97
|
+
Drawer.Close = Close;
|
98
|
+
Drawer.Actions = Actions;
|
99
|
+
Drawer.Outlet = Outlet;
|
100
|
+
|
101
|
+
export { Drawer };
|
102
|
+
//# sourceMappingURL=Drawer.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Drawer.js","sources":["../../../../../../../src/components/Drawer/Drawer.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n Actions,\n Footer,\n InnerContent,\n DrawerInnerContentProps,\n DrawerFooterProps,\n DrawerTitleProps,\n Title,\n Close,\n Content,\n DrawerContentProps,\n DrawerCloseProps,\n} from './components/Content';\nimport { GroupProps } from '../Group/Group';\nimport { DialogProps } from '../Dialog/Dialog';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport cn from 'classnames';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { DrawerTriggerProps, Trigger } from './components/Trigger';\nimport { DrawerContext } from './Context';\nimport { DrawerSize, DrawerVariant } from './types';\n\nexport type DrawerTexts = {\n /**\n * Aria-label for close icon button in drawer.\n */\n close: string;\n};\n\nexport type DrawerProps = Omit<DialogProps, 'draggable' | 'size'> & {\n children: React.ReactNode | React.ReactNode[];\n /** Size of the drawer. This is the recommended way to set a size for drawer component. */\n size?: DrawerSize;\n /** When `true`, pressing escape will close the drawer */\n closeOnEscape?: boolean;\n /** Set whether the drawer is open by default or not, use when not providing a trigger */\n defaultOpen?: boolean;\n /** Handler called when drawer closes by user interaction */\n onClose?: () => void;\n /** Called when the drawer opens or closes, must be used in conjunction with open */\n onChange?: (open: boolean | undefined) => void;\n /** Control the open state of the drawer from outside the component */\n open?: boolean;\n /** A trigger to be used for the drawer, should not be set if `children` already contains a trigger */\n trigger?: JSX.Element;\n /** Triggers when resizing, can be throttled or debounced for better performances */\n onResize?: (delta: number) => void;\n /** Rendering variant of the drawer */\n variant?: DrawerVariant;\n /** className for children container, needed for embedded version, in cases where we might need to control children height */\n className?: string;\n /** When 'true' preventing focus from leaving drawer content */\n focusTrap?: boolean;\n /** When 'true' renders close button in topr right cornenr of drawer content */\n showCloseButton?: boolean;\n};\n\nexport type OutletProps = React.HTMLAttributes<HTMLDivElement>;\nconst Outlet = React.forwardRef(function Outlet(props: OutletProps, ref: React.Ref<HTMLDivElement>) {\n const className = cn('h-full ml-auto overflow-hidden flex-shrink-0', props.className);\n return <div {...props} className={className} data-taco=\"drawer-outlet\" ref={ref} />;\n});\n\n// drawerStack getting set by previous drawer instance, to be able to close previous instance, when new instance getting opened.\nlet drawerStack: undefined | (() => void);\n\nexport type ForwardedDrawerWithStatics = React.ForwardRefExoticComponent<DrawerProps & React.RefAttributes<HTMLElement>> & {\n Trigger: React.ForwardRefExoticComponent<DrawerTriggerProps & React.RefAttributes<HTMLButtonElement>>;\n Content: React.ForwardRefExoticComponent<DrawerContentProps & React.RefAttributes<HTMLDivElement>>;\n InnerContent: React.ForwardRefExoticComponent<DrawerInnerContentProps & React.RefAttributes<HTMLDivElement>>;\n Title: React.ForwardRefExoticComponent<DrawerTitleProps & React.RefAttributes<HTMLHeadingElement>>;\n Footer: React.ForwardRefExoticComponent<DrawerFooterProps & React.RefAttributes<HTMLDivElement>>;\n Close: React.ForwardRefExoticComponent<DrawerCloseProps & React.RefAttributes<HTMLButtonElement>>;\n Actions: React.ForwardRefExoticComponent<GroupProps & React.RefAttributes<HTMLDivElement>>;\n Outlet: React.ForwardRefExoticComponent<OutletProps & React.RefAttributes<HTMLDivElement>>;\n};\n\nexport const Drawer = React.forwardRef(function Drawer(props: DrawerProps, ref: React.Ref<HTMLElement>) {\n const {\n open: openProp,\n defaultOpen: defaultOpenProp,\n // if onChange is not provided, then replace it with empty function, needed for useControllableState\n onChange = () => {\n // do nothing.\n },\n variant = 'embedded',\n className,\n closeOnEscape = true,\n onResize,\n onClose,\n size = 'md',\n trigger,\n children,\n focusTrap = props.focusTrap === undefined && props.variant === 'overlay' ? true : props.focusTrap,\n showCloseButton = true,\n ...otherProps\n } = props;\n\n const [open, setOpen] = useControllableState<boolean | undefined>({\n prop: openProp,\n defaultProp: defaultOpenProp,\n onChange,\n });\n\n const [outlet, setOutlet] = React.useState<HTMLElement>();\n\n const context = React.useMemo(\n () => ({\n closeOnEscape,\n onClose,\n onResize,\n props: otherProps,\n size,\n ref,\n open,\n setOpen,\n variant,\n focusTrap,\n showCloseButton,\n outlet,\n }),\n [closeOnEscape, open, setOpen, otherProps, variant, onResize, onClose, size, focusTrap, showCloseButton, outlet]\n );\n\n // this prevents two drawers being open at once and used when one drawer getting opened before another one got closed.\n const close = React.useCallback(() => {\n setOpen(false);\n onClose && onClose();\n }, []);\n\n React.useEffect(() => {\n const outletElement = document.querySelector<HTMLElement>('[data-taco=\"drawer-outlet\"]') ?? document.body;\n setOutlet(outletElement);\n }, []);\n\n React.useEffect(() => {\n if (open) {\n // if drawerStack is defined, this means that another drawer was opened before\n if (drawerStack) {\n drawerStack();\n }\n drawerStack = close;\n } else {\n // if drawerStack is equal to current close callback,\n // this means that drawer getting closed completely instead of getting closed on re-open\n if (drawerStack === close) {\n drawerStack = undefined;\n }\n }\n }, [open]);\n\n return (\n <DrawerContext.Provider value={context}>\n <DialogPrimitive.Root modal={variant === 'overlay' ? true : false} open={open} onOpenChange={setOpen}>\n {trigger && <Trigger>{trigger}</Trigger>}\n {children}\n </DialogPrimitive.Root>\n </DrawerContext.Provider>\n );\n}) as ForwardedDrawerWithStatics;\n\nDrawer.Trigger = Trigger;\nDrawer.Content = Content;\nDrawer.InnerContent = InnerContent;\nDrawer.Title = Title;\nDrawer.Footer = Footer;\nDrawer.Close = Close;\nDrawer.Actions = Actions;\nDrawer.Outlet = Outlet;\n"],"names":["Outlet","React","props","ref","className","cn","drawerStack","Drawer","open","openProp","defaultOpen","defaultOpenProp","onChange","variant","closeOnEscape","onResize","onClose","size","trigger","children","focusTrap","undefined","showCloseButton","otherProps","setOpen","useControllableState","prop","defaultProp","outlet","setOutlet","context","close","outletElement","document","querySelector","body","DrawerContext","Provider","value","DialogPrimitive","modal","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