react-restyle-components 0.4.46 → 0.4.47
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/lib/index.js +1 -3
- package/lib/src/core-components/index.js +1 -1
- package/lib/src/core-components/src/components/Accordion/AccordionSection/Accordion.js +1 -15
- package/lib/src/core-components/src/components/Accordion/AccordionSection/AccordionContext.js +1 -6
- package/lib/src/core-components/src/components/Accordion/AccordionSection/AccordionSection.js +1 -39
- package/lib/src/core-components/src/components/Accordion/AccordionSection/Header.js +1 -39
- package/lib/src/core-components/src/components/Accordion/AccordionSection/elements.js +57 -94
- package/lib/src/core-components/src/components/Accordion/AccordionSection/hooks/useCurrentAccordionIndex.js +1 -13
- package/lib/src/core-components/src/components/Accordion/AccordionSection/index.js +1 -3
- package/lib/src/core-components/src/components/Accordion/AccordionSection/types.js +1 -9
- package/lib/src/core-components/src/components/Accordion/Collapsible/Collapsible2.component.js +1 -249
- package/lib/src/core-components/src/components/Action/types.js +1 -8
- package/lib/src/core-components/src/components/AlertBanner/AlertBanner.js +1 -45
- package/lib/src/core-components/src/components/AlertBanner/elements.js +45 -120
- package/lib/src/core-components/src/components/AlertBanner/index.js +1 -2
- package/lib/src/core-components/src/components/AlertBanner/types.js +1 -10
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-group-by-multiple-select-multiple-fields-display/auto-complete-filter-group-by-multiple-select-multiple-fields-display.component.js +1 -451
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-multi-select-multi-fields-display-drag-drop/auto-complete-filter-multi-select-multi-fields-display-drag-drop.component.js +1 -229
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-multi-select-selected-top-display/auto-complete-filter-multi-select-selected-top-display.component.js +1 -174
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-multiple-select-multiple-fields-display/auto-complete-filter-multiple-select-multiple-fields-display.component.js +2 -129
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-single-select/auto-complete-filter-single-select.component.js +1 -55
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-single-select-multiple-fields-display/auto-complete-filter-single-select-multiple-fields-display.component.js +2 -308
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-group-by/auto-complete-group-by.component.js +1 -115
- package/lib/src/core-components/src/components/AutoComplete/autocomplete/autocomplete.js +2 -442
- package/lib/src/core-components/src/components/AutoComplete/index.js +1 -8
- package/lib/src/core-components/src/components/Avatar/Avatar.js +14 -148
- package/lib/src/core-components/src/components/Badge/Badge.js +2 -25
- package/lib/src/core-components/src/components/Badge/InnerBadge/Inline.js +1 -25
- package/lib/src/core-components/src/components/Badge/InnerBadge/InnerBadge.js +1 -25
- package/lib/src/core-components/src/components/Badge/InnerBadge/elements.js +32 -78
- package/lib/src/core-components/src/components/Badge/InnerBadge/index.js +1 -1
- package/lib/src/core-components/src/components/Badge/index.js +1 -1
- package/lib/src/core-components/src/components/Badge/types.js +1 -5
- package/lib/src/core-components/src/components/Breadcrumb/Breadcrumb.js +1 -83
- package/lib/src/core-components/src/components/Breadcrumb/elements.js +94 -166
- package/lib/src/core-components/src/components/Breadcrumb/index.js +1 -3
- package/lib/src/core-components/src/components/Breadcrumb/types.js +1 -3
- package/lib/src/core-components/src/components/Button/button.component.js +1 -18
- package/lib/src/core-components/src/components/Button/buttonGroup/buttonGroup.component.js +1 -4
- package/lib/src/core-components/src/components/Button/index.js +1 -2
- package/lib/src/core-components/src/components/Button/types.js +1 -1
- package/lib/src/core-components/src/components/Chip/Chip.js +1 -64
- package/lib/src/core-components/src/components/Chip/elements.js +48 -148
- package/lib/src/core-components/src/components/Chip/index.js +1 -2
- package/lib/src/core-components/src/components/Chip/types.js +1 -4
- package/lib/src/core-components/src/components/Divider/Divider.js +1 -25
- package/lib/src/core-components/src/components/Divider/elements.js +31 -68
- package/lib/src/core-components/src/components/Divider/index.js +1 -2
- package/lib/src/core-components/src/components/Divider/types.js +1 -4
- package/lib/src/core-components/src/components/DynamicGrid/DynamicGrid.js +1 -147
- package/lib/src/core-components/src/components/DynamicGrid/GridContainer.js +17 -24
- package/lib/src/core-components/src/components/DynamicGrid/elements.js +100 -162
- package/lib/src/core-components/src/components/DynamicGrid/index.js +1 -3
- package/lib/src/core-components/src/components/DynamicGrid/types.js +1 -28
- package/lib/src/core-components/src/components/DynamicGrid/utils.js +1 -193
- package/lib/src/core-components/src/components/FormField/FormField.js +1 -103
- package/lib/src/core-components/src/components/FormField/components/CheckboxGroupInput.js +1 -37
- package/lib/src/core-components/src/components/FormField/components/CheckboxInput.js +1 -8
- package/lib/src/core-components/src/components/FormField/components/CssMultilineInput.js +1 -192
- package/lib/src/core-components/src/components/FormField/components/DatePickerInput.js +1 -99
- package/lib/src/core-components/src/components/FormField/components/DropdownInput.js +1 -70
- package/lib/src/core-components/src/components/FormField/components/OtpInput.js +1 -81
- package/lib/src/core-components/src/components/FormField/components/PasswordInput.js +1 -40
- package/lib/src/core-components/src/components/FormField/components/PinInput.js +1 -75
- package/lib/src/core-components/src/components/FormField/components/RadioInput.js +1 -54
- package/lib/src/core-components/src/components/FormField/components/TextDropdownInput.js +1 -94
- package/lib/src/core-components/src/components/FormField/components/ToggleInput.js +1 -36
- package/lib/src/core-components/src/components/FormField/components/index.js +1 -11
- package/lib/src/core-components/src/components/FormField/css-properties.js +1 -161
- package/lib/src/core-components/src/components/FormField/index.js +1 -2
- package/lib/src/core-components/src/components/Icon/Icon.js +1 -159
- package/lib/src/core-components/src/components/Icon/index.js +1 -2
- package/lib/src/core-components/src/components/Icon/types.js +1 -9
- package/lib/src/core-components/src/components/Loader/loader.component.js +2 -215
- package/lib/src/core-components/src/components/Masonry/Masonry.js +1 -73
- package/lib/src/core-components/src/components/Masonry/elements.js +29 -46
- package/lib/src/core-components/src/components/Masonry/hooks.js +1 -100
- package/lib/src/core-components/src/components/Masonry/index.js +1 -3
- package/lib/src/core-components/src/components/Masonry/types.js +1 -1
- package/lib/src/core-components/src/components/Modal/BasicModal/modal.component.js +1 -116
- package/lib/src/core-components/src/components/Modal/index.js +1 -2
- package/lib/src/core-components/src/components/Modal/modal-confirm/modal-confirm.component.js +1 -147
- package/lib/src/core-components/src/components/Picker/color-picker/color-picker.component.js +1 -12
- package/lib/src/core-components/src/components/Picker/color-picker-modal/color-picker-modal.component.js +1 -40
- package/lib/src/core-components/src/components/Picker/index.js +1 -2
- package/lib/src/core-components/src/components/Selection/index.js +1 -4
- package/lib/src/core-components/src/components/Selection/multi-select/multi-select.component.js +1 -49
- package/lib/src/core-components/src/components/Selection/multi-select-with-field/multi-select-with-field.component.js +1 -58
- package/lib/src/core-components/src/components/Selection/multi-selection-dropdown/multi-selection-dropdown.component.js +1 -43
- package/lib/src/core-components/src/components/Selection/single-select/single-select.component.js +1 -87
- package/lib/src/core-components/src/components/Skeleton/Skeleton.js +1 -51
- package/lib/src/core-components/src/components/Skeleton/elements.js +54 -143
- package/lib/src/core-components/src/components/Skeleton/index.js +1 -2
- package/lib/src/core-components/src/components/Skeleton/types.js +1 -4
- package/lib/src/core-components/src/components/SpeedDial/SpeedDial.js +1 -128
- package/lib/src/core-components/src/components/SpeedDial/elements.js +62 -132
- package/lib/src/core-components/src/components/SpeedDial/index.js +1 -2
- package/lib/src/core-components/src/components/SpeedDial/types.js +1 -3
- package/lib/src/core-components/src/components/Stepper2/stepper.component.js +1 -139
- package/lib/src/core-components/src/components/Switch/Switch.js +1 -26
- package/lib/src/core-components/src/components/Switch/elements.js +34 -103
- package/lib/src/core-components/src/components/Switch/index.js +1 -2
- package/lib/src/core-components/src/components/Switch/types.js +1 -3
- package/lib/src/core-components/src/components/Table/Table.js +1 -1489
- package/lib/src/core-components/src/components/Table/columnReorder.js +36 -332
- package/lib/src/core-components/src/components/Table/columnResize.js +21 -284
- package/lib/src/core-components/src/components/Table/elements.js +173 -277
- package/lib/src/core-components/src/components/Table/filters.js +30 -555
- package/lib/src/core-components/src/components/Table/hooks.js +2 -536
- package/lib/src/core-components/src/components/Table/index.js +1 -6
- package/lib/src/core-components/src/components/Table/types.js +1 -1
- package/lib/src/core-components/src/components/Tabs/tabs.component.js +1 -22
- package/lib/src/core-components/src/components/Tags1/Tags.component.js +1 -118
- package/lib/src/core-components/src/components/Tags1/types.js +1 -20
- package/lib/src/core-components/src/components/Timer1/timer.component.js +1 -76
- package/lib/src/core-components/src/components/Toast/Toast.js +1 -50
- package/lib/src/core-components/src/components/Toast/elements.js +41 -122
- package/lib/src/core-components/src/components/Toast/index.js +1 -2
- package/lib/src/core-components/src/components/Toast/types.js +1 -9
- package/lib/src/core-components/src/components/Tooltip/Tooltip.js +1 -200
- package/lib/src/core-components/src/components/Tooltip/elements.js +55 -117
- package/lib/src/core-components/src/components/Tooltip/index.js +1 -2
- package/lib/src/core-components/src/components/Tooltip/types.js +1 -17
- package/lib/src/core-components/src/components/Tooltip/utils.js +1 -140
- package/lib/src/core-components/src/components/TreeSelect/TreeSelect.js +1 -303
- package/lib/src/core-components/src/components/TreeSelect/elements.js +117 -216
- package/lib/src/core-components/src/components/TreeSelect/hooks.js +1 -252
- package/lib/src/core-components/src/components/TreeSelect/index.js +1 -3
- package/lib/src/core-components/src/components/TreeSelect/types.js +1 -1
- package/lib/src/core-components/src/components/ag-grid/AgGrid.js +1 -1057
- package/lib/src/core-components/src/components/ag-grid/elements.js +396 -790
- package/lib/src/core-components/src/components/ag-grid/hooks.js +4 -1220
- package/lib/src/core-components/src/components/ag-grid/index.js +1 -15
- package/lib/src/core-components/src/components/ag-grid/types.js +1 -6
- package/lib/src/core-components/src/components/index.js +1 -31
- package/lib/src/core-components/src/components/pdf/pdf-images.components.js +1 -7
- package/lib/src/core-components/src/components/pdf/pdf-table.components.js +5 -48
- package/lib/src/core-components/src/components/pdf/pdf-typography.components.js +1 -70
- package/lib/src/core-components/src/components/pdf/pdf-wrapped-view.components.js +1 -50
- package/lib/src/core-components/src/core-components/Avatar.js +4 -33
- package/lib/src/core-components/src/core-components/CoreButton/CoreButton.js +1 -10
- package/lib/src/core-components/src/core-components/CoreButton/elements.js +67 -176
- package/lib/src/core-components/src/core-components/CoreButton/index.js +1 -3
- package/lib/src/core-components/src/core-components/CoreButton/types.js +1 -6
- package/lib/src/core-components/src/core-components/CoreButton/utils.js +1 -12
- package/lib/src/core-components/src/core-components/Divider/Divider.js +4 -19
- package/lib/src/core-components/src/core-components/Divider/index.js +1 -1
- package/lib/src/core-components/src/core-components/SelectionCardStrip/index.js +1 -1
- package/lib/src/core-components/src/core-components/SelectionCardStrip/selectionCardStrip.js +10 -33
- package/lib/src/core-components/src/core-components/StateLayer.js +3 -5
- package/lib/src/core-components/src/core-components/ToggleCore/elements.js +25 -50
- package/lib/src/core-components/src/core-components/ToggleCore/index.js +1 -2
- package/lib/src/core-components/src/core-components/ToggleCore/toggleCore.js +1 -14
- package/lib/src/core-components/src/core-components/atoms/Input/Input.js +1 -22
- package/lib/src/core-components/src/core-components/atoms/Label/Label.js +1 -21
- package/lib/src/core-components/src/core-components/atoms/Textarea/Textarea.js +1 -19
- package/lib/src/core-components/src/core-components/index.js +1 -3
- package/lib/src/core-components/src/helpers/constants.js +1 -11
- package/lib/src/core-components/src/hooks/index.js +1 -1
- package/lib/src/core-components/src/hooks/outside.hook.js +1 -28
- package/lib/src/core-components/src/index.js +1 -12
- package/lib/src/core-components/src/tc.global.css +1 -0
- package/lib/src/core-components/src/utils/abstracts/breakpoints/index.js +1 -28
- package/lib/src/core-components/src/utils/abstracts/colors/index.js +1 -49
- package/lib/src/core-components/src/utils/abstracts/index.js +1 -5
- package/lib/src/core-components/src/utils/abstracts/space/index.js +1 -26
- package/lib/src/core-components/src/utils/abstracts/theme/ThemeBoundary.js +1 -8
- package/lib/src/core-components/src/utils/abstracts/theme/default-themes.js +1 -30
- package/lib/src/core-components/src/utils/abstracts/theme/index.js +1 -3
- package/lib/src/core-components/src/utils/abstracts/theme/theme.js +1 -30
- package/lib/src/core-components/src/utils/abstracts/theme/types.js +1 -1
- package/lib/src/core-components/src/utils/abstracts/theme/useTheme.js +1 -17
- package/lib/src/core-components/src/utils/abstracts/typography/index.js +1 -25
- package/lib/src/core-components/src/utils/context/DefaultsProvider.js +1 -8
- package/lib/src/core-components/src/utils/context/InternalProvider.js +1 -24
- package/lib/src/core-components/src/utils/context/index.js +1 -2
- package/lib/src/core-components/src/utils/designTokens.js +1 -128
- package/lib/src/core-components/src/utils/helpers/attachSubComponents.js +1 -23
- package/lib/src/core-components/src/utils/helpers/flattenChildren.js +1 -11
- package/lib/src/core-components/src/utils/helpers/getChildByType.js +1 -3
- package/lib/src/core-components/src/utils/helpers/index.js +1 -5
- package/lib/src/core-components/src/utils/helpers/isComponentType.js +1 -16
- package/lib/src/core-components/src/utils/helpers/separateChildrenByType.js +1 -12
- package/lib/src/core-components/src/utils/hooks/index.js +1 -18
- package/lib/src/core-components/src/utils/hooks/useClickOutside.js +1 -18
- package/lib/src/core-components/src/utils/hooks/useCombinedRefs.js +1 -17
- package/lib/src/core-components/src/utils/hooks/useDebouncedCallback.js +1 -12
- package/lib/src/core-components/src/utils/hooks/useDebouncedValue.js +1 -20
- package/lib/src/core-components/src/utils/hooks/useDeprecation.js +1 -40
- package/lib/src/core-components/src/utils/hooks/useDeviceDetect.js +1 -10
- package/lib/src/core-components/src/utils/hooks/useDeviceForm.js +1 -24
- package/lib/src/core-components/src/utils/hooks/useDisableBodyScroll.js +1 -16
- package/lib/src/core-components/src/utils/hooks/useHoverState.js +1 -36
- package/lib/src/core-components/src/utils/hooks/useId.js +1 -7
- package/lib/src/core-components/src/utils/hooks/useIsBrowser.js +1 -11
- package/lib/src/core-components/src/utils/hooks/useMediaQuery.js +1 -16
- package/lib/src/core-components/src/utils/hooks/useOverflow.js +1 -22
- package/lib/src/core-components/src/utils/hooks/useSafeLayoutEffect.js +1 -5
- package/lib/src/core-components/src/utils/hooks/useScrollingUp.js +1 -18
- package/lib/src/core-components/src/utils/hooks/useTrapFocus.js +1 -30
- package/lib/src/core-components/src/utils/hooks/useWindowDimensions.js +1 -23
- package/lib/src/core-components/src/utils/index.js +1 -9
- package/lib/src/core-components/src/utils/stories/Wrappers.js +8 -23
- package/lib/src/core-components/src/utils/stories/cleanProps.js +1 -5
- package/lib/src/core-components/src/utils/stories/index.js +1 -4
- package/lib/src/core-components/src/utils/stories/sleep.js +1 -4
- package/lib/src/core-components/src/utils/stories/view-ports.js +1 -50
- package/lib/src/core-components/src/utils/styling/calcWidthOfColumns.js +1 -5
- package/lib/src/core-components/src/utils/styling/createGridContainer.js +6 -12
- package/lib/src/core-components/src/utils/styling/createTransition.js +2 -7
- package/lib/src/core-components/src/utils/styling/forwardProps.js +1 -10
- package/lib/src/core-components/src/utils/styling/index.js +1 -5
- package/lib/src/core-components/src/utils/styling/pxToRem.js +1 -6
- package/lib/src/core-components/src/utils/testing/getComputedStyle.js +1 -3
- package/lib/src/core-components/src/utils/testing/index.js +1 -1
- package/lib/src/core-components/src/utils/utility.util.js +1 -14
- package/lib/src/core-components/tailwind.config.js +1 -233
- package/lib/src/core-hooks/index.js +1 -3
- package/lib/src/core-hooks/src/useClickOutside/useClickOutside.hook.js +1 -46
- package/lib/src/core-hooks/src/useDebounce/useDebounce.hook.js +1 -30
- package/lib/src/core-hooks/src/usePreventEKey/usePreventEKey.hook.js +1 -8
- package/lib/src/core-utils/index.js +1 -7
- package/lib/src/core-utils/src/calculation/calculation.util.js +1 -89
- package/lib/src/core-utils/src/colors/color.util.js +1 -15
- package/lib/src/core-utils/src/convert/numberToWords/numToWords.util.js +1 -145
- package/lib/src/core-utils/src/convert/typography/camelCaseToTitleCase.util.js +1 -5
- package/lib/src/core-utils/src/form-helper/form-helper.util.js +1 -82
- package/lib/src/core-utils/src/index.js +1 -7
- package/lib/src/core-utils/src/utility/utility.util.js +1 -12
- package/lib/src/core-utils/src/uuid/uuid.util.js +1 -8
- package/package.json +1 -1
|
@@ -1,126 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const sizeConfig = {
|
|
5
|
-
small: {
|
|
6
|
-
height: '24px',
|
|
7
|
-
padding: '0 8px',
|
|
8
|
-
fontSize: '0.75rem',
|
|
9
|
-
iconSize: '14px',
|
|
10
|
-
gap: '4px',
|
|
11
|
-
borderRadius: '12px',
|
|
12
|
-
},
|
|
13
|
-
medium: {
|
|
14
|
-
height: '32px',
|
|
15
|
-
padding: '0 12px',
|
|
16
|
-
fontSize: '0.8125rem',
|
|
17
|
-
iconSize: '16px',
|
|
18
|
-
gap: '6px',
|
|
19
|
-
borderRadius: '16px',
|
|
20
|
-
},
|
|
21
|
-
large: {
|
|
22
|
-
height: '40px',
|
|
23
|
-
padding: '0 16px',
|
|
24
|
-
fontSize: '0.875rem',
|
|
25
|
-
iconSize: '18px',
|
|
26
|
-
gap: '8px',
|
|
27
|
-
borderRadius: '20px',
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
// Color configurations
|
|
31
|
-
const colorConfig = {
|
|
32
|
-
default: {
|
|
33
|
-
filled: { bg: tokens.onSurface || '#1a1a2e', text: '#fff', hover: '#2d2d42' },
|
|
34
|
-
outlined: {
|
|
35
|
-
border: tokens.outline || '#d1d5db',
|
|
36
|
-
text: tokens.onSurface || '#1a1a2e',
|
|
37
|
-
hover: '#f3f4f6',
|
|
38
|
-
},
|
|
39
|
-
soft: {
|
|
40
|
-
bg: tokens.surface || '#f3f4f6',
|
|
41
|
-
text: tokens.onSurface || '#1a1a2e',
|
|
42
|
-
hover: '#e5e7eb',
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
primary: {
|
|
46
|
-
filled: { bg: tokens.primary || '#454cbf', text: '#fff', hover: '#3d44a5' },
|
|
47
|
-
outlined: {
|
|
48
|
-
border: tokens.primary || '#454cbf',
|
|
49
|
-
text: tokens.primary || '#454cbf',
|
|
50
|
-
hover: '#e7e8f8',
|
|
51
|
-
},
|
|
52
|
-
soft: { bg: '#e7e8f8', text: tokens.primary || '#454cbf', hover: '#d4d6f4' },
|
|
53
|
-
},
|
|
54
|
-
success: {
|
|
55
|
-
filled: { bg: '#10b981', text: '#fff', hover: '#059669' },
|
|
56
|
-
outlined: { border: '#10b981', text: '#10b981', hover: '#ecfdf5' },
|
|
57
|
-
soft: { bg: '#ecfdf5', text: '#065f46', hover: '#d1fae5' },
|
|
58
|
-
},
|
|
59
|
-
warning: {
|
|
60
|
-
filled: { bg: '#f59e0b', text: '#fff', hover: '#d97706' },
|
|
61
|
-
outlined: { border: '#f59e0b', text: '#f59e0b', hover: '#fffbeb' },
|
|
62
|
-
soft: { bg: '#fffbeb', text: '#92400e', hover: '#fef3c7' },
|
|
63
|
-
},
|
|
64
|
-
error: {
|
|
65
|
-
filled: { bg: '#ef4444', text: '#fff', hover: '#dc2626' },
|
|
66
|
-
outlined: { border: '#ef4444', text: '#ef4444', hover: '#fef2f2' },
|
|
67
|
-
soft: { bg: '#fef2f2', text: '#991b1b', hover: '#fee2e2' },
|
|
68
|
-
},
|
|
69
|
-
info: {
|
|
70
|
-
filled: { bg: '#3b82f6', text: '#fff', hover: '#2563eb' },
|
|
71
|
-
outlined: { border: '#3b82f6', text: '#3b82f6', hover: '#e7f3ff' },
|
|
72
|
-
soft: { bg: '#e7f3ff', text: '#1e40af', hover: '#dbeafe' },
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
const getVariantStyles = (variant, color, selected) => {
|
|
76
|
-
const colorSet = colorConfig[color];
|
|
77
|
-
if (variant === 'filled') {
|
|
78
|
-
const config = colorSet.filled;
|
|
79
|
-
return css `
|
|
80
|
-
background: ${selected ? config.hover : config.bg};
|
|
81
|
-
color: ${config.text};
|
|
1
|
+
"use strict";import{styled as a,css as i}from"styled-components";import{tokens as t}from"../../utils/designTokens";const f={small:{height:"24px",padding:"0 8px",fontSize:"0.75rem",iconSize:"14px",gap:"4px",borderRadius:"12px"},medium:{height:"32px",padding:"0 12px",fontSize:"0.8125rem",iconSize:"16px",gap:"6px",borderRadius:"16px"},large:{height:"40px",padding:"0 16px",fontSize:"0.875rem",iconSize:"18px",gap:"8px",borderRadius:"20px"}},s={default:{filled:{bg:t.onSurface||"#1a1a2e",text:"#fff",hover:"#2d2d42"},outlined:{border:t.outline||"#d1d5db",text:t.onSurface||"#1a1a2e",hover:"#f3f4f6"},soft:{bg:t.surface||"#f3f4f6",text:t.onSurface||"#1a1a2e",hover:"#e5e7eb"}},primary:{filled:{bg:t.primary||"#454cbf",text:"#fff",hover:"#3d44a5"},outlined:{border:t.primary||"#454cbf",text:t.primary||"#454cbf",hover:"#e7e8f8"},soft:{bg:"#e7e8f8",text:t.primary||"#454cbf",hover:"#d4d6f4"}},success:{filled:{bg:"#10b981",text:"#fff",hover:"#059669"},outlined:{border:"#10b981",text:"#10b981",hover:"#ecfdf5"},soft:{bg:"#ecfdf5",text:"#065f46",hover:"#d1fae5"}},warning:{filled:{bg:"#f59e0b",text:"#fff",hover:"#d97706"},outlined:{border:"#f59e0b",text:"#f59e0b",hover:"#fffbeb"},soft:{bg:"#fffbeb",text:"#92400e",hover:"#fef3c7"}},error:{filled:{bg:"#ef4444",text:"#fff",hover:"#dc2626"},outlined:{border:"#ef4444",text:"#ef4444",hover:"#fef2f2"},soft:{bg:"#fef2f2",text:"#991b1b",hover:"#fee2e2"}},info:{filled:{bg:"#3b82f6",text:"#fff",hover:"#2563eb"},outlined:{border:"#3b82f6",text:"#3b82f6",hover:"#e7f3ff"},soft:{bg:"#e7f3ff",text:"#1e40af",hover:"#dbeafe"}}},p=(e,r,n)=>{const d=s[r];if(e==="filled"){const o=d.filled;return i`
|
|
2
|
+
background: ${n?o.hover:o.bg};
|
|
3
|
+
color: ${o.text};
|
|
82
4
|
border: 2px solid transparent;
|
|
83
5
|
|
|
84
6
|
&:hover:not(:disabled) {
|
|
85
|
-
background: ${
|
|
7
|
+
background: ${o.hover};
|
|
86
8
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return css `
|
|
92
|
-
background: ${selected ? config.hover : 'transparent'};
|
|
93
|
-
color: ${config.text};
|
|
94
|
-
border: 2px solid ${config.border};
|
|
9
|
+
`}if(e==="outlined"){const o=d.outlined;return i`
|
|
10
|
+
background: ${n?o.hover:"transparent"};
|
|
11
|
+
color: ${o.text};
|
|
12
|
+
border: 2px solid ${o.border};
|
|
95
13
|
|
|
96
14
|
&:hover:not(:disabled) {
|
|
97
|
-
background: ${
|
|
15
|
+
background: ${o.hover};
|
|
98
16
|
}
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const config = colorSet.soft;
|
|
103
|
-
return css `
|
|
104
|
-
background: ${selected ? config.hover : config.bg};
|
|
105
|
-
color: ${config.text};
|
|
17
|
+
`}const l=d.soft;return i`
|
|
18
|
+
background: ${n?l.hover:l.bg};
|
|
19
|
+
color: ${l.text};
|
|
106
20
|
border: 2px solid transparent;
|
|
107
21
|
|
|
108
22
|
&:hover:not(:disabled) {
|
|
109
|
-
background: ${
|
|
23
|
+
background: ${l.hover};
|
|
110
24
|
}
|
|
111
|
-
|
|
112
|
-
};
|
|
113
|
-
export const ChipElement = styled.button `
|
|
25
|
+
`};export const ChipElement=a.button`
|
|
114
26
|
display: inline-flex;
|
|
115
27
|
align-items: center;
|
|
116
28
|
justify-content: center;
|
|
117
|
-
gap: ${({
|
|
118
|
-
height: ${({
|
|
119
|
-
padding: ${({
|
|
120
|
-
font-size: ${({
|
|
29
|
+
gap: ${({$size:e})=>f[e].gap};
|
|
30
|
+
height: ${({$size:e})=>f[e].height};
|
|
31
|
+
padding: ${({$size:e})=>f[e].padding};
|
|
32
|
+
font-size: ${({$size:e})=>f[e].fontSize};
|
|
121
33
|
font-weight: 500;
|
|
122
34
|
font-family: inherit;
|
|
123
|
-
border-radius: ${({
|
|
35
|
+
border-radius: ${({$size:e})=>f[e].borderRadius};
|
|
124
36
|
cursor: pointer;
|
|
125
37
|
transition: all 0.2s ease;
|
|
126
38
|
white-space: nowrap;
|
|
@@ -129,19 +41,16 @@ export const ChipElement = styled.button `
|
|
|
129
41
|
position: relative;
|
|
130
42
|
overflow: hidden;
|
|
131
43
|
|
|
132
|
-
${({
|
|
44
|
+
${({$variant:e,$color:r,$selected:n})=>p(e,r,n)}
|
|
133
45
|
|
|
134
46
|
/* Selected state visual indicator */
|
|
135
|
-
${({
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
border-color: ${colorConfig[$color].outlined.text};
|
|
139
|
-
box-shadow: 0 0 0 1px ${colorConfig[$color].outlined.text};
|
|
47
|
+
${({$selected:e,$color:r,$variant:n})=>e&&n==="outlined"&&i`
|
|
48
|
+
border-color: ${s[r].outlined.text};
|
|
49
|
+
box-shadow: 0 0 0 1px ${s[r].outlined.text};
|
|
140
50
|
`}
|
|
141
51
|
|
|
142
52
|
/* Disabled state */
|
|
143
|
-
${({
|
|
144
|
-
css `
|
|
53
|
+
${({$disabled:e})=>e&&i`
|
|
145
54
|
opacity: 0.5;
|
|
146
55
|
cursor: not-allowed;
|
|
147
56
|
`}
|
|
@@ -149,28 +58,25 @@ export const ChipElement = styled.button `
|
|
|
149
58
|
/* Focus visible */
|
|
150
59
|
&:focus-visible {
|
|
151
60
|
box-shadow:
|
|
152
|
-
0 0 0 2px ${
|
|
153
|
-
0 0 0 4px ${
|
|
61
|
+
0 0 0 2px ${t.surface||"#fff"},
|
|
62
|
+
0 0 0 4px ${t.primary||"#454cbf"};
|
|
154
63
|
}
|
|
155
64
|
|
|
156
65
|
/* Active state */
|
|
157
66
|
&:active:not(:disabled) {
|
|
158
67
|
transform: scale(0.97);
|
|
159
68
|
}
|
|
160
|
-
|
|
161
|
-
export const IconWrapper = styled.span `
|
|
69
|
+
`,IconWrapper=a.span`
|
|
162
70
|
display: flex;
|
|
163
71
|
align-items: center;
|
|
164
72
|
justify-content: center;
|
|
165
73
|
flex-shrink: 0;
|
|
166
|
-
width: ${({
|
|
167
|
-
height: ${({
|
|
74
|
+
width: ${({$size:e})=>f[e].iconSize};
|
|
75
|
+
height: ${({$size:e})=>f[e].iconSize};
|
|
168
76
|
|
|
169
|
-
${({
|
|
170
|
-
? css `
|
|
77
|
+
${({$side:e})=>e==="left"?i`
|
|
171
78
|
margin-left: -2px;
|
|
172
|
-
`
|
|
173
|
-
: css `
|
|
79
|
+
`:i`
|
|
174
80
|
margin-right: -2px;
|
|
175
81
|
`}
|
|
176
82
|
|
|
@@ -178,31 +84,29 @@ export const IconWrapper = styled.span `
|
|
|
178
84
|
width: 100%;
|
|
179
85
|
height: 100%;
|
|
180
86
|
}
|
|
181
|
-
|
|
182
|
-
export const AvatarWrapper = styled.span `
|
|
87
|
+
`,AvatarWrapper=a.span`
|
|
183
88
|
display: flex;
|
|
184
89
|
align-items: center;
|
|
185
90
|
justify-content: center;
|
|
186
91
|
flex-shrink: 0;
|
|
187
|
-
width: ${({
|
|
188
|
-
height: ${({
|
|
92
|
+
width: ${({$size:e})=>e==="small"?"18px":e==="large"?"28px":"24px"};
|
|
93
|
+
height: ${({$size:e})=>e==="small"?"18px":e==="large"?"28px":"24px"};
|
|
189
94
|
border-radius: 50%;
|
|
190
95
|
overflow: hidden;
|
|
191
|
-
margin-left: ${({
|
|
96
|
+
margin-left: ${({$size:e})=>e==="small"?"-4px":e==="large"?"-10px":"-6px"};
|
|
192
97
|
|
|
193
98
|
img {
|
|
194
99
|
width: 100%;
|
|
195
100
|
height: 100%;
|
|
196
101
|
object-fit: cover;
|
|
197
102
|
}
|
|
198
|
-
|
|
199
|
-
export const DeleteButton = styled.span `
|
|
103
|
+
`,DeleteButton=a.span`
|
|
200
104
|
display: flex;
|
|
201
105
|
align-items: center;
|
|
202
106
|
justify-content: center;
|
|
203
107
|
flex-shrink: 0;
|
|
204
|
-
width: ${({
|
|
205
|
-
height: ${({
|
|
108
|
+
width: ${({$size:e})=>e==="small"?"14px":e==="large"?"18px":"16px"};
|
|
109
|
+
height: ${({$size:e})=>e==="small"?"14px":e==="large"?"18px":"16px"};
|
|
206
110
|
border-radius: 50%;
|
|
207
111
|
margin-right: -4px;
|
|
208
112
|
transition: all 0.2s ease;
|
|
@@ -215,25 +119,21 @@ export const DeleteButton = styled.span `
|
|
|
215
119
|
width: 100%;
|
|
216
120
|
height: 100%;
|
|
217
121
|
}
|
|
218
|
-
|
|
219
|
-
export const ChipLabel = styled.span `
|
|
122
|
+
`,ChipLabel=a.span`
|
|
220
123
|
line-height: 1;
|
|
221
|
-
|
|
222
|
-
export const ChipGroupElement = styled.div `
|
|
124
|
+
`,ChipGroupElement=a.div`
|
|
223
125
|
display: flex;
|
|
224
|
-
flex-direction: ${({
|
|
225
|
-
gap: ${({
|
|
126
|
+
flex-direction: ${({$direction:e})=>e};
|
|
127
|
+
gap: ${({$gap:e})=>e};
|
|
226
128
|
|
|
227
|
-
${({
|
|
228
|
-
css `
|
|
129
|
+
${({$wrap:e})=>e&&i`
|
|
229
130
|
flex-wrap: wrap;
|
|
230
131
|
`}
|
|
231
132
|
|
|
232
|
-
${({
|
|
233
|
-
|
|
234
|
-
overflow-
|
|
235
|
-
|
|
236
|
-
padding-bottom: ${$direction === 'row' ? '4px' : '0'};
|
|
133
|
+
${({$scrollable:e,$direction:r})=>e&&i`
|
|
134
|
+
overflow-x: ${r==="row"?"auto":"visible"};
|
|
135
|
+
overflow-y: ${r==="column"?"auto":"visible"};
|
|
136
|
+
padding-bottom: ${r==="row"?"4px":"0"};
|
|
237
137
|
|
|
238
138
|
/* Custom scrollbar */
|
|
239
139
|
&::-webkit-scrollbar {
|
|
@@ -246,7 +146,7 @@ export const ChipGroupElement = styled.div `
|
|
|
246
146
|
}
|
|
247
147
|
|
|
248
148
|
&::-webkit-scrollbar-thumb {
|
|
249
|
-
background: ${
|
|
149
|
+
background: ${t.outline||"#d1d5db"};
|
|
250
150
|
border-radius: 2px;
|
|
251
151
|
}
|
|
252
152
|
`}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './types';
|
|
1
|
+
"use strict";export{Chip,ChipGroup}from"./Chip";export*from"./types";
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
export const CHIP_VARIANTS
|
|
2
|
-
export const CHIP_SIZES = ['small', 'medium', 'large'];
|
|
3
|
-
export const CHIP_COLORS = ['default', 'primary', 'success', 'warning', 'error', 'info'];
|
|
4
|
-
export const CHIP_TYPES = ['button', 'selection', 'filter', 'input'];
|
|
1
|
+
"use strict";export const CHIP_VARIANTS=["filled","outlined","soft"],CHIP_SIZES=["small","medium","large"],CHIP_COLORS=["default","primary","success","warning","error","info"],CHIP_TYPES=["button","selection","filter","input"];
|
|
@@ -1,25 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef } from 'react';
|
|
4
|
-
import { DividerContainer, DividerLine, DividerLabel } from './elements';
|
|
5
|
-
export const Divider = forwardRef(function DividerComponent(props, ref) {
|
|
6
|
-
const { orientation = 'horizontal', variant = 'solid', size = 'thin', color = 'default', inset = '0', centerInset = false, label, labelPosition = 'center', className, ...rest } = props;
|
|
7
|
-
const hasLabel = Boolean(label);
|
|
8
|
-
// Calculate flex values for label positioning
|
|
9
|
-
const getFlexValues = () => {
|
|
10
|
-
if (!hasLabel)
|
|
11
|
-
return { start: 1, end: 0 };
|
|
12
|
-
switch (labelPosition) {
|
|
13
|
-
case 'start':
|
|
14
|
-
return { start: 0, end: 1 };
|
|
15
|
-
case 'end':
|
|
16
|
-
return { start: 1, end: 0 };
|
|
17
|
-
case 'center':
|
|
18
|
-
default:
|
|
19
|
-
return { start: 1, end: 1 };
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
const flexValues = getFlexValues();
|
|
23
|
-
return (_jsxs(DividerContainer, { ref: ref, "$orientation": orientation, "$variant": variant, "$size": size, "$color": color, "$inset": inset, "$centerInset": centerInset, "$hasLabel": hasLabel, role: "separator", "aria-orientation": orientation, "data-aui": "divider", className: className, ...rest, children: [flexValues.start > 0 && (_jsx(DividerLine, { "$orientation": orientation, "$variant": variant, "$size": size, "$color": color, "$flex": flexValues.start })), hasLabel && (_jsx(DividerLabel, { "$color": color, children: label })), flexValues.end > 0 && (_jsx(DividerLine, { "$orientation": orientation, "$variant": variant, "$size": size, "$color": color, "$flex": flexValues.end }))] }));
|
|
24
|
-
});
|
|
25
|
-
Divider.displayName = 'Divider';
|
|
1
|
+
"use strict";"use client";import{jsx as s,jsxs as x}from"react/jsx-runtime";import{forwardRef as h}from"react";import{DividerContainer as p,DividerLine as l,DividerLabel as D}from"./elements";export const Divider=h(function(c,d){const{orientation:e="horizontal",variant:a="solid",size:i="thin",color:t="default",inset:$="0",centerInset:f=!1,label:o,labelPosition:u="center",className:v,...m}=c,n=!!o,r=(()=>{if(!n)return{start:1,end:0};switch(u){case"start":return{start:0,end:1};case"end":return{start:1,end:0};default:return{start:1,end:1}}})();return x(p,{ref:d,$orientation:e,$variant:a,$size:i,$color:t,$inset:$,$centerInset:f,$hasLabel:n,role:"separator","aria-orientation":e,"data-aui":"divider",className:v,...m,children:[r.start>0&&s(l,{$orientation:e,$variant:a,$size:i,$color:t,$flex:r.start}),n&&s(D,{$color:t,children:o}),r.end>0&&s(l,{$orientation:e,$variant:a,$size:i,$color:t,$flex:r.end})]})});Divider.displayName="Divider";
|
|
@@ -1,103 +1,66 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { tokens } from '../../utils/designTokens';
|
|
3
|
-
// Size values
|
|
4
|
-
const sizeValues = {
|
|
5
|
-
thin: '1px',
|
|
6
|
-
medium: '2px',
|
|
7
|
-
thick: '4px',
|
|
8
|
-
};
|
|
9
|
-
// Color values
|
|
10
|
-
const colorValues = {
|
|
11
|
-
default: tokens.outline || '#e9ecef',
|
|
12
|
-
primary: tokens.primary || '#454cbf',
|
|
13
|
-
subtle: tokens.outlineSoft || '#f1f3f5',
|
|
14
|
-
dark: '#374151',
|
|
15
|
-
};
|
|
16
|
-
export const DividerContainer = styled.div `
|
|
1
|
+
"use strict";import{styled as i,css as t}from"styled-components";import{tokens as n}from"../../utils/designTokens";const o={thin:"1px",medium:"2px",thick:"4px"},c={default:n.outline||"#e9ecef",primary:n.primary||"#454cbf",subtle:n.outlineSoft||"#f1f3f5",dark:"#374151"};export const DividerContainer=i.div`
|
|
17
2
|
display: flex;
|
|
18
3
|
align-items: center;
|
|
19
4
|
|
|
20
|
-
${({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
: `calc(100% - ${$inset})`};
|
|
25
|
-
margin-left: ${$inset};
|
|
26
|
-
${$centerInset && `margin-right: ${$inset};`}
|
|
5
|
+
${({$orientation:a,$inset:e,$centerInset:r})=>a==="horizontal"?t`
|
|
6
|
+
width: ${r?`calc(100% - (${e} * 2))`:`calc(100% - ${e})`};
|
|
7
|
+
margin-left: ${e};
|
|
8
|
+
${r&&`margin-right: ${e};`}
|
|
27
9
|
flex-direction: row;
|
|
28
|
-
`
|
|
29
|
-
: css `
|
|
10
|
+
`:t`
|
|
30
11
|
height: 100%;
|
|
31
|
-
margin-top: ${
|
|
32
|
-
${
|
|
12
|
+
margin-top: ${e};
|
|
13
|
+
${r&&`margin-bottom: ${e};`}
|
|
33
14
|
flex-direction: column;
|
|
34
15
|
`}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
flex: ${({ $flex }) => $flex ?? 1};
|
|
16
|
+
`,DividerLine=i.div`
|
|
17
|
+
flex: ${({$flex:a})=>a??1};
|
|
38
18
|
|
|
39
|
-
${({
|
|
40
|
-
|
|
41
|
-
height: ${sizeValues[$size]};
|
|
19
|
+
${({$orientation:a,$size:e,$variant:r,$color:d})=>a==="horizontal"?t`
|
|
20
|
+
height: ${o[e]};
|
|
42
21
|
width: 100%;
|
|
43
|
-
`
|
|
44
|
-
|
|
45
|
-
width: ${sizeValues[$size]};
|
|
22
|
+
`:t`
|
|
23
|
+
width: ${o[e]};
|
|
46
24
|
height: 100%;
|
|
47
25
|
`}
|
|
48
26
|
|
|
49
27
|
/* Variant styles */
|
|
50
|
-
${({
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
case 'solid':
|
|
54
|
-
return css `
|
|
55
|
-
background-color: ${colorValue};
|
|
56
|
-
`;
|
|
57
|
-
case 'dashed':
|
|
58
|
-
return css `
|
|
28
|
+
${({$variant:a,$color:e})=>{const r=c[e];switch(a){case"solid":return t`
|
|
29
|
+
background-color: ${r};
|
|
30
|
+
`;case"dashed":return t`
|
|
59
31
|
background-image: repeating-linear-gradient(
|
|
60
32
|
90deg,
|
|
61
|
-
${
|
|
62
|
-
${
|
|
33
|
+
${r},
|
|
34
|
+
${r} 8px,
|
|
63
35
|
transparent 8px,
|
|
64
36
|
transparent 16px
|
|
65
37
|
);
|
|
66
|
-
`;
|
|
67
|
-
case 'dotted':
|
|
68
|
-
return css `
|
|
38
|
+
`;case"dotted":return t`
|
|
69
39
|
background-image: repeating-linear-gradient(
|
|
70
40
|
90deg,
|
|
71
|
-
${
|
|
72
|
-
${
|
|
41
|
+
${r},
|
|
42
|
+
${r} 4px,
|
|
73
43
|
transparent 4px,
|
|
74
44
|
transparent 12px
|
|
75
45
|
);
|
|
76
|
-
`;
|
|
77
|
-
case 'gradient':
|
|
78
|
-
return css `
|
|
46
|
+
`;case"gradient":return t`
|
|
79
47
|
background: linear-gradient(
|
|
80
48
|
90deg,
|
|
81
49
|
transparent 0%,
|
|
82
|
-
${
|
|
83
|
-
${
|
|
50
|
+
${r} 20%,
|
|
51
|
+
${r} 80%,
|
|
84
52
|
transparent 100%
|
|
85
53
|
);
|
|
86
|
-
`;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
}}
|
|
93
|
-
`;
|
|
94
|
-
export const DividerLabel = styled.span `
|
|
95
|
-
padding: 0 ${tokens.spacing150 || '0.75rem'};
|
|
54
|
+
`;default:return t`
|
|
55
|
+
background-color: ${r};
|
|
56
|
+
`}}}
|
|
57
|
+
`,DividerLabel=i.span`
|
|
58
|
+
padding: 0 ${n.spacing150||"0.75rem"};
|
|
96
59
|
font-size: 0.75rem;
|
|
97
60
|
font-weight: 500;
|
|
98
61
|
text-transform: uppercase;
|
|
99
62
|
letter-spacing: 0.05em;
|
|
100
|
-
color: ${({
|
|
63
|
+
color: ${({$color:a})=>a==="dark"?"#9ca3af":n.onSurface?`${n.onSurface}80`:"#6c757d"};
|
|
101
64
|
white-space: nowrap;
|
|
102
65
|
flex-shrink: 0;
|
|
103
66
|
`;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './types';
|
|
1
|
+
"use strict";export{Divider}from"./Divider";export*from"./types";
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
export const DIVIDER_ORIENTATIONS
|
|
2
|
-
export const DIVIDER_VARIANTS = ['solid', 'dashed', 'dotted', 'gradient'];
|
|
3
|
-
export const DIVIDER_SIZES = ['thin', 'medium', 'thick'];
|
|
4
|
-
export const DIVIDER_COLORS = ['default', 'primary', 'subtle', 'dark'];
|
|
1
|
+
"use strict";export const DIVIDER_ORIENTATIONS=["horizontal","vertical"],DIVIDER_VARIANTS=["solid","dashed","dotted","gradient"],DIVIDER_SIZES=["thin","medium","thick"],DIVIDER_COLORS=["default","primary","subtle","dark"];
|
|
@@ -1,147 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import React, { Children, forwardRef, useMemo, useRef, useState, useCallback, createContext, useContext, } from 'react';
|
|
4
|
-
import { cn } from '../../utils';
|
|
5
|
-
import s from '../../tc.module.css';
|
|
6
|
-
import { GridWrapper, GridContainer, GridItem, SkeletonItem, EmptyState, ScrollArrow, ScrollDots, ScrollDot, } from './elements';
|
|
7
|
-
import { gapSizeValues, } from './types';
|
|
8
|
-
import { calcColumns, getGapValue, getResponsiveColumns, useWindowWidth, useElementResize, useScrollToKeyboardFocus, useScrollNavigation, getItemCount, } from './utils';
|
|
9
|
-
// Grid context for nested components
|
|
10
|
-
const GridContext = createContext(null);
|
|
11
|
-
export const useGridContext = () => useContext(GridContext);
|
|
12
|
-
// Arrow icons
|
|
13
|
-
const ChevronLeftIcon = () => (_jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: _jsx("polyline", { points: "15 18 9 12 15 6" }) }));
|
|
14
|
-
const ChevronRightIcon = () => (_jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: _jsx("polyline", { points: "9 18 15 12 9 6" }) }));
|
|
15
|
-
// Empty icon
|
|
16
|
-
const EmptyIcon = () => (_jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }), _jsx("line", { x1: "9", y1: "9", x2: "15", y2: "15" }), _jsx("line", { x1: "15", y1: "9", x2: "9", y2: "15" })] }));
|
|
17
|
-
// Default empty state
|
|
18
|
-
const DefaultEmptyState = () => (_jsxs(EmptyState, { children: [_jsx(EmptyIcon, {}), _jsx("p", { className: cn(s['text-gray-500'], s['text-sm']), children: "No items to display" })] }));
|
|
19
|
-
// Default skeleton renderer
|
|
20
|
-
const DefaultSkeleton = ({ aspectRatio }) => (_jsx(SkeletonItem, { "$aspectRatio": aspectRatio }));
|
|
21
|
-
export const DynamicGrid = forwardRef(function DynamicGridComponent(props, fRef) {
|
|
22
|
-
const { children,
|
|
23
|
-
// Layout
|
|
24
|
-
minWidth = 10, maxWidth, columns: fixedColumns, responsiveColumns, maxColumns = Infinity, maxRows, autoFit = false, modulo = 1,
|
|
25
|
-
// Spacing
|
|
26
|
-
gap = 'md', rowGap, columnGap,
|
|
27
|
-
// Styling
|
|
28
|
-
variant = 'default', alignItems, justifyItems, alignContent, justifyContent,
|
|
29
|
-
// Scroll
|
|
30
|
-
scroll, scrollEnabled,
|
|
31
|
-
// Animation
|
|
32
|
-
animation,
|
|
33
|
-
// Item config
|
|
34
|
-
itemConfig,
|
|
35
|
-
// Accessibility
|
|
36
|
-
role = 'none', elementRole, ariaLabel,
|
|
37
|
-
// State
|
|
38
|
-
isLoading = false, skeletonCount = 6, renderSkeleton, emptyState,
|
|
39
|
-
// Events
|
|
40
|
-
onLayoutChange, onScrollChange,
|
|
41
|
-
// Styling
|
|
42
|
-
className, style, containerClassName, itemClassName, ...rest } = props;
|
|
43
|
-
const innerRef = useRef(null);
|
|
44
|
-
const gridRef = useRef(null);
|
|
45
|
-
const [elementWidth, setElementWidth] = useState(0);
|
|
46
|
-
const windowWidth = useWindowWidth();
|
|
47
|
-
// Merge scroll config
|
|
48
|
-
const scrollConfig = useMemo(() => scroll?.enabled || scrollEnabled
|
|
49
|
-
? {
|
|
50
|
-
enabled: true,
|
|
51
|
-
scrollHint: scroll?.scrollHint ?? 0.5,
|
|
52
|
-
hideScrollbar: scroll?.hideScrollbar ?? false,
|
|
53
|
-
scrollSnapAlign: scroll?.scrollSnapAlign ?? 'start',
|
|
54
|
-
smoothScroll: scroll?.smoothScroll ?? true,
|
|
55
|
-
showArrows: scroll?.showArrows ?? true,
|
|
56
|
-
showDots: scroll?.showDots ?? false,
|
|
57
|
-
...scroll,
|
|
58
|
-
}
|
|
59
|
-
: undefined, [scroll, scrollEnabled]);
|
|
60
|
-
// Handle element resize
|
|
61
|
-
const handleResize = useCallback((width) => {
|
|
62
|
-
setElementWidth(width);
|
|
63
|
-
}, []);
|
|
64
|
-
useElementResize(innerRef, handleResize);
|
|
65
|
-
// Calculate columns
|
|
66
|
-
const calculatedColumns = useMemo(() => {
|
|
67
|
-
// Use fixed columns if provided
|
|
68
|
-
if (fixedColumns)
|
|
69
|
-
return fixedColumns;
|
|
70
|
-
// Use responsive columns if provided
|
|
71
|
-
if (responsiveColumns) {
|
|
72
|
-
return getResponsiveColumns(responsiveColumns, windowWidth);
|
|
73
|
-
}
|
|
74
|
-
// Calculate based on container width
|
|
75
|
-
const gapValue = getGapValue(gap);
|
|
76
|
-
return calcColumns({
|
|
77
|
-
minWidth,
|
|
78
|
-
elementWidth,
|
|
79
|
-
gap: gapValue,
|
|
80
|
-
modulo,
|
|
81
|
-
maxColumns,
|
|
82
|
-
scrollHint: scrollConfig?.scrollHint,
|
|
83
|
-
});
|
|
84
|
-
}, [
|
|
85
|
-
fixedColumns,
|
|
86
|
-
responsiveColumns,
|
|
87
|
-
windowWidth,
|
|
88
|
-
minWidth,
|
|
89
|
-
elementWidth,
|
|
90
|
-
gap,
|
|
91
|
-
modulo,
|
|
92
|
-
maxColumns,
|
|
93
|
-
scrollConfig?.scrollHint,
|
|
94
|
-
]);
|
|
95
|
-
// Handle keyboard focus scroll
|
|
96
|
-
useScrollToKeyboardFocus(gridRef, scrollConfig);
|
|
97
|
-
// Scroll navigation
|
|
98
|
-
const itemCount = getItemCount(children);
|
|
99
|
-
const scrollNav = useScrollNavigation(gridRef, itemCount, calculatedColumns);
|
|
100
|
-
// Notify layout changes
|
|
101
|
-
React.useEffect(() => {
|
|
102
|
-
if (onLayoutChange) {
|
|
103
|
-
const rows = Math.ceil(itemCount / calculatedColumns);
|
|
104
|
-
onLayoutChange(calculatedColumns, rows);
|
|
105
|
-
}
|
|
106
|
-
}, [calculatedColumns, itemCount, onLayoutChange]);
|
|
107
|
-
// Get gap values
|
|
108
|
-
const gapValue = getGapValue(gap);
|
|
109
|
-
const rowGapValue = rowGap ? gapSizeValues[rowGap] : undefined;
|
|
110
|
-
const columnGapValue = columnGap ? gapSizeValues[columnGap] : undefined;
|
|
111
|
-
// Process children
|
|
112
|
-
const processedChildren = useMemo(() => {
|
|
113
|
-
const childArray = Children.toArray(children);
|
|
114
|
-
return childArray.map((child, index) => (_jsx(GridItem, { "$animation": animation, "$animationIndex": index, "$borderRadius": itemConfig?.borderRadius, "$padding": itemConfig?.padding, "$aspectRatio": itemConfig?.aspectRatio, className: itemClassName, children: child }, index)));
|
|
115
|
-
}, [children, animation, itemConfig, itemClassName]);
|
|
116
|
-
// Render as list items if role is list
|
|
117
|
-
const gridRole = role || elementRole || 'none';
|
|
118
|
-
const renderChildren = useMemo(() => {
|
|
119
|
-
if (gridRole === 'list') {
|
|
120
|
-
return processedChildren.map((child, index) => (_jsx("li", { style: { display: 'contents' }, children: child }, index)));
|
|
121
|
-
}
|
|
122
|
-
return processedChildren;
|
|
123
|
-
}, [processedChildren, gridRole]);
|
|
124
|
-
// Render skeletons
|
|
125
|
-
const skeletons = useMemo(() => {
|
|
126
|
-
if (!isLoading)
|
|
127
|
-
return null;
|
|
128
|
-
return Array.from({ length: skeletonCount }, (_, index) => (_jsx(GridItem, { "$animation": { enabled: true, type: 'fade', duration: 200 }, "$animationIndex": index, "$borderRadius": itemConfig?.borderRadius, "$aspectRatio": itemConfig?.aspectRatio, children: renderSkeleton ? (renderSkeleton()) : (_jsx(DefaultSkeleton, { aspectRatio: itemConfig?.aspectRatio })) }, `skeleton-${index}`)));
|
|
129
|
-
}, [isLoading, skeletonCount, renderSkeleton, itemConfig]);
|
|
130
|
-
// Check if empty
|
|
131
|
-
const isEmpty = !isLoading && itemCount === 0;
|
|
132
|
-
// Grid context value
|
|
133
|
-
const contextValue = useMemo(() => ({
|
|
134
|
-
columns: calculatedColumns,
|
|
135
|
-
gap: gapValue,
|
|
136
|
-
variant,
|
|
137
|
-
itemConfig,
|
|
138
|
-
}), [calculatedColumns, gapValue, variant, itemConfig]);
|
|
139
|
-
return (_jsx(GridContext.Provider, { value: contextValue, children: _jsxs(GridWrapper, { ref: innerRef, "$variant": variant, className: cn(containerClassName, className), style: style, "data-aui": "dynamic-grid", ...rest, children: [_jsx(GridContainer, { ref: gridRef, as: gridRole === 'list' ? 'ul' : 'div', role: gridRole === 'grid' ? 'grid' : undefined, "aria-label": ariaLabel, "$columns": calculatedColumns, "$minWidth": minWidth, "$maxWidth": maxWidth, "$gap": gapValue, "$rowGap": rowGapValue, "$columnGap": columnGapValue, "$autoFit": autoFit, "$maxRows": maxRows, "$alignItems": alignItems, "$justifyItems": justifyItems, "$alignContent": alignContent, "$justifyContent": justifyContent, "$scroll": scrollConfig, "$animation": animation, "$variant": variant, children: isLoading ? skeletons : isEmpty ? null : renderChildren }), isEmpty && (emptyState || _jsx(DefaultEmptyState, {})), scrollConfig?.enabled && scrollConfig.showArrows && !isEmpty && (_jsxs(_Fragment, { children: [_jsx(ScrollArrow, { "$direction": "left", "$visible": scrollNav.canScrollLeft, onClick: scrollNav.scrollLeft, "aria-label": "Scroll left", disabled: !scrollNav.canScrollLeft, children: _jsx(ChevronLeftIcon, {}) }), _jsx(ScrollArrow, { "$direction": "right", "$visible": scrollNav.canScrollRight, onClick: scrollNav.scrollRight, "aria-label": "Scroll right", disabled: !scrollNav.canScrollRight, children: _jsx(ChevronRightIcon, {}) })] })), scrollConfig?.enabled && scrollConfig.showDots && !isEmpty && (_jsx(ScrollDots, { children: Array.from({ length: scrollNav.totalPages }, (_, index) => (_jsx(ScrollDot, { "$active": index === scrollNav.currentPage, onClick: () => scrollNav.scrollTo(index), "aria-label": `Go to page ${index + 1}` }, index))) }))] }) }));
|
|
140
|
-
});
|
|
141
|
-
// Grid Item component for advanced usage
|
|
142
|
-
export const DynamicGridItem = forwardRef(function DynamicGridItemComponent({ children, colSpan, rowSpan, order, alignSelf, justifySelf, className, ...rest }, ref) {
|
|
143
|
-
const gridContext = useGridContext();
|
|
144
|
-
return (_jsx(GridItem, { ref: ref, "$colSpan": colSpan, "$rowSpan": rowSpan, "$order": order, "$alignSelf": alignSelf, "$justifySelf": justifySelf, "$borderRadius": gridContext?.itemConfig?.borderRadius, "$padding": gridContext?.itemConfig?.padding, className: className, ...rest, children: children }));
|
|
145
|
-
});
|
|
146
|
-
DynamicGrid.displayName = 'DynamicGrid';
|
|
147
|
-
DynamicGridItem.displayName = 'DynamicGridItem';
|
|
1
|
+
"use strict";"use client";import{jsx as e,jsxs as R,Fragment as ye}from"react/jsx-runtime";import Ce,{Children as $e,forwardRef as T,useMemo as s,useRef as K,useState as Re,useCallback as Se,createContext as we,useContext as xe}from"react";import{cn as q}from"../../utils";import J from"../../tc.module.css";import{GridWrapper as be,GridContainer as ke,GridItem as j,SkeletonItem as ve,EmptyState as Ge,ScrollArrow as O,ScrollDots as Ie,ScrollDot as De}from"./elements";import{gapSizeValues as Q}from"./types";import{calcColumns as Le,getGapValue as U,getResponsiveColumns as We,useWindowWidth as je,useElementResize as Ne,useScrollToKeyboardFocus as Ae,useScrollNavigation as Ee,getItemCount as Ve}from"./utils";const X=we(null);export const useGridContext=()=>xe(X);const Fe=()=>e("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e("polyline",{points:"15 18 9 12 15 6"})}),He=()=>e("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e("polyline",{points:"9 18 15 12 9 6"})}),_e=()=>R("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e("line",{x1:"9",y1:"9",x2:"15",y2:"15"}),e("line",{x1:"15",y1:"9",x2:"9",y2:"15"})]}),ze=()=>R(Ge,{children:[e(_e,{}),e("p",{className:q(J["text-gray-500"],J["text-sm"]),children:"No items to display"})]}),Be=({aspectRatio:S})=>e(ve,{$aspectRatio:S});export const DynamicGrid=T(function(w,N){const{children:c,minWidth:d=10,maxWidth:x,columns:m,responsiveColumns:u,maxColumns:p=1/0,maxRows:b,autoFit:h=!1,modulo:A=1,gap:k="md",rowGap:E,columnGap:V,variant:f="default",alignItems:Y,justifyItems:Z,alignContent:ee,justifyContent:te,scroll:r,scrollEnabled:F,animation:v,itemConfig:o,role:oe="none",elementRole:ne,ariaLabel:re,isLoading:g=!1,skeletonCount:H=6,renderSkeleton:G,emptyState:ie,onLayoutChange:I,onScrollChange:Pe,className:le,style:ae,containerClassName:se,itemClassName:_,...ce}=w,z=K(null),D=K(null),[B,de]=Re(0),P=je(),l=s(()=>r?.enabled||F?{enabled:!0,scrollHint:r?.scrollHint??.5,hideScrollbar:r?.hideScrollbar??!1,scrollSnapAlign:r?.scrollSnapAlign??"start",smoothScroll:r?.smoothScroll??!0,showArrows:r?.showArrows??!0,showDots:r?.showDots??!1,...r}:void 0,[r,F]),me=Se(n=>{de(n)},[]);Ne(z,me);const a=s(()=>{if(m)return m;if(u)return We(u,P);const n=U(k);return Le({minWidth:d,elementWidth:B,gap:n,modulo:A,maxColumns:p,scrollHint:l?.scrollHint})},[m,u,P,d,B,k,A,p,l?.scrollHint]);Ae(D,l);const y=Ve(c),i=Ee(D,y,a);Ce.useEffect(()=>{if(I){const n=Math.ceil(y/a);I(a,n)}},[a,y,I]);const L=U(k),ue=E?Q[E]:void 0,pe=V?Q[V]:void 0,W=s(()=>$e.toArray(c).map((t,M)=>e(j,{$animation:v,$animationIndex:M,$borderRadius:o?.borderRadius,$padding:o?.padding,$aspectRatio:o?.aspectRatio,className:_,children:t},M)),[c,v,o,_]),C=oe||ne||"none",he=s(()=>C==="list"?W.map((n,t)=>e("li",{style:{display:"contents"},children:n},t)):W,[W,C]),fe=s(()=>g?Array.from({length:H},(n,t)=>e(j,{$animation:{enabled:!0,type:"fade",duration:200},$animationIndex:t,$borderRadius:o?.borderRadius,$aspectRatio:o?.aspectRatio,children:G?G():e(Be,{aspectRatio:o?.aspectRatio})},`skeleton-${t}`)):null,[g,H,G,o]),$=!g&&y===0,ge=s(()=>({columns:a,gap:L,variant:f,itemConfig:o}),[a,L,f,o]);return e(X.Provider,{value:ge,children:R(be,{ref:z,$variant:f,className:q(se,le),style:ae,"data-aui":"dynamic-grid",...ce,children:[e(ke,{ref:D,as:C==="list"?"ul":"div",role:C==="grid"?"grid":void 0,"aria-label":re,$columns:a,$minWidth:d,$maxWidth:x,$gap:L,$rowGap:ue,$columnGap:pe,$autoFit:h,$maxRows:b,$alignItems:Y,$justifyItems:Z,$alignContent:ee,$justifyContent:te,$scroll:l,$animation:v,$variant:f,children:g?fe:$?null:he}),$&&(ie||e(ze,{})),l?.enabled&&l.showArrows&&!$&&R(ye,{children:[e(O,{$direction:"left",$visible:i.canScrollLeft,onClick:i.scrollLeft,"aria-label":"Scroll left",disabled:!i.canScrollLeft,children:e(Fe,{})}),e(O,{$direction:"right",$visible:i.canScrollRight,onClick:i.scrollRight,"aria-label":"Scroll right",disabled:!i.canScrollRight,children:e(He,{})})]}),l?.enabled&&l.showDots&&!$&&e(Ie,{children:Array.from({length:i.totalPages},(n,t)=>e(De,{$active:t===i.currentPage,onClick:()=>i.scrollTo(t),"aria-label":`Go to page ${t+1}`},t))})]})})}),DynamicGridItem=T(function({children:w,colSpan:N,rowSpan:c,order:d,alignSelf:x,justifySelf:m,className:u,...p},b){const h=useGridContext();return e(j,{ref:b,$colSpan:N,$rowSpan:c,$order:d,$alignSelf:x,$justifySelf:m,$borderRadius:h?.itemConfig?.borderRadius,$padding:h?.itemConfig?.padding,className:u,...p,children:w})});DynamicGrid.displayName="DynamicGrid",DynamicGridItem.displayName="DynamicGridItem";
|