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,118 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useState, useRef } from 'react';
|
|
3
|
-
import s from '../../tc.module.css';
|
|
4
|
-
import { cn } from '../../utils';
|
|
5
|
-
export const Tags = ({ defaultTags = [], placeholder = 'Type and press Enter to add tags...', maxTags, disabled = false, className = '', label, hasError = false, errorMessage, removable = true, tagVariant = 'default', size = 'md', classNames = {}, styles = {}, onChange, onBlur, onTagAdd, onTagRemove, }) => {
|
|
6
|
-
const [tags, setTags] = useState(defaultTags);
|
|
7
|
-
const [inputValue, setInputValue] = useState('');
|
|
8
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
9
|
-
const inputRef = useRef(null);
|
|
10
|
-
// Tag variant styles
|
|
11
|
-
const tagVariants = {
|
|
12
|
-
default: s['bg-gray-100'] + ' ' + s['text-gray-800'] + ' ' + s['border-gray-200'],
|
|
13
|
-
primary: s['bg-blue-100'] + ' ' + s['text-blue-800'] + ' ' + s['border-blue-200'],
|
|
14
|
-
secondary: s['bg-gray-100'] + ' ' + s['text-gray-700'] + ' ' + s['border-gray-300'],
|
|
15
|
-
success: s['bg-green-100'] +
|
|
16
|
-
' ' +
|
|
17
|
-
s['text-green-800'] +
|
|
18
|
-
' ' +
|
|
19
|
-
s['border-green-200'],
|
|
20
|
-
warning: s['bg-yellow-100'] +
|
|
21
|
-
' ' +
|
|
22
|
-
s['text-yellow-800'] +
|
|
23
|
-
' ' +
|
|
24
|
-
s['border-yellow-200'],
|
|
25
|
-
danger: s['bg-red-100'] + ' ' + s['text-red-800'] + ' ' + s['border-red-200'],
|
|
26
|
-
};
|
|
27
|
-
// Size styles
|
|
28
|
-
const sizeStyles = {
|
|
29
|
-
sm: {
|
|
30
|
-
tag: s['text-xs'] + ' ' + s['px-2'] + ' ' + s['py-1'],
|
|
31
|
-
input: s['text-sm'] + ' ' + s['p-2'],
|
|
32
|
-
removeBtn: s['w-3'] + ' ' + s['h-3'],
|
|
33
|
-
},
|
|
34
|
-
md: {
|
|
35
|
-
tag: s['text-sm'] + ' ' + s['px-3'] + ' ' + s['py-1'],
|
|
36
|
-
input: s['text-base'] + ' ' + s['p-3'],
|
|
37
|
-
removeBtn: s['w-4'] + ' ' + s['h-4'],
|
|
38
|
-
},
|
|
39
|
-
lg: {
|
|
40
|
-
tag: s['text-base'] + ' ' + s['px-4'] + ' ' + s['py-2'],
|
|
41
|
-
input: s['text-lg'] + ' ' + s['p-4'],
|
|
42
|
-
removeBtn: s['w-5'] + ' ' + s['h-5'],
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
const addTag = (tag) => {
|
|
46
|
-
const trimmedTag = tag.trim();
|
|
47
|
-
if (!trimmedTag)
|
|
48
|
-
return;
|
|
49
|
-
// Check if tag already exists
|
|
50
|
-
if (tags.includes(trimmedTag)) {
|
|
51
|
-
setInputValue('');
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
// Check max tags limit
|
|
55
|
-
if (maxTags && tags.length >= maxTags) {
|
|
56
|
-
setInputValue('');
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const newTags = [...tags, trimmedTag];
|
|
60
|
-
setTags(newTags);
|
|
61
|
-
setInputValue('');
|
|
62
|
-
// Callbacks
|
|
63
|
-
onChange?.(newTags);
|
|
64
|
-
onTagAdd?.(trimmedTag);
|
|
65
|
-
};
|
|
66
|
-
const removeTag = (indexToRemove) => {
|
|
67
|
-
if (!removable)
|
|
68
|
-
return;
|
|
69
|
-
const tagToRemove = tags[indexToRemove];
|
|
70
|
-
const newTags = tags.filter((_, index) => index !== indexToRemove);
|
|
71
|
-
setTags(newTags);
|
|
72
|
-
// Callbacks
|
|
73
|
-
onChange?.(newTags);
|
|
74
|
-
onTagRemove?.(tagToRemove, indexToRemove);
|
|
75
|
-
};
|
|
76
|
-
const handleKeyDown = (e) => {
|
|
77
|
-
if (e.key === 'Enter') {
|
|
78
|
-
e.preventDefault();
|
|
79
|
-
addTag(inputValue);
|
|
80
|
-
}
|
|
81
|
-
else if (e.key === 'Backspace' && !inputValue && tags.length > 0) {
|
|
82
|
-
// Remove last tag when backspace is pressed on empty input
|
|
83
|
-
removeTag(tags.length - 1);
|
|
84
|
-
}
|
|
85
|
-
else if (e.key === 'Escape') {
|
|
86
|
-
setInputValue('');
|
|
87
|
-
inputRef.current?.blur();
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
const handleInputBlur = () => {
|
|
91
|
-
setIsFocused(false);
|
|
92
|
-
// Add current input as tag if not empty
|
|
93
|
-
if (inputValue.trim()) {
|
|
94
|
-
addTag(inputValue);
|
|
95
|
-
}
|
|
96
|
-
onBlur?.(tags);
|
|
97
|
-
};
|
|
98
|
-
const handleContainerClick = () => {
|
|
99
|
-
if (!disabled) {
|
|
100
|
-
inputRef.current?.focus();
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
return (_jsxs("div", { className: cn(s.flex, s['flex-col'], s['w-full'], className, classNames.container), style: styles.container, children: [label && (_jsxs("label", { className: cn(s['text-sm'], s['font-medium'], s['mb-2'], hasError ? s['text-red-600'] : s['text-gray-700'], classNames.label), style: styles.label, children: [label, maxTags && (_jsxs("span", { className: cn(s['text-xs'], s['text-gray-500'], s['ml-2']), children: ["(", tags.length, "/", maxTags, ")"] }))] })), _jsxs("div", { onClick: handleContainerClick, className: cn(s['min-h-10'], s['w-full'], s['border'], s['rounded-md'], s['bg-white'], s['flex'], s['flex-wrap'], s['gap-2'], s['p-2'], s['cursor-text'], s['transition-colors'],
|
|
104
|
-
// Focus styles
|
|
105
|
-
isFocused &&
|
|
106
|
-
!hasError &&
|
|
107
|
-
s['border-blue-500'] + ' ' + s['ring-1'] + ' ' + s['ring-blue-500'],
|
|
108
|
-
// Error styles
|
|
109
|
-
hasError ? s['border-red'] : s['border-gray-300'],
|
|
110
|
-
// Disabled styles
|
|
111
|
-
disabled && s['bg-gray-50'] + ' ' + s['cursor-not-allowed'],
|
|
112
|
-
// Hover styles
|
|
113
|
-
!disabled && s['hover:border-gray-400'], classNames.tagsContainer), style: styles.tagsContainer, children: [tags.map((tag, index) => (_jsxs("span", { className: cn(s['flex'], s['inline-flex'], s['items-center'], s['border'], s['rounded-full'], s['font-medium'], s['transition-colors'], s['items-center'], sizeStyles[size].tag, tagVariants[tagVariant], disabled && s['opacity-60'], classNames.tag), style: styles.tag, children: [_jsx("span", { className: cn(s['truncate'], s['max-w-32'], classNames.tagText), style: styles.tagText, children: tag }), removable && !disabled && (_jsx("button", { type: "button", onClick: (e) => {
|
|
114
|
-
e.stopPropagation();
|
|
115
|
-
removeTag(index);
|
|
116
|
-
}, className: cn(s['ml-2'], s['flex-shrink-0'], s['rounded-full'], s['hover:bg-black'], s['hover:bg-opacity-10'], s['transition-colors'], s['focus:outline-none'], s['focus:ring-2'], s['focus:ring-offset-1'], s['focus:ring-gray-500'], classNames.removeButton), style: styles.removeButton, "aria-label": `Remove ${tag} tag`, children: _jsx("svg", { className: cn(sizeStyles[size].removeBtn), fill: "currentColor", viewBox: "0 0 20 20", children: _jsx("path", { fillRule: "evenodd", d: "M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z", clipRule: "evenodd" }) }) }))] }, `${tag}-${index}`))), (!maxTags || tags.length < maxTags) && (_jsx("input", { ref: inputRef, type: "text", value: inputValue, onChange: (e) => setInputValue(e.target.value), onKeyDown: handleKeyDown, onFocus: () => setIsFocused(true), onBlur: handleInputBlur, placeholder: tags.length === 0 ? placeholder : '', disabled: disabled, className: cn(s['flex-1'], s['min-w-32'], s['border-0'], s['outline-none'], s['bg-transparent'], sizeStyles[size].input.replace(s['p-3'], s['p-1']), // Adjust padding for input inside container
|
|
117
|
-
disabled && s['cursor-not-allowed'], classNames.input), style: styles.input, "aria-label": "Add new tag" }))] }), (errorMessage || maxTags) && (_jsxs("div", { className: cn(s['mt-1'], s['flex'], s['justify-between'], s['text-xs'], classNames.helperText), style: styles.helperText, children: [errorMessage && hasError && (_jsx("span", { className: cn(s['text-red-600'], classNames.errorMessage), style: styles.errorMessage, children: errorMessage })), maxTags && !hasError && (_jsxs("span", { className: cn(s['text-gray-500'], s['ml-auto']), children: [tags.length, "/", maxTags, " tags"] }))] })), !hasError && !errorMessage && (_jsx("p", { className: cn(s['mt-1'], s['text-xs'], s['text-gray-500'], classNames.helperText), style: styles.helperText, children: "Press Enter to add tags, Backspace to remove last tag" }))] }));
|
|
118
|
-
};
|
|
1
|
+
"use strict";import{jsxs as u,jsx as g}from"react/jsx-runtime";import{useState as h,useRef as q}from"react";import e from"../../tc.module.css";import{cn as n}from"../../utils";export const Tags=({defaultTags:L=[],placeholder:N="Type and press Enter to add tags...",maxTags:a,disabled:c=!1,className:R="",label:w,hasError:d=!1,errorMessage:x,removable:v=!0,tagVariant:D="default",size:m="md",classNames:l={},styles:o={},onChange:B,onBlur:F,onTagAdd:I,onTagRemove:V})=>{const[r,k]=h(L),[p,f]=h(""),[_,C]=h(!1),b=q(null),$={default:e["bg-gray-100"]+" "+e["text-gray-800"]+" "+e["border-gray-200"],primary:e["bg-blue-100"]+" "+e["text-blue-800"]+" "+e["border-blue-200"],secondary:e["bg-gray-100"]+" "+e["text-gray-700"]+" "+e["border-gray-300"],success:e["bg-green-100"]+" "+e["text-green-800"]+" "+e["border-green-200"],warning:e["bg-yellow-100"]+" "+e["text-yellow-800"]+" "+e["border-yellow-200"],danger:e["bg-red-100"]+" "+e["text-red-800"]+" "+e["border-red-200"]},y={sm:{tag:e["text-xs"]+" "+e["px-2"]+" "+e["py-1"],input:e["text-sm"]+" "+e["p-2"],removeBtn:e["w-3"]+" "+e["h-3"]},md:{tag:e["text-sm"]+" "+e["px-3"]+" "+e["py-1"],input:e["text-base"]+" "+e["p-3"],removeBtn:e["w-4"]+" "+e["h-4"]},lg:{tag:e["text-base"]+" "+e["px-4"]+" "+e["py-2"],input:e["text-lg"]+" "+e["p-4"],removeBtn:e["w-5"]+" "+e["h-5"]}},j=t=>{const i=t.trim();if(!i)return;if(r.includes(i)){f("");return}if(a&&r.length>=a){f("");return}const s=[...r,i];k(s),f(""),B?.(s),I?.(i)},T=t=>{if(!v)return;const i=r[t],s=r.filter((z,A)=>A!==t);k(s),B?.(s),V?.(i,t)},K=t=>{t.key==="Enter"?(t.preventDefault(),j(p)):t.key==="Backspace"&&!p&&r.length>0?T(r.length-1):t.key==="Escape"&&(f(""),b.current?.blur())},P=()=>{C(!1),p.trim()&&j(p),F?.(r)},S=()=>{c||b.current?.focus()};return u("div",{className:n(e.flex,e["flex-col"],e["w-full"],R,l.container),style:o.container,children:[w&&u("label",{className:n(e["text-sm"],e["font-medium"],e["mb-2"],d?e["text-red-600"]:e["text-gray-700"],l.label),style:o.label,children:[w,a&&u("span",{className:n(e["text-xs"],e["text-gray-500"],e["ml-2"]),children:["(",r.length,"/",a,")"]})]}),u("div",{onClick:S,className:n(e["min-h-10"],e["w-full"],e.border,e["rounded-md"],e["bg-white"],e.flex,e["flex-wrap"],e["gap-2"],e["p-2"],e["cursor-text"],e["transition-colors"],_&&!d&&e["border-blue-500"]+" "+e["ring-1"]+" "+e["ring-blue-500"],d?e["border-red"]:e["border-gray-300"],c&&e["bg-gray-50"]+" "+e["cursor-not-allowed"],!c&&e["hover:border-gray-400"],l.tagsContainer),style:o.tagsContainer,children:[r.map((t,i)=>u("span",{className:n(e.flex,e["inline-flex"],e["items-center"],e.border,e["rounded-full"],e["font-medium"],e["transition-colors"],e["items-center"],y[m].tag,$[D],c&&e["opacity-60"],l.tag),style:o.tag,children:[g("span",{className:n(e.truncate,e["max-w-32"],l.tagText),style:o.tagText,children:t}),v&&!c&&g("button",{type:"button",onClick:s=>{s.stopPropagation(),T(i)},className:n(e["ml-2"],e["flex-shrink-0"],e["rounded-full"],e["hover:bg-black"],e["hover:bg-opacity-10"],e["transition-colors"],e["focus:outline-none"],e["focus:ring-2"],e["focus:ring-offset-1"],e["focus:ring-gray-500"],l.removeButton),style:o.removeButton,"aria-label":`Remove ${t} tag`,children:g("svg",{className:n(y[m].removeBtn),fill:"currentColor",viewBox:"0 0 20 20",children:g("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]},`${t}-${i}`)),(!a||r.length<a)&&g("input",{ref:b,type:"text",value:p,onChange:t=>f(t.target.value),onKeyDown:K,onFocus:()=>C(!0),onBlur:P,placeholder:r.length===0?N:"",disabled:c,className:n(e["flex-1"],e["min-w-32"],e["border-0"],e["outline-none"],e["bg-transparent"],y[m].input.replace(e["p-3"],e["p-1"]),c&&e["cursor-not-allowed"],l.input),style:o.input,"aria-label":"Add new tag"})]}),(x||a)&&u("div",{className:n(e["mt-1"],e.flex,e["justify-between"],e["text-xs"],l.helperText),style:o.helperText,children:[x&&d&&g("span",{className:n(e["text-red-600"],l.errorMessage),style:o.errorMessage,children:x}),a&&!d&&u("span",{className:n(e["text-gray-500"],e["ml-auto"]),children:[r.length,"/",a," tags"]})]}),!d&&!x&&g("p",{className:n(e["mt-1"],e["text-xs"],e["text-gray-500"],l.helperText),style:o.helperText,children:"Press Enter to add tags, Backspace to remove last tag"})]})};
|
|
@@ -1,20 +1 @@
|
|
|
1
|
-
export const TAG_TYPES
|
|
2
|
-
'light',
|
|
3
|
-
'gray',
|
|
4
|
-
'dark',
|
|
5
|
-
'success',
|
|
6
|
-
'warn',
|
|
7
|
-
'error',
|
|
8
|
-
'update',
|
|
9
|
-
'attention',
|
|
10
|
-
'disabled',
|
|
11
|
-
'red',
|
|
12
|
-
'orange',
|
|
13
|
-
'yellow',
|
|
14
|
-
'green',
|
|
15
|
-
'teal',
|
|
16
|
-
'purple',
|
|
17
|
-
'themeable',
|
|
18
|
-
];
|
|
19
|
-
export const TAG_SIZES = ['large', 'regular', 'small'];
|
|
20
|
-
export const TAG_FAMILIES = ['bold', 'soft'];
|
|
1
|
+
"use strict";export const TAG_TYPES=["light","gray","dark","success","warn","error","update","attention","disabled","red","orange","yellow","green","teal","purple","themeable"],TAG_SIZES=["large","regular","small"],TAG_FAMILIES=["bold","soft"];
|
|
@@ -1,76 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
/* eslint-disable react/prop-types */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
4
|
-
import React, { useEffect, useState, useImperativeHandle } from 'react';
|
|
5
|
-
import { Icon } from '../Icon/Icon';
|
|
6
|
-
import s from '../../tc.module.css';
|
|
7
|
-
import { cn } from '../../utils';
|
|
8
|
-
// eslint-disable-next-line react/display-name
|
|
9
|
-
export const Timer = React.forwardRef(({ onClear }, ref) => {
|
|
10
|
-
const width = 15;
|
|
11
|
-
const [minute, setMinute] = useState('00');
|
|
12
|
-
const [second, setSecond] = useState('10');
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
const sec = parseInt(second);
|
|
15
|
-
const min = parseInt(minute);
|
|
16
|
-
const countDown = setInterval(() => {
|
|
17
|
-
if (min === 0 && sec === 0) {
|
|
18
|
-
setMinute('00');
|
|
19
|
-
setSecond('00');
|
|
20
|
-
clearInterval(countDown);
|
|
21
|
-
onClear && onClear();
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
let secondstTmp = (sec - 1).toString();
|
|
25
|
-
if (secondstTmp.length === 1) {
|
|
26
|
-
secondstTmp = '0'.concat(secondstTmp);
|
|
27
|
-
}
|
|
28
|
-
setSecond(secondstTmp);
|
|
29
|
-
if (sec === 0) {
|
|
30
|
-
setSecond('59');
|
|
31
|
-
const m = (min - 1).toString();
|
|
32
|
-
setMinute('0' + m);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}, 1000);
|
|
36
|
-
return () => {
|
|
37
|
-
clearInterval(countDown);
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
useImperativeHandle(ref, () => ({
|
|
41
|
-
updateState() {
|
|
42
|
-
setMinute('02');
|
|
43
|
-
setSecond('00');
|
|
44
|
-
},
|
|
45
|
-
resetTimer() {
|
|
46
|
-
// eslint-disable-next-line no-console
|
|
47
|
-
const sec = parseInt(second);
|
|
48
|
-
const min = parseInt(minute === '00' ? '02' : minute);
|
|
49
|
-
const countDown = setInterval(() => {
|
|
50
|
-
// eslint-disable-next-line no-console
|
|
51
|
-
if (min === 0 && sec === 0) {
|
|
52
|
-
setMinute('00');
|
|
53
|
-
setSecond('00');
|
|
54
|
-
clearInterval(countDown);
|
|
55
|
-
onClear && onClear();
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
let secondstTmp = (sec - 1).toString();
|
|
59
|
-
if (secondstTmp.length === 1) {
|
|
60
|
-
secondstTmp = '0'.concat(secondstTmp);
|
|
61
|
-
}
|
|
62
|
-
setSecond(secondstTmp);
|
|
63
|
-
if (sec === 0) {
|
|
64
|
-
setSecond('59');
|
|
65
|
-
const m = (min - 1).toString();
|
|
66
|
-
setMinute('0' + m);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}, 1000);
|
|
70
|
-
return () => {
|
|
71
|
-
clearInterval(countDown);
|
|
72
|
-
};
|
|
73
|
-
},
|
|
74
|
-
}));
|
|
75
|
-
return (_jsxs("div", { className: cn(s['flex'], s['flex-row'], s['items-center']), children: [_jsx(Icon, { nameIcon: "MdAvTimer" }), _jsxs("div", { className: cn(s['ml-2'], s['flex'], s['flex-row']), children: [_jsxs("span", { children: [minute, ":"] }), _jsx("span", { children: second })] })] }));
|
|
76
|
-
});
|
|
1
|
+
"use strict";import{jsx as p,jsxs as f}from"react/jsx-runtime";import v,{useEffect as x,useState as d,useImperativeHandle as h}from"react";import{Icon as S}from"../Icon/Icon";import s from"../../tc.module.css";import{cn as I}from"../../utils";export const Timer=v.forwardRef(({onClear:i},u)=>{const[a,r]=d("00"),[m,e]=d("10");return x(()=>{const n=parseInt(m),c=parseInt(a),o=setInterval(()=>{if(c===0&&n===0)r("00"),e("00"),clearInterval(o),i&&i();else{let t=(n-1).toString();if(t.length===1&&(t="0".concat(t)),e(t),n===0){e("59");const l=(c-1).toString();r("0"+l)}}},1e3);return()=>{clearInterval(o)}}),h(u,()=>({updateState(){r("02"),e("00")},resetTimer(){const n=parseInt(m),c=parseInt(a==="00"?"02":a),o=setInterval(()=>{if(c===0&&n===0)r("00"),e("00"),clearInterval(o),i&&i();else{let t=(n-1).toString();if(t.length===1&&(t="0".concat(t)),e(t),n===0){e("59");const l=(c-1).toString();r("0"+l)}}},1e3);return()=>{clearInterval(o)}}})),f("div",{className:I(s.flex,s["flex-row"],s["items-center"]),children:[p(S,{nameIcon:"MdAvTimer"}),f("div",{className:I(s["ml-2"],s.flex,s["flex-row"]),children:[f("span",{children:[a,":"]}),p("span",{children:m})]})]})});
|
|
@@ -1,50 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef, useEffect, useCallback } from 'react';
|
|
4
|
-
import { ToastElement, ToastContainerElement, IconWrapper, ContentWrapper, Message, ActionsWrapper, ActionButton, DismissButton, ProgressBar, } from './elements';
|
|
5
|
-
// Default icons
|
|
6
|
-
const SuccessIcon = () => (_jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [_jsx("path", { d: "M22 11.08V12a10 10 0 1 1-5.93-9.14" }), _jsx("polyline", { points: "22 4 12 14.01 9 11.01" })] }));
|
|
7
|
-
const ErrorIcon = () => (_jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [_jsx("circle", { cx: "12", cy: "12", r: "10" }), _jsx("line", { x1: "15", y1: "9", x2: "9", y2: "15" }), _jsx("line", { x1: "9", y1: "9", x2: "15", y2: "15" })] }));
|
|
8
|
-
const WarningIcon = () => (_jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [_jsx("path", { d: "M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" }), _jsx("line", { x1: "12", y1: "9", x2: "12", y2: "13" }), _jsx("line", { x1: "12", y1: "17", x2: "12.01", y2: "17" })] }));
|
|
9
|
-
const InfoIcon = () => (_jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [_jsx("circle", { cx: "12", cy: "12", r: "10" }), _jsx("line", { x1: "12", y1: "16", x2: "12", y2: "12" }), _jsx("line", { x1: "12", y1: "8", x2: "12.01", y2: "8" })] }));
|
|
10
|
-
const CloseIcon = () => (_jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [_jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), _jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })] }));
|
|
11
|
-
const getDefaultIcon = (type) => {
|
|
12
|
-
switch (type) {
|
|
13
|
-
case 'success':
|
|
14
|
-
return _jsx(SuccessIcon, {});
|
|
15
|
-
case 'error':
|
|
16
|
-
return _jsx(ErrorIcon, {});
|
|
17
|
-
case 'warning':
|
|
18
|
-
return _jsx(WarningIcon, {});
|
|
19
|
-
case 'info':
|
|
20
|
-
return _jsx(InfoIcon, {});
|
|
21
|
-
default:
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
export const Toast = forwardRef(function ToastComponent(props, ref) {
|
|
26
|
-
const { message, type = 'default', isOpen = true, onClose, action, icon, showIcon = true, duration, showProgress = false, className, ...rest } = props;
|
|
27
|
-
// Auto dismiss
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (duration && isOpen && onClose) {
|
|
30
|
-
const timer = setTimeout(() => {
|
|
31
|
-
onClose();
|
|
32
|
-
}, duration);
|
|
33
|
-
return () => clearTimeout(timer);
|
|
34
|
-
}
|
|
35
|
-
}, [duration, isOpen, onClose]);
|
|
36
|
-
const handleClose = useCallback(() => {
|
|
37
|
-
onClose?.();
|
|
38
|
-
}, [onClose]);
|
|
39
|
-
const handleAction = useCallback(() => {
|
|
40
|
-
action?.onClick?.();
|
|
41
|
-
}, [action]);
|
|
42
|
-
const displayIcon = icon ?? (showIcon ? getDefaultIcon(type) : null);
|
|
43
|
-
return (_jsxs(ToastElement, { ref: ref, "$type": type, "$isOpen": isOpen, "$position": "bottom-right", role: "alert", "aria-live": "assertive", "data-aui": "toast", className: className, ...rest, children: [displayIcon && (_jsx(IconWrapper, { "$type": type, "aria-hidden": "true", children: displayIcon })), _jsx(ContentWrapper, { children: _jsx(Message, { children: message }) }), _jsxs(ActionsWrapper, { children: [action && (_jsx(ActionButton, { "$type": type, onClick: handleAction, "aria-label": action.ariaLabel || action.text, children: action.text })), onClose && (_jsx(DismissButton, { "$type": type, onClick: handleClose, "aria-label": "Dismiss", children: _jsx(CloseIcon, {}) }))] }), showProgress && duration && (_jsx(ProgressBar, { "$type": type, "$duration": duration }))] }));
|
|
44
|
-
});
|
|
45
|
-
Toast.displayName = 'Toast';
|
|
46
|
-
export const ToastContainer = forwardRef(function ToastContainerComponent(props, ref) {
|
|
47
|
-
const { position = 'bottom-right', children, gap = '8px', ...rest } = props;
|
|
48
|
-
return (_jsx(ToastContainerElement, { ref: ref, "$position": position, "$gap": gap, "data-aui": "toast-container", ...rest, children: children }));
|
|
49
|
-
});
|
|
50
|
-
ToastContainer.displayName = 'ToastContainer';
|
|
1
|
+
"use strict";"use client";import{jsx as e,jsxs as n}from"react/jsx-runtime";import{forwardRef as p,useEffect as w,useCallback as x}from"react";import{ToastElement as I,ToastContainerElement as T,IconWrapper as $,ContentWrapper as W,Message as B,ActionsWrapper as b,ActionButton as j,DismissButton as E,ProgressBar as N}from"./elements";const A=()=>n("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e("polyline",{points:"22 4 12 14.01 9 11.01"})]}),D=()=>n("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("circle",{cx:"12",cy:"12",r:"10"}),e("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),L=()=>n("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),M=()=>n("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("circle",{cx:"12",cy:"12",r:"10"}),e("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),O=()=>n("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),P=a=>{switch(a){case"success":return e(A,{});case"error":return e(D,{});case"warning":return e(L,{});case"info":return e(M,{});default:return null}};export const Toast=p(function(c,l){const{message:u,type:t="default",isOpen:s=!0,onClose:o,action:r,icon:h,showIcon:y=!0,duration:i,showProgress:f=!1,className:m,...C}=c;w(()=>{if(i&&s&&o){const v=setTimeout(()=>{o()},i);return()=>clearTimeout(v)}},[i,s,o]);const g=x(()=>{o?.()},[o]),k=x(()=>{r?.onClick?.()},[r]),d=h??(y?P(t):null);return n(I,{ref:l,$type:t,$isOpen:s,$position:"bottom-right",role:"alert","aria-live":"assertive","data-aui":"toast",className:m,...C,children:[d&&e($,{$type:t,"aria-hidden":"true",children:d}),e(W,{children:e(B,{children:u})}),n(b,{children:[r&&e(j,{$type:t,onClick:k,"aria-label":r.ariaLabel||r.text,children:r.text}),o&&e(E,{$type:t,onClick:g,"aria-label":"Dismiss",children:e(O,{})})]}),f&&i&&e(N,{$type:t,$duration:i})]})});Toast.displayName="Toast";export const ToastContainer=p(function(c,l){const{position:u="bottom-right",children:t,gap:s="8px",...o}=c;return e(T,{ref:l,$position:u,$gap:s,"data-aui":"toast-container",...o,children:t})});ToastContainer.displayName="ToastContainer";
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { tokens } from '../../utils/designTokens';
|
|
3
|
-
import { breakpoints } from '../../utils/abstracts';
|
|
4
|
-
// Animations
|
|
5
|
-
const slideInRight = keyframes `
|
|
1
|
+
"use strict";import{styled as e,css as n,keyframes as i}from"styled-components";import{tokens as r}from"../../utils/designTokens";import{breakpoints as s}from"../../utils/abstracts";const a=i`
|
|
6
2
|
from {
|
|
7
3
|
transform: translateX(100%);
|
|
8
4
|
opacity: 0;
|
|
@@ -11,8 +7,7 @@ const slideInRight = keyframes `
|
|
|
11
7
|
transform: translateX(0);
|
|
12
8
|
opacity: 1;
|
|
13
9
|
}
|
|
14
|
-
|
|
15
|
-
const slideInLeft = keyframes `
|
|
10
|
+
`,c=i`
|
|
16
11
|
from {
|
|
17
12
|
transform: translateX(-100%);
|
|
18
13
|
opacity: 0;
|
|
@@ -21,8 +16,7 @@ const slideInLeft = keyframes `
|
|
|
21
16
|
transform: translateX(0);
|
|
22
17
|
opacity: 1;
|
|
23
18
|
}
|
|
24
|
-
|
|
25
|
-
const slideInUp = keyframes `
|
|
19
|
+
`,f=i`
|
|
26
20
|
from {
|
|
27
21
|
transform: translateY(100%);
|
|
28
22
|
opacity: 0;
|
|
@@ -31,8 +25,7 @@ const slideInUp = keyframes `
|
|
|
31
25
|
transform: translateY(0);
|
|
32
26
|
opacity: 1;
|
|
33
27
|
}
|
|
34
|
-
|
|
35
|
-
const slideInDown = keyframes `
|
|
28
|
+
`,l=i`
|
|
36
29
|
from {
|
|
37
30
|
transform: translateY(-100%);
|
|
38
31
|
opacity: 0;
|
|
@@ -41,181 +34,109 @@ const slideInDown = keyframes `
|
|
|
41
34
|
transform: translateY(0);
|
|
42
35
|
opacity: 1;
|
|
43
36
|
}
|
|
44
|
-
|
|
45
|
-
const progressShrink = keyframes `
|
|
37
|
+
`,p=i`
|
|
46
38
|
from {
|
|
47
39
|
width: 100%;
|
|
48
40
|
}
|
|
49
41
|
to {
|
|
50
42
|
width: 0%;
|
|
51
43
|
}
|
|
52
|
-
|
|
53
|
-
// Type styles
|
|
54
|
-
const typeStyles = {
|
|
55
|
-
default: {
|
|
56
|
-
bg: '#1f2937',
|
|
57
|
-
border: '#374151',
|
|
58
|
-
text: '#f9fafb',
|
|
59
|
-
icon: '#9ca3af',
|
|
60
|
-
accent: tokens.primary || '#454cbf',
|
|
61
|
-
},
|
|
62
|
-
success: {
|
|
63
|
-
bg: '#065f46',
|
|
64
|
-
border: '#10b981',
|
|
65
|
-
text: '#ecfdf5',
|
|
66
|
-
icon: '#10b981',
|
|
67
|
-
accent: '#10b981',
|
|
68
|
-
},
|
|
69
|
-
error: {
|
|
70
|
-
bg: '#991b1b',
|
|
71
|
-
border: '#ef4444',
|
|
72
|
-
text: '#fef2f2',
|
|
73
|
-
icon: '#ef4444',
|
|
74
|
-
accent: '#ef4444',
|
|
75
|
-
},
|
|
76
|
-
warning: {
|
|
77
|
-
bg: '#92400e',
|
|
78
|
-
border: '#f59e0b',
|
|
79
|
-
text: '#fffbeb',
|
|
80
|
-
icon: '#f59e0b',
|
|
81
|
-
accent: '#f59e0b',
|
|
82
|
-
},
|
|
83
|
-
info: {
|
|
84
|
-
bg: '#1e40af',
|
|
85
|
-
border: '#3b82f6',
|
|
86
|
-
text: '#e7f3ff',
|
|
87
|
-
icon: '#3b82f6',
|
|
88
|
-
accent: '#3b82f6',
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
const getPositionStyles = (position) => {
|
|
92
|
-
switch (position) {
|
|
93
|
-
case 'top-left':
|
|
94
|
-
return css `
|
|
44
|
+
`,o={default:{bg:"#1f2937",border:"#374151",text:"#f9fafb",icon:"#9ca3af",accent:r.primary||"#454cbf"},success:{bg:"#065f46",border:"#10b981",text:"#ecfdf5",icon:"#10b981",accent:"#10b981"},error:{bg:"#991b1b",border:"#ef4444",text:"#fef2f2",icon:"#ef4444",accent:"#ef4444"},warning:{bg:"#92400e",border:"#f59e0b",text:"#fffbeb",icon:"#f59e0b",accent:"#f59e0b"},info:{bg:"#1e40af",border:"#3b82f6",text:"#e7f3ff",icon:"#3b82f6",accent:"#3b82f6"}},d=t=>{switch(t){case"top-left":return n`
|
|
95
45
|
top: 1rem;
|
|
96
46
|
left: 1rem;
|
|
97
47
|
align-items: flex-start;
|
|
98
|
-
`;
|
|
99
|
-
case 'top-center':
|
|
100
|
-
return css `
|
|
48
|
+
`;case"top-center":return n`
|
|
101
49
|
top: 1rem;
|
|
102
50
|
left: 50%;
|
|
103
51
|
transform: translateX(-50%);
|
|
104
52
|
align-items: center;
|
|
105
|
-
`;
|
|
106
|
-
case 'top-right':
|
|
107
|
-
return css `
|
|
53
|
+
`;case"top-right":return n`
|
|
108
54
|
top: 1rem;
|
|
109
55
|
right: 1rem;
|
|
110
56
|
align-items: flex-end;
|
|
111
|
-
`;
|
|
112
|
-
case 'bottom-left':
|
|
113
|
-
return css `
|
|
57
|
+
`;case"bottom-left":return n`
|
|
114
58
|
bottom: 1rem;
|
|
115
59
|
left: 1rem;
|
|
116
60
|
align-items: flex-start;
|
|
117
|
-
`;
|
|
118
|
-
case 'bottom-center':
|
|
119
|
-
return css `
|
|
61
|
+
`;case"bottom-center":return n`
|
|
120
62
|
bottom: 1rem;
|
|
121
63
|
left: 50%;
|
|
122
64
|
transform: translateX(-50%);
|
|
123
65
|
align-items: center;
|
|
124
|
-
`;
|
|
125
|
-
case 'bottom-right':
|
|
126
|
-
default:
|
|
127
|
-
return css `
|
|
66
|
+
`;default:return n`
|
|
128
67
|
bottom: 1rem;
|
|
129
68
|
right: 1rem;
|
|
130
69
|
align-items: flex-end;
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
const getAnimation = (position) => {
|
|
135
|
-
if (position.includes('left'))
|
|
136
|
-
return slideInLeft;
|
|
137
|
-
if (position.includes('right'))
|
|
138
|
-
return slideInRight;
|
|
139
|
-
if (position.includes('top'))
|
|
140
|
-
return slideInDown;
|
|
141
|
-
return slideInUp;
|
|
142
|
-
};
|
|
143
|
-
export const ToastContainerElement = styled.div `
|
|
70
|
+
`}},m=t=>t.includes("left")?c:t.includes("right")?a:t.includes("top")?l:f;export const ToastContainerElement=e.div`
|
|
144
71
|
position: fixed;
|
|
145
72
|
z-index: 9999;
|
|
146
73
|
display: flex;
|
|
147
74
|
flex-direction: column;
|
|
148
|
-
gap: ${({
|
|
75
|
+
gap: ${({$gap:t})=>t};
|
|
149
76
|
pointer-events: none;
|
|
150
77
|
|
|
151
|
-
${({
|
|
78
|
+
${({$position:t})=>d(t)}
|
|
152
79
|
|
|
153
|
-
${
|
|
80
|
+
${s.xs} {
|
|
154
81
|
left: 1rem;
|
|
155
82
|
right: 1rem;
|
|
156
83
|
transform: none;
|
|
157
84
|
align-items: stretch;
|
|
158
85
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
display: ${({ $isOpen }) => ($isOpen ? 'flex' : 'none')};
|
|
86
|
+
`,ToastElement=e.div`
|
|
87
|
+
display: ${({$isOpen:t})=>t?"flex":"none"};
|
|
162
88
|
align-items: flex-start;
|
|
163
|
-
gap: ${
|
|
89
|
+
gap: ${r.spacing150||"0.75rem"};
|
|
164
90
|
min-width: 280px;
|
|
165
91
|
max-width: 420px;
|
|
166
|
-
padding: ${
|
|
167
|
-
background: ${({
|
|
168
|
-
border: 1px solid ${({
|
|
169
|
-
border-radius: ${
|
|
170
|
-
color: ${({
|
|
92
|
+
padding: ${r.spacing150||"0.75rem"} ${r.spacing200||"1rem"};
|
|
93
|
+
background: ${({$type:t})=>o[t].bg};
|
|
94
|
+
border: 1px solid ${({$type:t})=>o[t].border};
|
|
95
|
+
border-radius: ${r.borderRadius100||"8px"};
|
|
96
|
+
color: ${({$type:t})=>o[t].text};
|
|
171
97
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
172
98
|
pointer-events: auto;
|
|
173
99
|
overflow: hidden;
|
|
174
100
|
position: relative;
|
|
175
101
|
|
|
176
|
-
animation: ${({
|
|
102
|
+
animation: ${({$position:t})=>m(t)} 0.3s ease-out;
|
|
177
103
|
|
|
178
|
-
${
|
|
104
|
+
${s.xs} {
|
|
179
105
|
min-width: unset;
|
|
180
106
|
max-width: unset;
|
|
181
107
|
width: 100%;
|
|
182
108
|
}
|
|
183
|
-
|
|
184
|
-
export const IconWrapper = styled.span `
|
|
109
|
+
`,IconWrapper=e.span`
|
|
185
110
|
display: flex;
|
|
186
111
|
align-items: center;
|
|
187
112
|
justify-content: center;
|
|
188
113
|
flex-shrink: 0;
|
|
189
114
|
width: 20px;
|
|
190
115
|
height: 20px;
|
|
191
|
-
color: ${({
|
|
116
|
+
color: ${({$type:t})=>o[t].icon};
|
|
192
117
|
|
|
193
118
|
svg {
|
|
194
119
|
width: 100%;
|
|
195
120
|
height: 100%;
|
|
196
121
|
}
|
|
197
|
-
|
|
198
|
-
export const ContentWrapper = styled.div `
|
|
122
|
+
`,ContentWrapper=e.div`
|
|
199
123
|
flex: 1;
|
|
200
124
|
min-width: 0;
|
|
201
|
-
|
|
202
|
-
export const Message = styled.div `
|
|
125
|
+
`,Message=e.div`
|
|
203
126
|
font-size: 0.875rem;
|
|
204
127
|
line-height: 1.5;
|
|
205
128
|
word-break: break-word;
|
|
206
|
-
|
|
207
|
-
export const ActionsWrapper = styled.div `
|
|
129
|
+
`,ActionsWrapper=e.div`
|
|
208
130
|
display: flex;
|
|
209
131
|
align-items: center;
|
|
210
|
-
gap: ${
|
|
132
|
+
gap: ${r.spacing100||"0.5rem"};
|
|
211
133
|
flex-shrink: 0;
|
|
212
|
-
|
|
213
|
-
export const ActionButton = styled.button `
|
|
134
|
+
`,ActionButton=e.button`
|
|
214
135
|
background: transparent;
|
|
215
|
-
border: 1px solid ${({
|
|
136
|
+
border: 1px solid ${({$type:t})=>o[t].border};
|
|
216
137
|
color: inherit;
|
|
217
138
|
padding: 0.25rem 0.625rem;
|
|
218
|
-
border-radius: ${
|
|
139
|
+
border-radius: ${r.borderRadius050||"4px"};
|
|
219
140
|
font-size: 0.8125rem;
|
|
220
141
|
font-weight: 500;
|
|
221
142
|
cursor: pointer;
|
|
@@ -227,11 +148,10 @@ export const ActionButton = styled.button `
|
|
|
227
148
|
}
|
|
228
149
|
|
|
229
150
|
&:focus-visible {
|
|
230
|
-
outline: 2px solid ${({
|
|
151
|
+
outline: 2px solid ${({$type:t})=>o[t].accent};
|
|
231
152
|
outline-offset: 2px;
|
|
232
153
|
}
|
|
233
|
-
|
|
234
|
-
export const DismissButton = styled.button `
|
|
154
|
+
`,DismissButton=e.button`
|
|
235
155
|
display: flex;
|
|
236
156
|
align-items: center;
|
|
237
157
|
justify-content: center;
|
|
@@ -239,7 +159,7 @@ export const DismissButton = styled.button `
|
|
|
239
159
|
border: none;
|
|
240
160
|
color: inherit;
|
|
241
161
|
padding: 0.25rem;
|
|
242
|
-
border-radius: ${
|
|
162
|
+
border-radius: ${r.borderRadius050||"4px"};
|
|
243
163
|
cursor: pointer;
|
|
244
164
|
transition: all 0.2s ease;
|
|
245
165
|
opacity: 0.7;
|
|
@@ -253,7 +173,7 @@ export const DismissButton = styled.button `
|
|
|
253
173
|
}
|
|
254
174
|
|
|
255
175
|
&:focus-visible {
|
|
256
|
-
outline: 2px solid ${({
|
|
176
|
+
outline: 2px solid ${({$type:t})=>o[t].accent};
|
|
257
177
|
outline-offset: 2px;
|
|
258
178
|
}
|
|
259
179
|
|
|
@@ -261,12 +181,11 @@ export const DismissButton = styled.button `
|
|
|
261
181
|
width: 100%;
|
|
262
182
|
height: 100%;
|
|
263
183
|
}
|
|
264
|
-
|
|
265
|
-
export const ProgressBar = styled.div `
|
|
184
|
+
`,ProgressBar=e.div`
|
|
266
185
|
position: absolute;
|
|
267
186
|
bottom: 0;
|
|
268
187
|
left: 0;
|
|
269
188
|
height: 3px;
|
|
270
|
-
background: ${({
|
|
271
|
-
animation: ${
|
|
189
|
+
background: ${({$type:t})=>o[t].accent};
|
|
190
|
+
animation: ${p} ${({$duration:t})=>t}ms linear forwards;
|
|
272
191
|
`;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './types';
|
|
1
|
+
"use strict";export{Toast,ToastContainer}from"./Toast";export*from"./types";
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
export const TOAST_TYPES
|
|
2
|
-
export const TOAST_POSITIONS = [
|
|
3
|
-
'top-left',
|
|
4
|
-
'top-center',
|
|
5
|
-
'top-right',
|
|
6
|
-
'bottom-left',
|
|
7
|
-
'bottom-center',
|
|
8
|
-
'bottom-right',
|
|
9
|
-
];
|
|
1
|
+
"use strict";export const TOAST_TYPES=["default","success","error","warning","info"],TOAST_POSITIONS=["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"];
|