react-restyle-components 0.4.39 → 0.4.41
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 +3 -1
- package/lib/src/core-components/index.js +1 -1
- package/lib/src/core-components/src/components/Accordion/AccordionSection/Accordion.js +15 -1
- package/lib/src/core-components/src/components/Accordion/AccordionSection/AccordionContext.js +6 -1
- package/lib/src/core-components/src/components/Accordion/AccordionSection/AccordionSection.js +39 -1
- package/lib/src/core-components/src/components/Accordion/AccordionSection/Header.js +39 -1
- package/lib/src/core-components/src/components/Accordion/AccordionSection/elements.js +94 -57
- package/lib/src/core-components/src/components/Accordion/AccordionSection/hooks/useCurrentAccordionIndex.js +13 -1
- package/lib/src/core-components/src/components/Accordion/AccordionSection/index.js +3 -1
- package/lib/src/core-components/src/components/Accordion/AccordionSection/types.js +9 -1
- package/lib/src/core-components/src/components/Accordion/Collapsible/Collapsible2.component.js +249 -1
- package/lib/src/core-components/src/components/Action/types.js +8 -1
- package/lib/src/core-components/src/components/AlertBanner/AlertBanner.js +45 -1
- package/lib/src/core-components/src/components/AlertBanner/elements.js +120 -45
- package/lib/src/core-components/src/components/AlertBanner/index.js +2 -1
- package/lib/src/core-components/src/components/AlertBanner/types.js +10 -1
- 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 +334 -1
- 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 +229 -1
- 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 +174 -1
- 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 +129 -2
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-single-select/auto-complete-filter-single-select.component.js +55 -1
- 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 +308 -2
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-group-by/auto-complete-group-by.component.js +115 -1
- package/lib/src/core-components/src/components/AutoComplete/autocomplete/autocomplete.js +442 -2
- package/lib/src/core-components/src/components/AutoComplete/index.js +8 -1
- package/lib/src/core-components/src/components/Avatar/Avatar.js +148 -14
- package/lib/src/core-components/src/components/Badge/Badge.js +25 -2
- package/lib/src/core-components/src/components/Badge/InnerBadge/Inline.js +25 -1
- package/lib/src/core-components/src/components/Badge/InnerBadge/InnerBadge.js +25 -1
- package/lib/src/core-components/src/components/Badge/InnerBadge/elements.js +78 -32
- 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 +5 -1
- package/lib/src/core-components/src/components/Breadcrumb/Breadcrumb.js +83 -1
- package/lib/src/core-components/src/components/Breadcrumb/elements.js +166 -94
- package/lib/src/core-components/src/components/Breadcrumb/index.js +3 -1
- package/lib/src/core-components/src/components/Breadcrumb/types.js +3 -1
- package/lib/src/core-components/src/components/Button/button.component.js +18 -1
- package/lib/src/core-components/src/components/Button/buttonGroup/buttonGroup.component.js +4 -1
- package/lib/src/core-components/src/components/Button/index.js +2 -1
- package/lib/src/core-components/src/components/Button/types.js +1 -1
- package/lib/src/core-components/src/components/Chip/Chip.js +64 -1
- package/lib/src/core-components/src/components/Chip/elements.js +148 -48
- package/lib/src/core-components/src/components/Chip/index.js +2 -1
- package/lib/src/core-components/src/components/Chip/types.js +4 -1
- package/lib/src/core-components/src/components/Divider/Divider.js +25 -1
- package/lib/src/core-components/src/components/Divider/elements.js +68 -31
- package/lib/src/core-components/src/components/Divider/index.js +2 -1
- package/lib/src/core-components/src/components/Divider/types.js +4 -1
- package/lib/src/core-components/src/components/DynamicGrid/DynamicGrid.js +147 -1
- package/lib/src/core-components/src/components/DynamicGrid/GridContainer.js +24 -17
- package/lib/src/core-components/src/components/DynamicGrid/elements.js +162 -100
- package/lib/src/core-components/src/components/DynamicGrid/index.js +3 -1
- package/lib/src/core-components/src/components/DynamicGrid/types.js +28 -1
- package/lib/src/core-components/src/components/DynamicGrid/utils.js +193 -1
- package/lib/src/core-components/src/components/FormField/FormField.js +103 -1
- package/lib/src/core-components/src/components/FormField/components/CheckboxGroupInput.js +37 -1
- package/lib/src/core-components/src/components/FormField/components/CheckboxInput.js +8 -1
- package/lib/src/core-components/src/components/FormField/components/CssMultilineInput.js +192 -1
- package/lib/src/core-components/src/components/FormField/components/DatePickerInput.js +99 -1
- package/lib/src/core-components/src/components/FormField/components/DropdownInput.js +70 -1
- package/lib/src/core-components/src/components/FormField/components/OtpInput.js +81 -1
- package/lib/src/core-components/src/components/FormField/components/PasswordInput.js +40 -1
- package/lib/src/core-components/src/components/FormField/components/PinInput.js +75 -1
- package/lib/src/core-components/src/components/FormField/components/RadioInput.js +54 -1
- package/lib/src/core-components/src/components/FormField/components/TextDropdownInput.js +94 -1
- package/lib/src/core-components/src/components/FormField/components/ToggleInput.js +36 -1
- package/lib/src/core-components/src/components/FormField/components/index.js +11 -1
- package/lib/src/core-components/src/components/FormField/css-properties.js +161 -1
- package/lib/src/core-components/src/components/FormField/index.js +2 -1
- package/lib/src/core-components/src/components/Icon/Icon.js +79 -1
- package/lib/src/core-components/src/components/Icon/index.js +2 -1
- package/lib/src/core-components/src/components/Icon/types.js +9 -1
- package/lib/src/core-components/src/components/Loader/loader.component.js +215 -2
- package/lib/src/core-components/src/components/Masonry/Masonry.js +73 -1
- package/lib/src/core-components/src/components/Masonry/elements.js +46 -29
- package/lib/src/core-components/src/components/Masonry/hooks.js +100 -1
- package/lib/src/core-components/src/components/Masonry/index.js +3 -1
- package/lib/src/core-components/src/components/Masonry/types.js +1 -1
- package/lib/src/core-components/src/components/Modal/BasicModal/modal.component.js +116 -1
- package/lib/src/core-components/src/components/Modal/index.js +2 -1
- package/lib/src/core-components/src/components/Modal/modal-confirm/modal-confirm.component.js +147 -1
- package/lib/src/core-components/src/components/Picker/color-picker/color-picker.component.js +12 -1
- package/lib/src/core-components/src/components/Picker/color-picker-modal/color-picker-modal.component.js +40 -1
- package/lib/src/core-components/src/components/Picker/index.js +2 -1
- package/lib/src/core-components/src/components/Selection/index.js +4 -1
- package/lib/src/core-components/src/components/Selection/multi-select/multi-select.component.js +49 -1
- package/lib/src/core-components/src/components/Selection/multi-select-with-field/multi-select-with-field.component.js +58 -1
- package/lib/src/core-components/src/components/Selection/multi-selection-dropdown/multi-selection-dropdown.component.js +43 -1
- package/lib/src/core-components/src/components/Selection/single-select/single-select.component.js +87 -1
- package/lib/src/core-components/src/components/Skeleton/Skeleton.js +51 -1
- package/lib/src/core-components/src/components/Skeleton/elements.js +143 -54
- package/lib/src/core-components/src/components/Skeleton/index.js +2 -1
- package/lib/src/core-components/src/components/Skeleton/types.js +4 -1
- package/lib/src/core-components/src/components/SpeedDial/SpeedDial.js +128 -1
- package/lib/src/core-components/src/components/SpeedDial/elements.js +132 -62
- package/lib/src/core-components/src/components/SpeedDial/index.js +2 -1
- package/lib/src/core-components/src/components/SpeedDial/types.js +3 -1
- package/lib/src/core-components/src/components/Stepper2/stepper.component.js +139 -1
- package/lib/src/core-components/src/components/Switch/Switch.js +26 -1
- package/lib/src/core-components/src/components/Switch/elements.js +103 -34
- package/lib/src/core-components/src/components/Switch/index.js +2 -1
- package/lib/src/core-components/src/components/Switch/types.js +3 -1
- package/lib/src/core-components/src/components/Table/Table.js +1357 -1
- package/lib/src/core-components/src/components/Table/columnReorder.d.ts +128 -0
- package/lib/src/core-components/src/components/Table/columnReorder.js +530 -0
- package/lib/src/core-components/src/components/Table/columnResize.d.ts +99 -0
- package/lib/src/core-components/src/components/Table/columnResize.js +399 -0
- package/lib/src/core-components/src/components/Table/elements.d.ts +9 -1
- package/lib/src/core-components/src/components/Table/elements.js +324 -155
- package/lib/src/core-components/src/components/Table/filters.js +555 -30
- package/lib/src/core-components/src/components/Table/hooks.js +536 -2
- package/lib/src/core-components/src/components/Table/index.d.ts +4 -0
- package/lib/src/core-components/src/components/Table/index.js +6 -1
- package/lib/src/core-components/src/components/Table/types.d.ts +58 -0
- package/lib/src/core-components/src/components/Table/types.js +1 -1
- package/lib/src/core-components/src/components/Tabs/tabs.component.js +22 -1
- package/lib/src/core-components/src/components/Tags1/Tags.component.js +118 -1
- package/lib/src/core-components/src/components/Tags1/types.js +20 -1
- package/lib/src/core-components/src/components/Timer1/timer.component.js +76 -1
- package/lib/src/core-components/src/components/Toast/Toast.js +50 -1
- package/lib/src/core-components/src/components/Toast/elements.js +122 -41
- package/lib/src/core-components/src/components/Toast/index.js +2 -1
- package/lib/src/core-components/src/components/Toast/types.js +9 -1
- package/lib/src/core-components/src/components/Tooltip/Tooltip.js +200 -1
- package/lib/src/core-components/src/components/Tooltip/elements.js +117 -55
- package/lib/src/core-components/src/components/Tooltip/index.js +2 -1
- package/lib/src/core-components/src/components/Tooltip/types.js +17 -1
- package/lib/src/core-components/src/components/Tooltip/utils.js +140 -1
- package/lib/src/core-components/src/components/TreeSelect/TreeSelect.js +303 -1
- package/lib/src/core-components/src/components/TreeSelect/elements.js +216 -117
- package/lib/src/core-components/src/components/TreeSelect/hooks.js +252 -1
- package/lib/src/core-components/src/components/TreeSelect/index.js +3 -1
- package/lib/src/core-components/src/components/TreeSelect/types.js +1 -1
- package/lib/src/core-components/src/components/ag-grid/AgGrid.d.ts +11 -0
- package/lib/src/core-components/src/components/ag-grid/AgGrid.js +733 -0
- package/lib/src/core-components/src/components/ag-grid/elements.d.ts +246 -0
- package/lib/src/core-components/src/components/ag-grid/elements.js +1156 -0
- package/lib/src/core-components/src/components/ag-grid/hooks.d.ts +196 -0
- package/lib/src/core-components/src/components/ag-grid/hooks.js +943 -0
- package/lib/src/core-components/src/components/ag-grid/index.d.ts +9 -0
- package/lib/src/core-components/src/components/ag-grid/index.js +13 -0
- package/lib/src/core-components/src/components/ag-grid/types.d.ts +1367 -0
- package/lib/src/core-components/src/components/ag-grid/types.js +6 -0
- package/lib/src/core-components/src/components/index.d.ts +1 -0
- package/lib/src/core-components/src/components/index.js +31 -1
- package/lib/src/core-components/src/components/pdf/pdf-images.components.js +7 -1
- package/lib/src/core-components/src/components/pdf/pdf-table.components.js +48 -5
- package/lib/src/core-components/src/components/pdf/pdf-typography.components.js +70 -1
- package/lib/src/core-components/src/components/pdf/pdf-wrapped-view.components.js +50 -1
- package/lib/src/core-components/src/core-components/Avatar.js +33 -4
- package/lib/src/core-components/src/core-components/CoreButton/CoreButton.js +10 -1
- package/lib/src/core-components/src/core-components/CoreButton/elements.js +176 -67
- package/lib/src/core-components/src/core-components/CoreButton/index.js +3 -1
- package/lib/src/core-components/src/core-components/CoreButton/types.js +6 -1
- package/lib/src/core-components/src/core-components/CoreButton/utils.js +12 -1
- package/lib/src/core-components/src/core-components/Divider/Divider.js +19 -4
- 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 +33 -10
- package/lib/src/core-components/src/core-components/StateLayer.js +5 -3
- package/lib/src/core-components/src/core-components/ToggleCore/elements.js +50 -25
- package/lib/src/core-components/src/core-components/ToggleCore/index.js +2 -1
- package/lib/src/core-components/src/core-components/ToggleCore/toggleCore.js +14 -1
- package/lib/src/core-components/src/core-components/atoms/Input/Input.js +22 -1
- package/lib/src/core-components/src/core-components/atoms/Label/Label.js +21 -1
- package/lib/src/core-components/src/core-components/atoms/Textarea/Textarea.js +19 -1
- package/lib/src/core-components/src/core-components/index.js +3 -1
- package/lib/src/core-components/src/helpers/constants.js +11 -1
- package/lib/src/core-components/src/hooks/index.js +1 -1
- package/lib/src/core-components/src/hooks/outside.hook.js +28 -1
- package/lib/src/core-components/src/index.js +12 -1
- package/lib/src/core-components/src/tc.global.css +16 -3
- package/lib/src/core-components/src/tc.module.css +2 -2
- package/lib/src/core-components/src/utils/abstracts/breakpoints/index.js +28 -1
- package/lib/src/core-components/src/utils/abstracts/colors/index.js +49 -1
- package/lib/src/core-components/src/utils/abstracts/index.js +5 -1
- package/lib/src/core-components/src/utils/abstracts/space/index.js +26 -1
- package/lib/src/core-components/src/utils/abstracts/theme/ThemeBoundary.js +8 -1
- package/lib/src/core-components/src/utils/abstracts/theme/default-themes.js +30 -1
- package/lib/src/core-components/src/utils/abstracts/theme/index.js +3 -1
- package/lib/src/core-components/src/utils/abstracts/theme/theme.js +30 -1
- package/lib/src/core-components/src/utils/abstracts/theme/types.js +1 -1
- package/lib/src/core-components/src/utils/abstracts/theme/useTheme.js +17 -1
- package/lib/src/core-components/src/utils/abstracts/typography/index.js +25 -1
- package/lib/src/core-components/src/utils/context/DefaultsProvider.js +8 -1
- package/lib/src/core-components/src/utils/context/InternalProvider.js +24 -1
- package/lib/src/core-components/src/utils/context/index.js +2 -1
- package/lib/src/core-components/src/utils/designTokens.js +125 -1
- package/lib/src/core-components/src/utils/helpers/attachSubComponents.js +23 -1
- package/lib/src/core-components/src/utils/helpers/flattenChildren.js +11 -1
- package/lib/src/core-components/src/utils/helpers/getChildByType.js +3 -1
- package/lib/src/core-components/src/utils/helpers/index.js +5 -1
- package/lib/src/core-components/src/utils/helpers/isComponentType.js +16 -1
- package/lib/src/core-components/src/utils/helpers/separateChildrenByType.js +12 -1
- package/lib/src/core-components/src/utils/hooks/index.js +18 -1
- package/lib/src/core-components/src/utils/hooks/useClickOutside.js +18 -1
- package/lib/src/core-components/src/utils/hooks/useCombinedRefs.js +17 -1
- package/lib/src/core-components/src/utils/hooks/useDebouncedCallback.js +12 -1
- package/lib/src/core-components/src/utils/hooks/useDebouncedValue.js +20 -1
- package/lib/src/core-components/src/utils/hooks/useDeprecation.js +40 -1
- package/lib/src/core-components/src/utils/hooks/useDeviceDetect.js +10 -1
- package/lib/src/core-components/src/utils/hooks/useDeviceForm.js +24 -1
- package/lib/src/core-components/src/utils/hooks/useDisableBodyScroll.js +16 -1
- package/lib/src/core-components/src/utils/hooks/useHoverState.js +36 -1
- package/lib/src/core-components/src/utils/hooks/useId.js +7 -1
- package/lib/src/core-components/src/utils/hooks/useIsBrowser.js +11 -1
- package/lib/src/core-components/src/utils/hooks/useMediaQuery.js +16 -1
- package/lib/src/core-components/src/utils/hooks/useOverflow.js +22 -1
- package/lib/src/core-components/src/utils/hooks/useSafeLayoutEffect.js +5 -1
- package/lib/src/core-components/src/utils/hooks/useScrollingUp.js +18 -1
- package/lib/src/core-components/src/utils/hooks/useTrapFocus.js +30 -1
- package/lib/src/core-components/src/utils/hooks/useWindowDimensions.js +23 -1
- package/lib/src/core-components/src/utils/index.js +9 -1
- package/lib/src/core-components/src/utils/stories/Wrappers.js +23 -8
- package/lib/src/core-components/src/utils/stories/cleanProps.js +5 -1
- package/lib/src/core-components/src/utils/stories/index.js +4 -1
- package/lib/src/core-components/src/utils/stories/sleep.js +4 -1
- package/lib/src/core-components/src/utils/stories/view-ports.js +50 -1
- package/lib/src/core-components/src/utils/styling/calcWidthOfColumns.js +5 -1
- package/lib/src/core-components/src/utils/styling/createGridContainer.js +12 -6
- package/lib/src/core-components/src/utils/styling/createTransition.js +7 -2
- package/lib/src/core-components/src/utils/styling/forwardProps.js +10 -1
- package/lib/src/core-components/src/utils/styling/index.js +5 -1
- package/lib/src/core-components/src/utils/styling/pxToRem.js +6 -1
- package/lib/src/core-components/src/utils/testing/getComputedStyle.js +3 -1
- package/lib/src/core-components/src/utils/testing/index.js +1 -1
- package/lib/src/core-components/src/utils/utility.util.js +14 -1
- package/lib/src/core-components/tailwind.config.js +233 -1
- package/lib/src/core-hooks/index.js +3 -1
- package/lib/src/core-hooks/src/useClickOutside/useClickOutside.hook.js +46 -1
- package/lib/src/core-hooks/src/useDebounce/useDebounce.hook.js +30 -1
- package/lib/src/core-hooks/src/usePreventEKey/usePreventEKey.hook.js +8 -1
- package/lib/src/core-utils/index.js +7 -1
- package/lib/src/core-utils/src/calculation/calculation.util.js +89 -1
- package/lib/src/core-utils/src/colors/color.util.js +15 -1
- package/lib/src/core-utils/src/convert/numberToWords/numToWords.util.js +145 -1
- package/lib/src/core-utils/src/convert/typography/camelCaseToTitleCase.util.js +5 -1
- package/lib/src/core-utils/src/form-helper/form-helper.util.js +82 -1
- package/lib/src/core-utils/src/index.js +7 -1
- package/lib/src/core-utils/src/utility/utility.util.js +12 -1
- package/lib/src/core-utils/src/uuid/uuid.util.js +8 -1
- package/package.json +1 -1
|
@@ -1 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { Label } from '../../../core-components/atoms/Label/Label';
|
|
5
|
+
import s from '../../../tc.module.css';
|
|
6
|
+
import { cn } from '../../../utils';
|
|
7
|
+
import '../toggle.css';
|
|
8
|
+
export const ToggleInput = React.forwardRef(({ id, label, error, required, value, onChange, disabled, isToggleLabel = true, className, labelProps, ...props }, ref) => {
|
|
9
|
+
const [toggleValue, setToggleValue] = useState(value ?? false);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (value !== undefined) {
|
|
12
|
+
setToggleValue(value);
|
|
13
|
+
}
|
|
14
|
+
}, [value]);
|
|
15
|
+
const handleToggleClick = () => {
|
|
16
|
+
if (disabled)
|
|
17
|
+
return;
|
|
18
|
+
const newValue = !toggleValue;
|
|
19
|
+
setToggleValue(newValue);
|
|
20
|
+
if (onChange) {
|
|
21
|
+
onChange(newValue);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const toggleClasses = classNames('wrg-toggle', {
|
|
25
|
+
'wrg-toggle--checked': toggleValue,
|
|
26
|
+
'wrg-toggle--disabled': disabled,
|
|
27
|
+
}, className);
|
|
28
|
+
return (_jsxs("div", { className: cn(s['w-full'], className), children: [label && (_jsx(Label, { id: id, required: required, label: label, ...labelProps })), _jsxs("div", { onClick: handleToggleClick, className: toggleClasses, children: [_jsx("div", { className: cn('wrg-toggle-container', {
|
|
29
|
+
[s['bg-green-700']]: toggleValue,
|
|
30
|
+
[s['bg-black']]: !toggleValue,
|
|
31
|
+
}), children: isToggleLabel && (_jsxs(_Fragment, { children: [_jsx("div", { className: cn('wrg-toggle-check'), children: _jsx("span", { className: cn(s['text-white'], s['ml-1']), children: "Yes" }) }), _jsx("div", { className: cn('wrg-toggle-uncheck'), children: _jsx("span", { className: cn(s['dark:text-black']), children: "No" }) })] })) }), _jsx("div", { className: cn('wrg-toggle-circle', s['dark:bg-black'], {
|
|
32
|
+
'ml-1': toggleValue,
|
|
33
|
+
'mr-1': !toggleValue,
|
|
34
|
+
}) }), _jsx("input", { ref: ref, type: "checkbox", "aria-label": "Toggle Button", className: cn('wrg-toggle-input'), checked: toggleValue, readOnly: true, ...props })] }), error && (_jsx("p", { className: cn(s['mt-1'], s['text-sm'], s['text-red-600'], s['dark:text-red-400']), children: error }))] }));
|
|
35
|
+
});
|
|
36
|
+
ToggleInput.displayName = 'ToggleInput';
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
export { PasswordInput } from './PasswordInput';
|
|
2
|
+
export { ToggleInput } from './ToggleInput';
|
|
3
|
+
export { RadioInput } from './RadioInput';
|
|
4
|
+
export { CheckboxInput } from './CheckboxInput';
|
|
5
|
+
export { CheckboxGroupInput } from './CheckboxGroupInput';
|
|
6
|
+
export { DatePickerInput } from './DatePickerInput';
|
|
7
|
+
export { DropdownInput } from './DropdownInput';
|
|
8
|
+
export { TextDropdownInput } from './TextDropdownInput';
|
|
9
|
+
export { PinInput } from './PinInput';
|
|
10
|
+
export { OtpInput } from './OtpInput';
|
|
11
|
+
export { CssMultilineInput } from './CssMultilineInput';
|
|
@@ -1 +1,161 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable no-sparse-arrays */
|
|
2
|
+
export const properties = [
|
|
3
|
+
{
|
|
4
|
+
alignContent: [
|
|
5
|
+
'flex-start',
|
|
6
|
+
'flex-end',
|
|
7
|
+
'center',
|
|
8
|
+
'stretch',
|
|
9
|
+
'space-between',
|
|
10
|
+
'space-around',
|
|
11
|
+
],
|
|
12
|
+
},
|
|
13
|
+
{ alignItems: ['flex-start', 'flex-end', 'center', 'stretch', 'baseline'] },
|
|
14
|
+
{
|
|
15
|
+
alignSelf: [
|
|
16
|
+
'auto',
|
|
17
|
+
'flex-start',
|
|
18
|
+
'flex-end',
|
|
19
|
+
'center',
|
|
20
|
+
'baseline',
|
|
21
|
+
'stretch',
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
{ flex: ['number'] },
|
|
25
|
+
{ flexDirection: ['row', 'row-reverse', 'column', 'column-reverse'] },
|
|
26
|
+
{ flexWrap: ['nowrap', 'wrap', 'wrap-reverse'] },
|
|
27
|
+
{ flexFlow: ['number'] },
|
|
28
|
+
{ flexGrow: ['number'] },
|
|
29
|
+
{ flexShrink: ['number'] },
|
|
30
|
+
{ flexBasis: ['number'] },
|
|
31
|
+
{
|
|
32
|
+
justifyContent: [
|
|
33
|
+
,
|
|
34
|
+
'flex-start',
|
|
35
|
+
'flex-end',
|
|
36
|
+
'center',
|
|
37
|
+
'space-around',
|
|
38
|
+
'space-between',
|
|
39
|
+
'space-evenly',
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
{ gap: ['number'] },
|
|
43
|
+
{ rowGap: ['number'] },
|
|
44
|
+
{ columnGap: ['number'] },
|
|
45
|
+
// Layout
|
|
46
|
+
{ aspectRatio: ['number'] },
|
|
47
|
+
{ bottom: ['number'] },
|
|
48
|
+
{ display: ['flex', 'none'] },
|
|
49
|
+
{ left: ['number'] },
|
|
50
|
+
{ position: ['absolute', 'relative'] },
|
|
51
|
+
{ right: ['number'] },
|
|
52
|
+
{ top: ['number'] },
|
|
53
|
+
{ overflow: ['hidden'] },
|
|
54
|
+
{ zIndex: ['number'] },
|
|
55
|
+
// Dimension
|
|
56
|
+
{ height: ['number'] },
|
|
57
|
+
{ maxHeight: ['number'] },
|
|
58
|
+
{ maxWidth: ['number'] },
|
|
59
|
+
{ minHeight: ['number'] },
|
|
60
|
+
{ minWidth: ['number'] },
|
|
61
|
+
{ width: ['number'] },
|
|
62
|
+
// Color
|
|
63
|
+
{ backgroundColor: ['string'] },
|
|
64
|
+
{ color: ['string'] },
|
|
65
|
+
{ opacity: ['number'] },
|
|
66
|
+
// Text
|
|
67
|
+
{ fontSize: ['number'] },
|
|
68
|
+
{ fontFamily: ['string'] },
|
|
69
|
+
{ fontStyle: ['string', 'normal'] },
|
|
70
|
+
{
|
|
71
|
+
fontWeight: [
|
|
72
|
+
,
|
|
73
|
+
'number',
|
|
74
|
+
'thin',
|
|
75
|
+
'hairline',
|
|
76
|
+
'ultralight',
|
|
77
|
+
'extralight',
|
|
78
|
+
'light',
|
|
79
|
+
'normal',
|
|
80
|
+
'medium',
|
|
81
|
+
'semibold',
|
|
82
|
+
'demibold',
|
|
83
|
+
'bold',
|
|
84
|
+
'ultrabold',
|
|
85
|
+
'extrabold',
|
|
86
|
+
'heavy',
|
|
87
|
+
'black',
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
{ letterSpacing: ['number'] },
|
|
91
|
+
{ lineHeight: ['number'] },
|
|
92
|
+
{ maxLines: ['number'] },
|
|
93
|
+
{ textAlign: ['left', 'right', 'center', 'justify'] },
|
|
94
|
+
{
|
|
95
|
+
textDecoration: [
|
|
96
|
+
,
|
|
97
|
+
'line-through',
|
|
98
|
+
'underline',
|
|
99
|
+
'none',
|
|
100
|
+
'line-through underline',
|
|
101
|
+
'underline line-through',
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
{ textDecorationColor: ['string'] },
|
|
105
|
+
{ textDecorationStyle: ['dashed', 'dotted', 'solid', 'string'] },
|
|
106
|
+
{ textIndent: ['any'] },
|
|
107
|
+
{ textOverflow: ['ellipsis'] },
|
|
108
|
+
{ textTransform: ['capitalize', 'lowercase', 'uppercase'] },
|
|
109
|
+
{ verticalAlign: ['sub', 'super'] },
|
|
110
|
+
// Sizing/positioning
|
|
111
|
+
{ objectFit: ['string'] },
|
|
112
|
+
{ objectPosition: ['number'] },
|
|
113
|
+
{ objectPositionX: ['number'] },
|
|
114
|
+
{ objectPositionY: ['number'] },
|
|
115
|
+
// Margin/padding
|
|
116
|
+
{ margin: ['number'] },
|
|
117
|
+
{ marginHorizontal: ['number'] },
|
|
118
|
+
{ marginVertical: ['number'] },
|
|
119
|
+
{ marginTop: ['number'] },
|
|
120
|
+
{ marginRight: ['number'] },
|
|
121
|
+
{ marginBottom: ['number'] },
|
|
122
|
+
{ marginLeft: ['number'] },
|
|
123
|
+
{ padding: ['number'] },
|
|
124
|
+
{ paddingHorizontal: ['number'] },
|
|
125
|
+
{ paddingVertical: ['number'] },
|
|
126
|
+
{ paddingTop: ['number'] },
|
|
127
|
+
{ paddingRight: ['number'] },
|
|
128
|
+
{ paddingBottom: ['number'] },
|
|
129
|
+
{ paddingLeft: ['number'] },
|
|
130
|
+
// Transformations
|
|
131
|
+
{ transform: ['string'] },
|
|
132
|
+
{ transformOrigin: ['number'] },
|
|
133
|
+
{ transformOriginX: ['number'] },
|
|
134
|
+
{ transformOriginY: ['number'] },
|
|
135
|
+
// Borders
|
|
136
|
+
{ border: ['number'] },
|
|
137
|
+
{ borderWidth: ['number'] },
|
|
138
|
+
{ borderColor: ['string'] },
|
|
139
|
+
{ borderStyle: ['dashed', 'dotted', 'solid'] },
|
|
140
|
+
{ borderTop: ['number'] },
|
|
141
|
+
{ borderTopColor: ['string'] },
|
|
142
|
+
{ borderTopStyle: ['dashed', 'dotted', 'solid'] },
|
|
143
|
+
{ borderTopWidth: ['number'] },
|
|
144
|
+
{ borderRight: ['number'] },
|
|
145
|
+
{ borderRightColor: ['string'] },
|
|
146
|
+
{ borderRightStyle: ['dashed', 'dotted', 'solid'] },
|
|
147
|
+
{ borderRightWidth: ['number'] },
|
|
148
|
+
{ borderBottom: ['number'] },
|
|
149
|
+
{ borderBottomColor: ['string'] },
|
|
150
|
+
{ borderBottomStyle: ['dashed', 'dotted', 'solid'] },
|
|
151
|
+
{ borderBottomWidth: ['number'] },
|
|
152
|
+
{ borderLeft: ['number'] },
|
|
153
|
+
{ borderLeftColor: ['string'] },
|
|
154
|
+
{ borderLeftStyle: ['dashed', 'dotted', 'solid'] },
|
|
155
|
+
{ borderLeftWidth: ['number'] },
|
|
156
|
+
{ borderTopLeftRadius: ['number'] },
|
|
157
|
+
{ borderTopRightRadius: ['number'] },
|
|
158
|
+
{ borderBottomRightRadius: ['number'] },
|
|
159
|
+
{ borderBottomLeftRadius: ['number'] },
|
|
160
|
+
{ borderRadius: ['number'] },
|
|
161
|
+
];
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export * from './FormField';
|
|
2
|
+
export * from './components';
|
|
@@ -1 +1,79 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense } from 'react';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import { Tooltip } from '../Tooltip';
|
|
5
|
+
import loadable from '@loadable/component';
|
|
6
|
+
import s from '../../tc.module.css';
|
|
7
|
+
import { cn } from '../../utils';
|
|
8
|
+
const CompatIcon = ({ src, className, style, ...props }) => {
|
|
9
|
+
if (typeof src === 'string') {
|
|
10
|
+
return (_jsx("img", { src: src, className: cn(s.icon, className), style: style, ...props, alt: "" }));
|
|
11
|
+
}
|
|
12
|
+
return (_jsx("div", { className: cn(s.icon, className), style: style, ...props, children: src }));
|
|
13
|
+
};
|
|
14
|
+
const SSRIcon = ({ nameIcon, classNames = {}, styles = {}, ...props }) => {
|
|
15
|
+
return (_jsx("span", { className: cn(s.icon, props.className, classNames.icon), style: styles.icon, "aria-hidden": "true", children: "\u26AB" }));
|
|
16
|
+
};
|
|
17
|
+
export const Icon = ({ nameIcon, propsIcon, className, tooltip = '', isDisable = false, classNames = {}, styles = {}, onClick, }) => {
|
|
18
|
+
try {
|
|
19
|
+
const iconProps = {
|
|
20
|
+
...propsIcon,
|
|
21
|
+
color: isDisable ? '#808080' : propsIcon?.color || 'rgb(36 48 63)',
|
|
22
|
+
};
|
|
23
|
+
const lib = nameIcon.startsWith('IoIo')
|
|
24
|
+
? 'io'
|
|
25
|
+
: nameIcon.startsWith('Io')
|
|
26
|
+
? 'io5'
|
|
27
|
+
: nameIcon
|
|
28
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
29
|
+
.split(' ')[0]
|
|
30
|
+
.toLowerCase();
|
|
31
|
+
const iconLibraries = {
|
|
32
|
+
fa: () => import('react-icons/fa'),
|
|
33
|
+
md: () => import('react-icons/md'),
|
|
34
|
+
io: () => import('react-icons/io'),
|
|
35
|
+
fi: () => import('react-icons/fi'),
|
|
36
|
+
bs: () => import('react-icons/bs'),
|
|
37
|
+
hi: () => import('react-icons/hi'),
|
|
38
|
+
go: () => import('react-icons/go'),
|
|
39
|
+
si: () => import('react-icons/si'),
|
|
40
|
+
ti: () => import('react-icons/ti'),
|
|
41
|
+
wi: () => import('react-icons/wi'),
|
|
42
|
+
di: () => import('react-icons/di'),
|
|
43
|
+
ri: () => import('react-icons/ri'),
|
|
44
|
+
fc: () => import('react-icons/fc'),
|
|
45
|
+
gr: () => import('react-icons/gr'),
|
|
46
|
+
lu: () => import('react-icons/lu'),
|
|
47
|
+
gi: () => import('react-icons/gi'),
|
|
48
|
+
tb: () => import('react-icons/tb'),
|
|
49
|
+
rx: () => import('react-icons/rx'),
|
|
50
|
+
im: () => import('react-icons/im'),
|
|
51
|
+
cg: () => import('react-icons/cg'),
|
|
52
|
+
io5: () => import('react-icons/io5'),
|
|
53
|
+
ai: () => import('react-icons/ai'),
|
|
54
|
+
vsc: () => import('react-icons/vsc'),
|
|
55
|
+
bi: () => import('react-icons/bi'),
|
|
56
|
+
fa2: () => import('react-icons/fa'),
|
|
57
|
+
ci: () => import('react-icons/ci'),
|
|
58
|
+
lib: () => import('react-icons/lib'),
|
|
59
|
+
lia: () => import('react-icons/lia'),
|
|
60
|
+
pi: () => import('react-icons/pi'),
|
|
61
|
+
tfi: () => import('react-icons/tfi'),
|
|
62
|
+
fa6: () => import('react-icons/fa6'),
|
|
63
|
+
};
|
|
64
|
+
const loadLibrary = iconLibraries[lib] || (() => import('react-icons/md'));
|
|
65
|
+
const ElementIcon = loadable(loadLibrary, {
|
|
66
|
+
resolveComponent: (el) => el[nameIcon] != null ? el[nameIcon] : el[Object.keys(el.default)[0]],
|
|
67
|
+
});
|
|
68
|
+
return (_jsx("div", { className: cn(s.iconContainer, className, classNames.container), style: styles.container, onClick: () => {
|
|
69
|
+
if (!isDisable)
|
|
70
|
+
onClick && onClick();
|
|
71
|
+
}, children: !_.isEmpty(tooltip) ? (_jsx(Tooltip, { content: tooltip, children: _jsx(ElementIcon, { ...iconProps, className: cn(s.icon, classNames.icon), style: styles.icon }) })) : (_jsx(Suspense, { fallback: _jsx("div", { children: "Loading..." }), children: _jsx(ElementIcon, { ...iconProps, className: cn(s.icon, classNames.icon), style: styles.icon }) })) }));
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
return _jsx(_Fragment, {});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
// Attach sub-components
|
|
78
|
+
Icon.SSR = SSRIcon;
|
|
79
|
+
Icon.Compat = CompatIcon;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export * from './Icon';
|
|
2
|
+
export * from './types';
|
|
@@ -1,4 +1,216 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import s from '../../tc.module.css';
|
|
3
|
+
import { cn } from '../../utils';
|
|
4
|
+
const sizeClasses = {
|
|
5
|
+
sm: {
|
|
6
|
+
wrapper: cn(s['w-4'], s['h-4']),
|
|
7
|
+
spinner: cn(s['w-4'], s['h-4']),
|
|
8
|
+
dots: cn(s['w-1'], s['h-1']),
|
|
9
|
+
bars: cn(s['w-1'], s['h-6']),
|
|
10
|
+
pulse: cn(s['w-4'], s['h-4']),
|
|
11
|
+
},
|
|
12
|
+
md: {
|
|
13
|
+
wrapper: cn(s['w-8'], s['h-8']),
|
|
14
|
+
spinner: cn(s['w-8'], s['h-8']),
|
|
15
|
+
dots: cn(s['w-2'], s['h-2']),
|
|
16
|
+
bars: cn(s['w-1'], s['h-8']),
|
|
17
|
+
pulse: cn(s['w-8'], s['h-8']),
|
|
18
|
+
},
|
|
19
|
+
lg: {
|
|
20
|
+
wrapper: cn(s['w-10'], s['h-10']),
|
|
21
|
+
spinner: cn(s['w-10'], s['h-10']),
|
|
22
|
+
dots: cn(s['w-3'], s['h-3']),
|
|
23
|
+
bars: cn(s['w-2'], s['h-10']),
|
|
24
|
+
pulse: cn(s['w-10'], s['h-10']),
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const getColorValue = (color) => {
|
|
28
|
+
const colors = {
|
|
29
|
+
blue: 'rgb(59 130 246)',
|
|
30
|
+
green: 'rgb(34 197 94)',
|
|
31
|
+
gray: 'rgb(156 163 175)',
|
|
32
|
+
primary: 'rgb(59 130 246)',
|
|
33
|
+
white: 'rgb(255 255 255)',
|
|
34
|
+
black: 'rgb(0 0 0)',
|
|
35
|
+
};
|
|
36
|
+
// If it's a predefined color, return the mapped value
|
|
37
|
+
if (colors[color]) {
|
|
38
|
+
return colors[color];
|
|
39
|
+
}
|
|
40
|
+
// If it's already a valid CSS color (hex, rgb, rgba, hsl, named color, etc.), return it as-is
|
|
41
|
+
// Check if it looks like a CSS color value (starts with #, rgb, rgba, hsl, hsla, or is a valid CSS color name)
|
|
42
|
+
if (color.startsWith('#') ||
|
|
43
|
+
color.startsWith('rgb') ||
|
|
44
|
+
color.startsWith('hsl') ||
|
|
45
|
+
color.startsWith('rgba') ||
|
|
46
|
+
color.startsWith('hsla') ||
|
|
47
|
+
/^[a-z]+$/i.test(color) // Named colors like 'coral', 'tomato', etc.
|
|
48
|
+
) {
|
|
49
|
+
return color;
|
|
50
|
+
}
|
|
51
|
+
// Default fallback
|
|
52
|
+
return colors.blue;
|
|
53
|
+
};
|
|
54
|
+
// Helper function to extract RGB values from any color format for opacity borders
|
|
55
|
+
const extractRgbForOpacity = (colorValue) => {
|
|
56
|
+
// Handle rgb/rgba format: rgb(59 130 246) or rgba(59, 130, 246, 0.5)
|
|
57
|
+
const rgbMatch = colorValue.match(/rgba?\((\d+)[,\s]+(\d+)[,\s]+(\d+)/);
|
|
58
|
+
if (rgbMatch) {
|
|
59
|
+
return [
|
|
60
|
+
parseInt(rgbMatch[1]),
|
|
61
|
+
parseInt(rgbMatch[2]),
|
|
62
|
+
parseInt(rgbMatch[3]),
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
// Handle hex format: #3b82f6 or #3bf
|
|
66
|
+
if (colorValue.startsWith('#')) {
|
|
67
|
+
const hex = colorValue.slice(1);
|
|
68
|
+
if (hex.length === 3) {
|
|
69
|
+
// Short hex: #3bf -> #33bbff
|
|
70
|
+
const r = parseInt(hex[0] + hex[0], 16);
|
|
71
|
+
const g = parseInt(hex[1] + hex[1], 16);
|
|
72
|
+
const b = parseInt(hex[2] + hex[2], 16);
|
|
73
|
+
return [r, g, b];
|
|
74
|
+
}
|
|
75
|
+
else if (hex.length === 6) {
|
|
76
|
+
// Full hex: #3b82f6
|
|
77
|
+
const r = parseInt(hex.slice(0, 2), 16);
|
|
78
|
+
const g = parseInt(hex.slice(2, 4), 16);
|
|
79
|
+
const b = parseInt(hex.slice(4, 6), 16);
|
|
80
|
+
return [r, g, b];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// For named colors or other formats, create a temporary element to get computed color
|
|
84
|
+
// This is a fallback for named CSS colors like 'coral', 'tomato', etc.
|
|
85
|
+
if (typeof document !== 'undefined') {
|
|
86
|
+
try {
|
|
87
|
+
const tempEl = document.createElement('div');
|
|
88
|
+
tempEl.style.color = colorValue;
|
|
89
|
+
document.body.appendChild(tempEl);
|
|
90
|
+
const computedColor = window.getComputedStyle(tempEl).color;
|
|
91
|
+
document.body.removeChild(tempEl);
|
|
92
|
+
const computedRgb = computedColor.match(/\d+/g);
|
|
93
|
+
if (computedRgb && computedRgb.length >= 3) {
|
|
94
|
+
return [
|
|
95
|
+
parseInt(computedRgb[0]),
|
|
96
|
+
parseInt(computedRgb[1]),
|
|
97
|
+
parseInt(computedRgb[2]),
|
|
98
|
+
];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
// Fallback if DOM manipulation fails
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// Default fallback to white
|
|
106
|
+
return [255, 255, 255];
|
|
107
|
+
};
|
|
108
|
+
// Helper to calculate proportional border width based on spinner size
|
|
109
|
+
// Default ratio: 10px border for 4rem (64px) spinner = ~15.6%
|
|
110
|
+
const calculateBorderWidth = (sizeValue, explicitBorderWidth) => {
|
|
111
|
+
// If explicit borderWidth is provided, use it
|
|
112
|
+
if (explicitBorderWidth) {
|
|
113
|
+
return explicitBorderWidth;
|
|
114
|
+
}
|
|
115
|
+
// Default border width if no size specified
|
|
116
|
+
if (!sizeValue) {
|
|
117
|
+
return '10px';
|
|
118
|
+
}
|
|
119
|
+
// Parse the size value to pixels
|
|
120
|
+
let sizeInPx;
|
|
121
|
+
if (sizeValue.endsWith('rem')) {
|
|
122
|
+
sizeInPx = parseFloat(sizeValue) * 16;
|
|
123
|
+
}
|
|
124
|
+
else if (sizeValue.endsWith('px')) {
|
|
125
|
+
sizeInPx = parseFloat(sizeValue);
|
|
126
|
+
}
|
|
127
|
+
else if (sizeValue.endsWith('em')) {
|
|
128
|
+
sizeInPx = parseFloat(sizeValue) * 16;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
// Fallback for unknown units
|
|
132
|
+
return '10px';
|
|
133
|
+
}
|
|
134
|
+
// Calculate proportional border (about 15.6% of size, min 2px, max 16px)
|
|
135
|
+
const borderPx = Math.max(2, Math.min(16, Math.round(sizeInPx * 0.156)));
|
|
136
|
+
return `${borderPx}px`;
|
|
137
|
+
};
|
|
138
|
+
export const LoadingAnimateSpin = ({ classWarper = '', className = '', variant = 'spinner', size = 'md', color = 'blue', borderWidth, width, height, textFontSize = '1.125rem', loadingText, classNames = {}, styles = {}, 'aria-label': ariaLabel = 'Loading', }) => {
|
|
139
|
+
const sizeConfig = sizeClasses[size];
|
|
140
|
+
const renderSpinner = () => {
|
|
141
|
+
const colorValue = getColorValue(color);
|
|
142
|
+
// Extract RGB values for opacity border - making it more subtle
|
|
143
|
+
const [r, g, b] = extractRgbForOpacity(colorValue);
|
|
144
|
+
const baseBorderColor = `rgba(${r}, ${g}, ${b}, 0.15)`;
|
|
145
|
+
// Calculate spinner dimensions
|
|
146
|
+
const spinnerWidth = width || '4rem';
|
|
147
|
+
const spinnerHeight = height || '4rem';
|
|
148
|
+
// Calculate proportional border width based on spinner size
|
|
149
|
+
const calculatedBorderWidth = calculateBorderWidth(spinnerWidth, borderWidth);
|
|
150
|
+
return (_jsxs("div", { className: cn(s['flex'], s['flex-col'], s['items-center'], s['justify-center'], className, classNames.container), style: styles.container, "aria-label": ariaLabel, role: "status", children: [_jsx("div", { className: cn(sizeConfig.spinner, s['rounded-full'], s['animate-spin'], classNames.spinner), style: {
|
|
151
|
+
width: spinnerWidth,
|
|
152
|
+
height: spinnerHeight,
|
|
153
|
+
borderWidth: calculatedBorderWidth,
|
|
154
|
+
borderStyle: 'solid',
|
|
155
|
+
borderTopColor: colorValue,
|
|
156
|
+
borderRightColor: colorValue,
|
|
157
|
+
borderBottomColor: baseBorderColor,
|
|
158
|
+
borderLeftColor: baseBorderColor,
|
|
159
|
+
animation: 'spin 1s linear infinite',
|
|
160
|
+
...styles.spinner,
|
|
161
|
+
} }), loadingText && (_jsx("p", { className: cn(s['mt-4'], s['text-white'], s['text-lg'], s['font-semibold'], s['animate-pulse'], classNames.text), style: {
|
|
162
|
+
marginTop: '1rem',
|
|
163
|
+
color: colorValue,
|
|
164
|
+
fontSize: textFontSize,
|
|
165
|
+
fontWeight: 600,
|
|
166
|
+
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
167
|
+
...styles.text,
|
|
168
|
+
}, children: loadingText }))] }));
|
|
169
|
+
};
|
|
170
|
+
const renderDots = () => {
|
|
171
|
+
const colorValue = getColorValue(color);
|
|
172
|
+
return (_jsx("div", { className: cn(s['flex'], s['gap-2'], s['items-center'], className, classNames.container), style: styles.container, "aria-label": ariaLabel, role: "status", children: [0, 1, 2].map((i) => (_jsx("div", { className: cn(sizeConfig.dots, s['rounded-full'], classNames.dot), style: {
|
|
173
|
+
backgroundColor: colorValue,
|
|
174
|
+
animation: `bounce 1.4s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite`,
|
|
175
|
+
animationDelay: `${i * 0.16}s`,
|
|
176
|
+
animationFillMode: 'both',
|
|
177
|
+
...styles.dot,
|
|
178
|
+
} }, i))) }));
|
|
179
|
+
};
|
|
180
|
+
const renderBars = () => {
|
|
181
|
+
const colorValue = getColorValue(color);
|
|
182
|
+
return (_jsx("div", { className: cn(s['flex'], s['gap-1'], s['items-center'], className, classNames.container), style: styles.container, "aria-label": ariaLabel, role: "status", children: [0, 1, 2].map((i) => (_jsx("div", { className: cn(sizeConfig.bars, s.rounded, classNames.bar), style: {
|
|
183
|
+
backgroundColor: colorValue,
|
|
184
|
+
borderRadius: '0.125rem',
|
|
185
|
+
animation: `pulse 1.2s ease-in-out infinite`,
|
|
186
|
+
animationDelay: `${i * 0.15}s`,
|
|
187
|
+
animationFillMode: 'both',
|
|
188
|
+
...styles.bar,
|
|
189
|
+
} }, i))) }));
|
|
190
|
+
};
|
|
191
|
+
const renderPulse = () => {
|
|
192
|
+
const colorValue = getColorValue(color);
|
|
193
|
+
return (_jsx("div", { className: cn(sizeConfig.pulse, s['rounded-full'], className, classNames.pulse), style: {
|
|
194
|
+
backgroundColor: colorValue,
|
|
195
|
+
animation: `pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite`,
|
|
196
|
+
animationFillMode: 'both',
|
|
197
|
+
...styles.pulse,
|
|
198
|
+
}, "aria-label": ariaLabel, role: "status" }));
|
|
199
|
+
};
|
|
200
|
+
const renderLoader = () => {
|
|
201
|
+
switch (variant) {
|
|
202
|
+
case 'dots':
|
|
203
|
+
return renderDots();
|
|
204
|
+
case 'bars':
|
|
205
|
+
return renderBars();
|
|
206
|
+
case 'pulse':
|
|
207
|
+
return renderPulse();
|
|
208
|
+
case 'spinner':
|
|
209
|
+
default:
|
|
210
|
+
return renderSpinner();
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
return (_jsxs("div", { className: cn(s['flex'], s['justify-center'], s['items-center'], classWarper, classNames.wrapper), style: styles.wrapper, children: [_jsx("style", { children: `
|
|
2
214
|
@keyframes spin {
|
|
3
215
|
from {
|
|
4
216
|
transform: rotate(0deg);
|
|
@@ -31,4 +243,5 @@
|
|
|
31
243
|
opacity: 0.8;
|
|
32
244
|
}
|
|
33
245
|
}
|
|
34
|
-
`}),
|
|
246
|
+
` }), renderLoader()] }));
|
|
247
|
+
};
|
|
@@ -1 +1,73 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useCallback, useState, useEffect } from 'react';
|
|
4
|
+
import { MasonryContainer, MasonryColumn, MasonryItemWrapper, MasonryImage, ImagePlaceholder, EmptyState, MasonryCard, MasonryCardContent, } from './elements';
|
|
5
|
+
import { useResponsiveValue, useColumnDistribution, useImageLoading } from './hooks';
|
|
6
|
+
// Default empty icon
|
|
7
|
+
const EmptyIcon = () => (_jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [_jsx("rect", { x: "3", y: "3", width: "7", height: "7", rx: "1" }), _jsx("rect", { x: "14", y: "3", width: "7", height: "7", rx: "1" }), _jsx("rect", { x: "3", y: "14", width: "7", height: "7", rx: "1" }), _jsx("rect", { x: "14", y: "14", width: "7", height: "7", rx: "1" })] }));
|
|
8
|
+
export const Masonry = forwardRef(function MasonryComponent(props, ref) {
|
|
9
|
+
const { items, columns = 3, gutter = 16, renderItem, sequential = false, animationDuration = 300, animated = true, staggerDelay = 50, classNames = {}, styles = {}, className, style, onImageLoad, onLayoutComplete, minItemHeight, loadingPlaceholder, emptyState, } = props;
|
|
10
|
+
// Get responsive values
|
|
11
|
+
const columnCount = useResponsiveValue(columns, 3);
|
|
12
|
+
const gutterSize = useResponsiveValue(gutter, 16);
|
|
13
|
+
// Distribute items into columns
|
|
14
|
+
const columnData = useColumnDistribution(items, columnCount, sequential);
|
|
15
|
+
// Image loading state
|
|
16
|
+
const { setLoading, isLoading } = useImageLoading();
|
|
17
|
+
// Track global item index for stagger animation
|
|
18
|
+
let globalIndex = 0;
|
|
19
|
+
// Layout complete callback
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (items.length > 0) {
|
|
22
|
+
const timeout = setTimeout(() => {
|
|
23
|
+
onLayoutComplete?.();
|
|
24
|
+
}, animationDuration + staggerDelay * items.length);
|
|
25
|
+
return () => clearTimeout(timeout);
|
|
26
|
+
}
|
|
27
|
+
}, [items, animationDuration, staggerDelay, onLayoutComplete]);
|
|
28
|
+
// Handle image load
|
|
29
|
+
const handleImageLoad = useCallback((item, e) => {
|
|
30
|
+
const img = e.currentTarget;
|
|
31
|
+
setLoading(item.id, false);
|
|
32
|
+
onImageLoad?.(item, img.naturalWidth, img.naturalHeight);
|
|
33
|
+
}, [setLoading, onImageLoad]);
|
|
34
|
+
// Default render function
|
|
35
|
+
const defaultRenderItem = useCallback((item, index, columnIndex) => {
|
|
36
|
+
if (item.src) {
|
|
37
|
+
// Image item
|
|
38
|
+
return (_jsxs(MasonryCard, { "$borderRadius": 8, children: [isLoading(item.id) && (_jsx(ImagePlaceholder, { "$height": item.height, "$borderRadius": 8 })), _jsx(MasonryImage, { src: item.src, alt: item.alt || '', "$objectFit": "cover", "$borderRadius": 0, "$isLoading": isLoading(item.id), onLoad: (e) => handleImageLoad(item, e), onError: () => setLoading(item.id, false) }), item.content && (_jsx(MasonryCardContent, { children: item.content }))] }));
|
|
39
|
+
}
|
|
40
|
+
// Content item
|
|
41
|
+
if (item.content) {
|
|
42
|
+
return item.content;
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}, [isLoading, handleImageLoad, setLoading]);
|
|
46
|
+
// Use custom render or default
|
|
47
|
+
const render = renderItem || defaultRenderItem;
|
|
48
|
+
// Empty state
|
|
49
|
+
if (items.length === 0) {
|
|
50
|
+
return (_jsx(EmptyState, { className: classNames.root, style: styles.root, children: emptyState || (_jsxs(_Fragment, { children: [_jsx(EmptyIcon, {}), _jsx("span", { children: "No items to display" })] })) }));
|
|
51
|
+
}
|
|
52
|
+
return (_jsx(MasonryContainer, { ref: ref, "$gutter": gutterSize, className: className || classNames.root, style: { ...styles.root, ...style }, role: "grid", "aria-label": "Masonry layout", children: columnData.map((columnItems, columnIndex) => (_jsx(MasonryColumn, { "$gutter": gutterSize, "$columnCount": columnCount, className: classNames.column, style: styles.column, role: "gridcell", children: columnItems.map((item, itemIndex) => {
|
|
53
|
+
const currentGlobalIndex = globalIndex++;
|
|
54
|
+
return (_jsx(MasonryItemWrapper, { "$animated": animated, "$animationDuration": animationDuration, "$staggerIndex": currentGlobalIndex, "$staggerDelay": staggerDelay, "$minHeight": minItemHeight, className: classNames.item, style: styles.item, children: render(item, itemIndex, columnIndex) }, item.id));
|
|
55
|
+
}) }, columnIndex))) }));
|
|
56
|
+
});
|
|
57
|
+
// Display name
|
|
58
|
+
Masonry.displayName = 'Masonry';
|
|
59
|
+
// MasonryImage component for standalone use
|
|
60
|
+
export const MasonryImageComponent = forwardRef(function MasonryImageComponent(props, ref) {
|
|
61
|
+
const { src, alt = '', className, style, onLoad, onError, objectFit = 'cover', borderRadius = 8, } = props;
|
|
62
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
63
|
+
const handleLoad = (e) => {
|
|
64
|
+
setIsLoading(false);
|
|
65
|
+
onLoad?.(e);
|
|
66
|
+
};
|
|
67
|
+
const handleError = (e) => {
|
|
68
|
+
setIsLoading(false);
|
|
69
|
+
onError?.(e);
|
|
70
|
+
};
|
|
71
|
+
return (_jsxs(_Fragment, { children: [isLoading && _jsx(ImagePlaceholder, { "$borderRadius": borderRadius }), _jsx(MasonryImage, { ref: ref, src: src, alt: alt, className: className, style: style, "$objectFit": objectFit, "$borderRadius": borderRadius, "$isLoading": isLoading, onLoad: handleLoad, onError: handleError })] }));
|
|
72
|
+
});
|
|
73
|
+
MasonryImageComponent.displayName = 'MasonryImage';
|