@mantine/core 9.1.1 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/Autocomplete/Autocomplete.cjs +5 -1
- package/cjs/components/Autocomplete/Autocomplete.cjs.map +1 -1
- package/cjs/components/Checkbox/Checkbox.cjs +4 -1
- package/cjs/components/Checkbox/Checkbox.cjs.map +1 -1
- package/cjs/components/ColorInput/ColorInput.cjs +5 -1
- package/cjs/components/ColorInput/ColorInput.cjs.map +1 -1
- package/cjs/components/Combobox/use-pills-reorder/move-pill.cjs +17 -0
- package/cjs/components/Combobox/use-pills-reorder/move-pill.cjs.map +1 -0
- package/cjs/components/Combobox/use-pills-reorder/use-pills-reorder.cjs +170 -0
- package/cjs/components/Combobox/use-pills-reorder/use-pills-reorder.cjs.map +1 -0
- package/cjs/components/FileInput/FileInput.cjs +5 -1
- package/cjs/components/FileInput/FileInput.cjs.map +1 -1
- package/cjs/components/Input/use-input-props.cjs +5 -1
- package/cjs/components/Input/use-input-props.cjs.map +1 -1
- package/cjs/components/JsonInput/JsonInput.cjs +5 -2
- package/cjs/components/JsonInput/JsonInput.cjs.map +1 -1
- package/cjs/components/MaskInput/MaskInput.cjs +5 -1
- package/cjs/components/MaskInput/MaskInput.cjs.map +1 -1
- package/cjs/components/MaskInput/use-mask-input-props.cjs +3 -2
- package/cjs/components/MaskInput/use-mask-input-props.cjs.map +1 -1
- package/cjs/components/MultiSelect/MultiSelect.cjs +19 -3
- package/cjs/components/MultiSelect/MultiSelect.cjs.map +1 -1
- package/cjs/components/NativeSelect/NativeSelect.cjs +5 -1
- package/cjs/components/NativeSelect/NativeSelect.cjs.map +1 -1
- package/cjs/components/NumberInput/NumberInput.cjs +5 -1
- package/cjs/components/NumberInput/NumberInput.cjs.map +1 -1
- package/cjs/components/PasswordInput/PasswordInput.cjs +5 -1
- package/cjs/components/PasswordInput/PasswordInput.cjs.map +1 -1
- package/cjs/components/Pill/Pill.module.cjs.map +1 -1
- package/cjs/components/PillsInput/PillsInput.cjs +5 -1
- package/cjs/components/PillsInput/PillsInput.cjs.map +1 -1
- package/cjs/components/PinInput/PinInput.cjs +1 -1
- package/cjs/components/PinInput/PinInput.cjs.map +1 -1
- package/cjs/components/RollingNumber/DigitColumn.cjs +46 -0
- package/cjs/components/RollingNumber/DigitColumn.cjs.map +1 -0
- package/cjs/components/RollingNumber/RollingNumber.cjs +102 -0
- package/cjs/components/RollingNumber/RollingNumber.cjs.map +1 -0
- package/cjs/components/RollingNumber/RollingNumber.module.cjs +13 -0
- package/cjs/components/RollingNumber/RollingNumber.module.cjs.map +1 -0
- package/cjs/components/RollingNumber/build-value.cjs +22 -0
- package/cjs/components/RollingNumber/build-value.cjs.map +1 -0
- package/cjs/components/RollingNumber/get-digit-parts.cjs +40 -0
- package/cjs/components/RollingNumber/get-digit-parts.cjs.map +1 -0
- package/cjs/components/RollingNumber/get-render-slots.cjs +78 -0
- package/cjs/components/RollingNumber/get-render-slots.cjs.map +1 -0
- package/cjs/components/Select/Select.cjs +5 -1
- package/cjs/components/Select/Select.cjs.map +1 -1
- package/cjs/components/TagsInput/TagsInput.cjs +19 -4
- package/cjs/components/TagsInput/TagsInput.cjs.map +1 -1
- package/cjs/components/TextInput/TextInput.cjs +5 -1
- package/cjs/components/TextInput/TextInput.cjs.map +1 -1
- package/cjs/components/Textarea/Textarea.cjs +5 -2
- package/cjs/components/Textarea/Textarea.cjs.map +1 -1
- package/cjs/components/Tree/is-node-checked/is-node-checked.cjs +1 -0
- package/cjs/components/Tree/is-node-indeterminate/is-node-indeterminate.cjs +1 -0
- package/cjs/components/TreeSelect/TreeSelect.cjs +601 -0
- package/cjs/components/TreeSelect/TreeSelect.cjs.map +1 -0
- package/cjs/components/TreeSelect/TreeSelect.module.cjs +16 -0
- package/cjs/components/TreeSelect/TreeSelect.module.cjs.map +1 -0
- package/cjs/components/TreeSelect/TreeSelectOption.cjs +95 -0
- package/cjs/components/TreeSelect/TreeSelectOption.cjs.map +1 -0
- package/cjs/components/TreeSelect/flatten-tree-select-data.cjs +34 -0
- package/cjs/components/TreeSelect/flatten-tree-select-data.cjs.map +1 -0
- package/cjs/components/TreeSelect/get-checked-values-by-strategy.cjs +30 -0
- package/cjs/components/TreeSelect/get-checked-values-by-strategy.cjs.map +1 -0
- package/cjs/core/MantineProvider/use-props/use-props.cjs +10 -2
- package/cjs/core/MantineProvider/use-props/use-props.cjs.map +1 -1
- package/cjs/index.cjs +8 -0
- package/esm/components/Autocomplete/Autocomplete.mjs +5 -1
- package/esm/components/Autocomplete/Autocomplete.mjs.map +1 -1
- package/esm/components/Checkbox/Checkbox.mjs +4 -1
- package/esm/components/Checkbox/Checkbox.mjs.map +1 -1
- package/esm/components/ColorInput/ColorInput.mjs +5 -1
- package/esm/components/ColorInput/ColorInput.mjs.map +1 -1
- package/esm/components/Combobox/use-pills-reorder/move-pill.mjs +17 -0
- package/esm/components/Combobox/use-pills-reorder/move-pill.mjs.map +1 -0
- package/esm/components/Combobox/use-pills-reorder/use-pills-reorder.mjs +169 -0
- package/esm/components/Combobox/use-pills-reorder/use-pills-reorder.mjs.map +1 -0
- package/esm/components/FileInput/FileInput.mjs +5 -1
- package/esm/components/FileInput/FileInput.mjs.map +1 -1
- package/esm/components/Input/use-input-props.mjs +5 -1
- package/esm/components/Input/use-input-props.mjs.map +1 -1
- package/esm/components/JsonInput/JsonInput.mjs +5 -2
- package/esm/components/JsonInput/JsonInput.mjs.map +1 -1
- package/esm/components/MaskInput/MaskInput.mjs +5 -1
- package/esm/components/MaskInput/MaskInput.mjs.map +1 -1
- package/esm/components/MaskInput/use-mask-input-props.mjs +4 -3
- package/esm/components/MaskInput/use-mask-input-props.mjs.map +1 -1
- package/esm/components/MultiSelect/MultiSelect.mjs +19 -3
- package/esm/components/MultiSelect/MultiSelect.mjs.map +1 -1
- package/esm/components/NativeSelect/NativeSelect.mjs +5 -1
- package/esm/components/NativeSelect/NativeSelect.mjs.map +1 -1
- package/esm/components/NumberInput/NumberInput.mjs +5 -1
- package/esm/components/NumberInput/NumberInput.mjs.map +1 -1
- package/esm/components/PasswordInput/PasswordInput.mjs +5 -1
- package/esm/components/PasswordInput/PasswordInput.mjs.map +1 -1
- package/esm/components/Pill/Pill.module.mjs.map +1 -1
- package/esm/components/PillsInput/PillsInput.mjs +5 -1
- package/esm/components/PillsInput/PillsInput.mjs.map +1 -1
- package/esm/components/PinInput/PinInput.mjs +1 -1
- package/esm/components/PinInput/PinInput.mjs.map +1 -1
- package/esm/components/RollingNumber/DigitColumn.mjs +45 -0
- package/esm/components/RollingNumber/DigitColumn.mjs.map +1 -0
- package/esm/components/RollingNumber/RollingNumber.mjs +101 -0
- package/esm/components/RollingNumber/RollingNumber.mjs.map +1 -0
- package/esm/components/RollingNumber/RollingNumber.module.mjs +13 -0
- package/esm/components/RollingNumber/RollingNumber.module.mjs.map +1 -0
- package/esm/components/RollingNumber/build-value.mjs +22 -0
- package/esm/components/RollingNumber/build-value.mjs.map +1 -0
- package/esm/components/RollingNumber/get-digit-parts.mjs +40 -0
- package/esm/components/RollingNumber/get-digit-parts.mjs.map +1 -0
- package/esm/components/RollingNumber/get-render-slots.mjs +78 -0
- package/esm/components/RollingNumber/get-render-slots.mjs.map +1 -0
- package/esm/components/Select/Select.mjs +5 -1
- package/esm/components/Select/Select.mjs.map +1 -1
- package/esm/components/TagsInput/TagsInput.mjs +19 -4
- package/esm/components/TagsInput/TagsInput.mjs.map +1 -1
- package/esm/components/TextInput/TextInput.mjs +5 -1
- package/esm/components/TextInput/TextInput.mjs.map +1 -1
- package/esm/components/Textarea/Textarea.mjs +5 -2
- package/esm/components/Textarea/Textarea.mjs.map +1 -1
- package/esm/components/Tree/is-node-checked/is-node-checked.mjs +1 -1
- package/esm/components/Tree/is-node-indeterminate/is-node-indeterminate.mjs +1 -1
- package/esm/components/TreeSelect/TreeSelect.mjs +600 -0
- package/esm/components/TreeSelect/TreeSelect.mjs.map +1 -0
- package/esm/components/TreeSelect/TreeSelect.module.mjs +16 -0
- package/esm/components/TreeSelect/TreeSelect.module.mjs.map +1 -0
- package/esm/components/TreeSelect/TreeSelectOption.mjs +94 -0
- package/esm/components/TreeSelect/TreeSelectOption.mjs.map +1 -0
- package/esm/components/TreeSelect/flatten-tree-select-data.mjs +34 -0
- package/esm/components/TreeSelect/flatten-tree-select-data.mjs.map +1 -0
- package/esm/components/TreeSelect/get-checked-values-by-strategy.mjs +29 -0
- package/esm/components/TreeSelect/get-checked-values-by-strategy.mjs.map +1 -0
- package/esm/core/MantineProvider/use-props/use-props.mjs +10 -2
- package/esm/core/MantineProvider/use-props/use-props.mjs.map +1 -1
- package/esm/index.mjs +5 -1
- package/lib/components/Combobox/Combobox.types.d.ts +3 -0
- package/lib/components/Combobox/index.d.ts +2 -0
- package/lib/components/Combobox/use-pills-reorder/move-pill.d.ts +2 -0
- package/lib/components/Combobox/use-pills-reorder/use-pills-reorder.d.ts +26 -0
- package/lib/components/MaskInput/MaskInput.d.ts +2 -0
- package/lib/components/MultiSelect/MultiSelect.d.ts +2 -0
- package/lib/components/RollingNumber/DigitColumn.d.ts +11 -0
- package/lib/components/RollingNumber/RollingNumber.d.ts +41 -0
- package/lib/components/RollingNumber/build-value.d.ts +10 -0
- package/lib/components/RollingNumber/get-digit-parts.d.ts +12 -0
- package/lib/components/RollingNumber/get-render-slots.d.ts +35 -0
- package/lib/components/RollingNumber/index.d.ts +9 -0
- package/lib/components/TagsInput/TagsInput.d.ts +2 -0
- package/lib/components/TreeSelect/TreeSelect.d.ts +124 -0
- package/lib/components/TreeSelect/TreeSelectOption.d.ts +36 -0
- package/lib/components/TreeSelect/flatten-tree-select-data.d.ts +12 -0
- package/lib/components/TreeSelect/get-checked-values-by-strategy.d.ts +4 -0
- package/lib/components/TreeSelect/index.d.ts +13 -0
- package/lib/components/index.d.ts +2 -0
- package/lib/core/MantineProvider/use-props/use-props.d.ts +1 -1
- package/package.json +2 -2
- package/styles/Pill.css +35 -0
- package/styles/Pill.layer.css +35 -0
- package/styles/RollingNumber.css +60 -0
- package/styles/RollingNumber.layer.css +61 -0
- package/styles/TreeSelect.css +113 -0
- package/styles/TreeSelect.layer.css +114 -0
- package/styles.css +210 -0
- package/styles.layer.css +210 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pill.module.cjs","names":[],"sources":["../../../src/components/Pill/Pill.module.css"],"sourcesContent":[".root {\n --pill-fz-xs: 10px;\n --pill-fz-sm: 12px;\n --pill-fz-md: 14px;\n --pill-fz-lg: 16px;\n --pill-fz-xl: 18px;\n\n --pill-height-xs: 18px;\n --pill-height-sm: 22px;\n --pill-height-md: 25px;\n --pill-height-lg: 28px;\n --pill-height-xl: 32px;\n\n --pill-fz: var(--pill-fz-sm);\n --pill-height: var(--pill-height-sm);\n\n font-size: var(--pill-fz);\n flex: 0;\n height: var(--pill-height);\n padding-inline: 0.8em;\n display: inline-flex;\n align-items: center;\n border-radius: var(--pill-radius, 1000rem);\n line-height: 1;\n white-space: nowrap;\n user-select: none;\n -webkit-user-select: none;\n max-width: 100%;\n\n @mixin where-dark {\n background-color: var(--mantine-color-dark-7);\n color: var(--mantine-color-dark-0);\n }\n\n @mixin where-light {\n color: var(--mantine-color-black);\n }\n\n &:where([data-with-remove]:not(:has(button:disabled))) {\n padding-inline-end: 0;\n }\n\n &:where([data-disabled], :has(button:disabled)) {\n cursor: not-allowed;\n }\n}\n\n.root--default {\n @mixin where-light {\n background-color: var(--mantine-color-gray-1);\n\n &:where([data-disabled], :has(button:disabled)) {\n background-color: var(--mantine-color-disabled);\n }\n }\n}\n\n.root--contrast {\n @mixin where-light {\n background-color: var(--mantine-color-white);\n\n &:where([data-disabled], :has(button:disabled)) {\n background-color: var(--mantine-color-disabled);\n }\n }\n}\n\n.label {\n cursor: inherit;\n overflow: hidden;\n text-overflow: ellipsis;\n display: flex;\n align-items: center;\n height: 100%;\n text-box-trim: trim-both;\n text-box-edge: cap alphabetic;\n}\n\n.remove {\n color: inherit;\n font-size: inherit;\n height: 100%;\n min-height: unset;\n min-width: 2em;\n width: unset;\n border-radius: 0;\n padding-inline-start: 0.1em;\n padding-inline-end: 0.3em;\n flex: 0;\n border-end-end-radius: var(--pill-radius, 50%);\n border-start-end-radius: var(--pill-radius, 50%);\n\n .root[data-disabled] > &,\n &:disabled {\n display: none;\n background-color: transparent;\n width: 0.8em;\n min-width: 0.8em;\n padding: 0;\n cursor: not-allowed;\n\n & > svg {\n display: none;\n }\n }\n\n & > svg {\n pointer-events: none;\n }\n}\n\n.group {\n --pg-gap-xs: 6px;\n --pg-gap-sm: 8px;\n --pg-gap-md: 10px;\n --pg-gap-lg: 12px;\n --pg-gap-xl: 12px;\n --pg-gap: var(--pg-gap-sm);\n\n display: flex;\n align-items: center;\n gap: var(--pg-gap);\n flex-wrap: wrap;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Pill.module.cjs","names":[],"sources":["../../../src/components/Pill/Pill.module.css"],"sourcesContent":[".root {\n --pill-fz-xs: 10px;\n --pill-fz-sm: 12px;\n --pill-fz-md: 14px;\n --pill-fz-lg: 16px;\n --pill-fz-xl: 18px;\n\n --pill-height-xs: 18px;\n --pill-height-sm: 22px;\n --pill-height-md: 25px;\n --pill-height-lg: 28px;\n --pill-height-xl: 32px;\n\n --pill-fz: var(--pill-fz-sm);\n --pill-height: var(--pill-height-sm);\n\n font-size: var(--pill-fz);\n flex: 0;\n height: var(--pill-height);\n padding-inline: 0.8em;\n display: inline-flex;\n align-items: center;\n border-radius: var(--pill-radius, 1000rem);\n line-height: 1;\n white-space: nowrap;\n user-select: none;\n -webkit-user-select: none;\n max-width: 100%;\n position: relative;\n\n @mixin where-dark {\n background-color: var(--mantine-color-dark-7);\n color: var(--mantine-color-dark-0);\n }\n\n @mixin where-light {\n color: var(--mantine-color-black);\n }\n\n &:where([data-with-remove]:not(:has(button:disabled))) {\n padding-inline-end: 0;\n }\n\n &:where([data-disabled], :has(button:disabled)) {\n cursor: not-allowed;\n }\n\n &:where([draggable='true']) {\n cursor: grab;\n }\n\n &:where([draggable='true']):focus-visible {\n outline: 2px solid var(--mantine-primary-color-filled);\n outline-offset: 2px;\n }\n\n &:where([data-dragging]) {\n opacity: 0.4;\n cursor: grabbing;\n }\n\n &:where([data-drag-over='before'])::before,\n &:where([data-drag-over='after'])::after {\n content: '';\n position: absolute;\n top: 0;\n bottom: 0;\n width: rem(2px);\n background-color: var(--mantine-primary-color-filled);\n pointer-events: none;\n z-index: 1;\n }\n\n &:where([data-drag-over='before'])::before {\n inset-inline-start: rem(-4px);\n }\n\n &:where([data-drag-over='after'])::after {\n inset-inline-end: rem(-4px);\n }\n}\n\n.root--default {\n @mixin where-light {\n background-color: var(--mantine-color-gray-1);\n\n &:where([data-disabled], :has(button:disabled)) {\n background-color: var(--mantine-color-disabled);\n }\n }\n}\n\n.root--contrast {\n @mixin where-light {\n background-color: var(--mantine-color-white);\n\n &:where([data-disabled], :has(button:disabled)) {\n background-color: var(--mantine-color-disabled);\n }\n }\n}\n\n.label {\n cursor: inherit;\n overflow: hidden;\n text-overflow: ellipsis;\n display: flex;\n align-items: center;\n height: 100%;\n text-box-trim: trim-both;\n text-box-edge: cap alphabetic;\n}\n\n.remove {\n color: inherit;\n font-size: inherit;\n height: 100%;\n min-height: unset;\n min-width: 2em;\n width: unset;\n border-radius: 0;\n padding-inline-start: 0.1em;\n padding-inline-end: 0.3em;\n flex: 0;\n border-end-end-radius: var(--pill-radius, 50%);\n border-start-end-radius: var(--pill-radius, 50%);\n\n .root[data-disabled] > &,\n &:disabled {\n display: none;\n background-color: transparent;\n width: 0.8em;\n min-width: 0.8em;\n padding: 0;\n cursor: not-allowed;\n\n & > svg {\n display: none;\n }\n }\n\n & > svg {\n pointer-events: none;\n }\n}\n\n.group {\n --pg-gap-xs: 6px;\n --pg-gap-sm: 8px;\n --pg-gap-md: 10px;\n --pg-gap-lg: 12px;\n --pg-gap-xl: 12px;\n --pg-gap: var(--pg-gap-sm);\n\n display: flex;\n align-items: center;\n gap: var(--pg-gap);\n flex-wrap: wrap;\n}\n"],"mappings":""}
|
|
@@ -10,7 +10,11 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
10
10
|
//#region packages/@mantine/core/src/components/PillsInput/PillsInput.tsx
|
|
11
11
|
const defaultProps = { size: "sm" };
|
|
12
12
|
const PillsInput = require_factory.factory((_props) => {
|
|
13
|
-
const { children, onMouseDown, onClick, size, disabled, __staticSelector, error, variant, ...others } = require_use_props.useProps(
|
|
13
|
+
const { children, onMouseDown, onClick, size, disabled, __staticSelector, error, variant, ...others } = require_use_props.useProps([
|
|
14
|
+
"Input",
|
|
15
|
+
"InputWrapper",
|
|
16
|
+
"PillsInput"
|
|
17
|
+
], defaultProps, _props);
|
|
14
18
|
const fieldRef = (0, react.useRef)(null);
|
|
15
19
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillsInput_context.PillsInputContext, {
|
|
16
20
|
value: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PillsInput.cjs","names":["factory","useProps","PillsInputContext","InputBase","PillsInputField"],"sources":["../../../src/components/PillsInput/PillsInput.tsx"],"sourcesContent":["import { useRef } from 'react';\nimport { BoxProps, ElementProps, factory, Factory, StylesApiProps, useProps } from '../../core';\nimport { __BaseInputProps, __InputStylesNames } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { PillsInputContext, type PillsInputContextValue } from './PillsInput.context';\nimport {\n PillsInputField,\n type PillsInputFieldProps,\n type PillsInputFieldFactory,\n type PillsInputFieldStylesNames,\n} from './PillsInputField/PillsInputField';\nexport interface PillsInputProps\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<PillsInputFactory>,\n ElementProps<'div', 'size'> {\n __stylesApiProps?: Record<string, any>;\n __staticSelector?: string;\n}\n\nexport type PillsInputFactory = Factory<{\n props: PillsInputProps;\n ref: HTMLDivElement;\n stylesNames: __InputStylesNames;\n staticComponents: {\n Field: typeof PillsInputField;\n };\n}>;\n\nconst defaultProps = {\n size: 'sm',\n} satisfies Partial<PillsInputProps>;\n\nexport const PillsInput = factory<PillsInputFactory>((_props) => {\n const props = useProps('PillsInput', defaultProps, _props);\n const {\n children,\n onMouseDown,\n onClick,\n size,\n disabled,\n __staticSelector,\n error,\n variant,\n ...others\n } = props;\n\n const fieldRef = useRef<HTMLInputElement>(null);\n\n return (\n <PillsInputContext value={{ fieldRef, size, disabled, hasError: !!error, variant }}>\n <InputBase\n size={size}\n error={error}\n variant={variant}\n component=\"div\"\n data-no-overflow\n onMouseDown={(event) => {\n event.preventDefault();\n onMouseDown?.(event);\n fieldRef.current?.focus();\n }}\n onClick={(event) => {\n event.preventDefault();\n const fieldset = event.currentTarget.closest('fieldset');\n if (!fieldset?.disabled) {\n fieldRef.current?.focus();\n onClick?.(event);\n }\n }}\n {...others}\n multiline\n disabled={disabled}\n __staticSelector={__staticSelector || 'PillsInput'}\n withAria={false}\n >\n {children}\n </InputBase>\n </PillsInputContext>\n );\n});\n\nPillsInput.displayName = '@mantine/core/PillsInput';\nPillsInput.classes = InputBase.classes;\nPillsInput.Field = PillsInputField;\n\nexport namespace PillsInput {\n export type Props = PillsInputProps;\n export type Factory = PillsInputFactory;\n export type ContextValue = PillsInputContextValue;\n\n export namespace Field {\n export type Props = PillsInputFieldProps;\n export type Factory = PillsInputFieldFactory;\n export type StylesNames = PillsInputFieldStylesNames;\n }\n}\n"],"mappings":";;;;;;;;;;AA8BA,MAAM,eAAe,EACnB,MAAM,MACP;AAED,MAAa,aAAaA,gBAAAA,SAA4B,WAAW;CAE/D,MAAM,EACJ,UACA,aACA,SACA,MACA,UACA,kBACA,OACA,SACA,GAAG,WAVSC,kBAAAA,SAAS,
|
|
1
|
+
{"version":3,"file":"PillsInput.cjs","names":["factory","useProps","PillsInputContext","InputBase","PillsInputField"],"sources":["../../../src/components/PillsInput/PillsInput.tsx"],"sourcesContent":["import { useRef } from 'react';\nimport { BoxProps, ElementProps, factory, Factory, StylesApiProps, useProps } from '../../core';\nimport { __BaseInputProps, __InputStylesNames } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { PillsInputContext, type PillsInputContextValue } from './PillsInput.context';\nimport {\n PillsInputField,\n type PillsInputFieldProps,\n type PillsInputFieldFactory,\n type PillsInputFieldStylesNames,\n} from './PillsInputField/PillsInputField';\nexport interface PillsInputProps\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<PillsInputFactory>,\n ElementProps<'div', 'size'> {\n __stylesApiProps?: Record<string, any>;\n __staticSelector?: string;\n}\n\nexport type PillsInputFactory = Factory<{\n props: PillsInputProps;\n ref: HTMLDivElement;\n stylesNames: __InputStylesNames;\n staticComponents: {\n Field: typeof PillsInputField;\n };\n}>;\n\nconst defaultProps = {\n size: 'sm',\n} satisfies Partial<PillsInputProps>;\n\nexport const PillsInput = factory<PillsInputFactory>((_props) => {\n const props = useProps(['Input', 'InputWrapper', 'PillsInput'], defaultProps, _props);\n const {\n children,\n onMouseDown,\n onClick,\n size,\n disabled,\n __staticSelector,\n error,\n variant,\n ...others\n } = props;\n\n const fieldRef = useRef<HTMLInputElement>(null);\n\n return (\n <PillsInputContext value={{ fieldRef, size, disabled, hasError: !!error, variant }}>\n <InputBase\n size={size}\n error={error}\n variant={variant}\n component=\"div\"\n data-no-overflow\n onMouseDown={(event) => {\n event.preventDefault();\n onMouseDown?.(event);\n fieldRef.current?.focus();\n }}\n onClick={(event) => {\n event.preventDefault();\n const fieldset = event.currentTarget.closest('fieldset');\n if (!fieldset?.disabled) {\n fieldRef.current?.focus();\n onClick?.(event);\n }\n }}\n {...others}\n multiline\n disabled={disabled}\n __staticSelector={__staticSelector || 'PillsInput'}\n withAria={false}\n >\n {children}\n </InputBase>\n </PillsInputContext>\n );\n});\n\nPillsInput.displayName = '@mantine/core/PillsInput';\nPillsInput.classes = InputBase.classes;\nPillsInput.Field = PillsInputField;\n\nexport namespace PillsInput {\n export type Props = PillsInputProps;\n export type Factory = PillsInputFactory;\n export type ContextValue = PillsInputContextValue;\n\n export namespace Field {\n export type Props = PillsInputFieldProps;\n export type Factory = PillsInputFieldFactory;\n export type StylesNames = PillsInputFieldStylesNames;\n }\n}\n"],"mappings":";;;;;;;;;;AA8BA,MAAM,eAAe,EACnB,MAAM,MACP;AAED,MAAa,aAAaA,gBAAAA,SAA4B,WAAW;CAE/D,MAAM,EACJ,UACA,aACA,SACA,MACA,UACA,kBACA,OACA,SACA,GAAG,WAVSC,kBAAAA,SAAS;EAAC;EAAS;EAAgB;EAAa,EAAE,cAAc,OAAO;CAarF,MAAM,YAAA,GAAA,MAAA,QAAoC,KAAK;AAE/C,QACE,iBAAA,GAAA,kBAAA,KAACC,2BAAAA,mBAAD;EAAmB,OAAO;GAAE;GAAU;GAAM;GAAU,UAAU,CAAC,CAAC;GAAO;GAAS;YAChF,iBAAA,GAAA,kBAAA,KAACC,kBAAAA,WAAD;GACQ;GACC;GACE;GACT,WAAU;GACV,oBAAA;GACA,cAAc,UAAU;AACtB,UAAM,gBAAgB;AACtB,kBAAc,MAAM;AACpB,aAAS,SAAS,OAAO;;GAE3B,UAAU,UAAU;AAClB,UAAM,gBAAgB;AAEtB,QAAI,CADa,MAAM,cAAc,QAAQ,WAAW,EACzC,UAAU;AACvB,cAAS,SAAS,OAAO;AACzB,eAAU,MAAM;;;GAGpB,GAAI;GACJ,WAAA;GACU;GACV,kBAAkB,oBAAoB;GACtC,UAAU;GAET;GACS,CAAA;EACM,CAAA;EAEtB;AAEF,WAAW,cAAc;AACzB,WAAW,UAAUA,kBAAAA,UAAU;AAC/B,WAAW,QAAQC,wBAAAA"}
|
|
@@ -31,7 +31,7 @@ const defaultProps = {
|
|
|
31
31
|
};
|
|
32
32
|
const varsResolver = require_create_vars_resolver.createVarsResolver((_, { size }) => ({ root: { "--pin-input-size": require_get_size.getSize(size ?? "sm", "pin-input-size") } }));
|
|
33
33
|
const PinInput = require_factory.factory((props) => {
|
|
34
|
-
const { name, form, className, value, defaultValue, variant, gap, style, size, classNames, styles, unstyled, length, onChange, onComplete, manageFocus, autoFocus, error, radius, disabled, oneTimeCode, placeholder, type, mask, readOnly, inputType, inputMode, ariaLabel, vars, id, hiddenInputProps, rootRef, getInputProps, attributes, ref, ...others } = require_use_props.useProps("PinInput", defaultProps, props);
|
|
34
|
+
const { name, form, className, value, defaultValue, variant, gap, style, size, classNames, styles, unstyled, length, onChange, onComplete, manageFocus, autoFocus, error, radius, disabled, oneTimeCode, placeholder, type, mask, readOnly, inputType, inputMode, ariaLabel, vars, id, hiddenInputProps, rootRef, getInputProps, attributes, ref, ...others } = require_use_props.useProps(["Input", "PinInput"], defaultProps, props);
|
|
35
35
|
const uuid = (0, _mantine_hooks.useId)(id);
|
|
36
36
|
const getStyles = require_use_styles.useStyles({
|
|
37
37
|
name: "PinInput",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PinInput.cjs","names":["createVarsResolver","getSize","factory","useProps","useStyles","useResolvedStylesApi","createPinArray","Group","Input","classes","InputBase"],"sources":["../../../src/components/PinInput/PinInput.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { assignRef, useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n DataAttributes,\n ElementProps,\n Factory,\n factory,\n getSize,\n MantineRadius,\n MantineSize,\n MantineSpacing,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { Group } from '../Group';\nimport { Input, InputProps } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { createPinArray } from './create-pin-array/create-pin-array';\nimport classes from './PinInput.module.css';\n\nconst regex = {\n number: /^[0-9]+$/,\n alphanumeric: /^[a-zA-Z0-9]+$/i,\n};\n\nexport type PinInputStylesNames = 'root' | 'pinInput' | 'input';\n\nexport type PinInputCssVariables = {\n root: '--pin-input-size';\n};\n\nexport interface PinInputProps\n extends BoxProps, StylesApiProps<PinInputFactory>, ElementProps<'div', 'onChange' | 'ref'> {\n ref?: React.Ref<HTMLInputElement>;\n\n /** Hidden input `name` attribute */\n name?: string;\n\n /** Hidden input `form` attribute */\n form?: string;\n\n /** Key of `theme.spacing` or any valid CSS value to set `gap` between inputs, numbers are converted to rem @default 'md' */\n gap?: MantineSpacing;\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius`, numbers are converted to rem @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Controls inputs `width` and `height` @default 'sm' */\n size?: MantineSize;\n\n /** If set, the first input is focused when component is mounted @default false */\n autoFocus?: boolean;\n\n /** Controlled component value */\n value?: string;\n\n /** Uncontrolled component default value */\n defaultValue?: string;\n\n /** Called when value changes */\n onChange?: (value: string) => void;\n\n /** Called when all inputs have value */\n onComplete?: (value: string) => void;\n\n /** Inputs placeholder @default '○' */\n placeholder?: string;\n\n /** Determines whether focus should be moved automatically to the next input once filled @default true */\n manageFocus?: boolean;\n\n /** Determines whether `autocomplete=\"one-time-code\"` attribute should be set on all inputs @default true */\n oneTimeCode?: boolean;\n\n /** Base id used to generate unique ids for inputs */\n id?: string;\n\n /** Adds disabled attribute to all inputs */\n disabled?: boolean;\n\n /** Sets `aria-invalid` attribute and applies error styles to all inputs */\n error?: boolean;\n\n /** Determines which values can be entered @default 'alphanumeric' */\n type?: 'alphanumeric' | 'number' | RegExp;\n\n /** Changes input type to `\"password\"` @default false */\n mask?: boolean;\n\n /** Number of inputs @default 4 */\n length?: number;\n\n /** If set, the user cannot edit the value */\n readOnly?: boolean;\n\n /** Inputs `type` attribute, inferred from the `type` prop if not specified */\n inputType?: React.HTMLInputTypeAttribute;\n\n /** `inputmode` attribute, inferred from the `type` prop if not specified */\n inputMode?:\n | 'none'\n | 'text'\n | 'tel'\n | 'url'\n | 'email'\n | 'numeric'\n | 'decimal'\n | 'search'\n | undefined;\n\n /** `aria-label` attribute */\n ariaLabel?: string;\n\n /** Props passed down to the hidden input */\n hiddenInputProps?: React.ComponentProps<'input'>;\n\n /** Assigns ref of the root element */\n rootRef?: React.Ref<HTMLDivElement>;\n\n /** Props added to the input element depending on its index */\n getInputProps?: (index: number) => InputProps & ElementProps<'input', 'size'> & DataAttributes;\n}\n\nexport type PinInputFactory = Factory<{\n props: PinInputProps;\n ref: HTMLDivElement;\n stylesNames: PinInputStylesNames;\n vars: PinInputCssVariables;\n}>;\n\nconst defaultProps = {\n gap: 'sm',\n length: 4,\n manageFocus: true,\n oneTimeCode: true,\n placeholder: '○',\n type: 'alphanumeric',\n ariaLabel: 'PinInput',\n size: 'sm',\n} satisfies Partial<PinInputProps>;\n\nconst varsResolver = createVarsResolver<PinInputFactory>((_, { size }) => ({\n root: {\n '--pin-input-size': getSize(size ?? 'sm', 'pin-input-size'),\n },\n}));\n\nexport const PinInput = factory<PinInputFactory>((props) => {\n const {\n name,\n form,\n className,\n value,\n defaultValue,\n variant,\n gap,\n style,\n size,\n classNames,\n styles,\n unstyled,\n length,\n onChange,\n onComplete,\n manageFocus,\n autoFocus,\n error,\n radius,\n disabled,\n oneTimeCode,\n placeholder,\n type,\n mask,\n readOnly,\n inputType,\n inputMode,\n ariaLabel,\n vars,\n id,\n hiddenInputProps,\n rootRef,\n getInputProps,\n attributes,\n ref,\n ...others\n } = useProps('PinInput', defaultProps, props);\n\n const uuid = useId(id);\n\n const getStyles = useStyles<PinInputFactory>({\n name: 'PinInput',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<PinInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const [focusedIndex, setFocusedIndex] = useState(-1);\n const inputsRef = useRef<Array<HTMLInputElement>>([]);\n const currentLength = length ?? 4;\n\n const completedRef = useRef(false);\n\n const [_value, setValues] = useUncontrolled<string[]>({\n value: value !== undefined ? createPinArray(currentLength, value) : undefined,\n defaultValue: defaultValue?.split('').slice(0, currentLength),\n finalValue: createPinArray(currentLength, ''),\n onChange: (val) => {\n const stringValue = val.join('').trim();\n onChange?.(stringValue);\n if (stringValue.length === currentLength && !completedRef.current) {\n completedRef.current = true;\n onComplete?.(stringValue);\n } else if (stringValue.length < currentLength) {\n completedRef.current = false;\n }\n },\n });\n\n const currentValue =\n _value.length !== currentLength ? createPinArray(currentLength, _value.join('')) : _value;\n\n const _valueToString = currentValue.join('').trim();\n\n const validate = (code: string) => {\n const re = type instanceof RegExp ? type : type && type in regex ? regex[type] : null;\n return re?.test(code);\n };\n\n const focusInputField = (dir: 'next' | 'prev', index: number) => {\n if (!manageFocus) {\n return;\n }\n\n if (dir === 'next') {\n const nextIndex = index + 1;\n if (nextIndex < currentLength) {\n inputsRef.current[nextIndex]?.focus();\n }\n } else if (dir === 'prev') {\n const prevIndex = index - 1;\n if (prevIndex >= 0) {\n inputsRef.current[prevIndex]?.focus();\n }\n }\n };\n\n const setFieldValue = (val: string, index: number) => {\n const values = [...currentValue];\n values[index] = val;\n setValues(values);\n return values;\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>, index: number) => {\n const inputValue = event.target.value;\n\n if (inputValue.length > 1) {\n const isPaste = inputValue.length > 2;\n if (isPaste) {\n const isValid = validate(inputValue);\n if (isValid) {\n setValues(createPinArray(currentLength, inputValue));\n const filledCount = Math.min(inputValue.length, currentLength);\n if (filledCount < currentLength) {\n focusInputField('next', filledCount - 1);\n }\n }\n return;\n }\n\n const newChar = inputValue.split('')[inputValue.length - 1];\n if (validate(newChar)) {\n setFieldValue(newChar, index);\n focusInputField('next', index);\n }\n return;\n }\n\n if (inputValue.length === 1) {\n if (validate(inputValue)) {\n setFieldValue(inputValue, index);\n focusInputField('next', index);\n } else {\n setFieldValue('', index);\n }\n } else if (inputValue.length === 0) {\n setFieldValue('', index);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>, index: number) => {\n const { ctrlKey, metaKey, key, shiftKey, target } = event;\n const inputValue = (target as HTMLInputElement).value;\n\n if (inputMode === 'numeric') {\n const allowedKeys = ['Backspace', 'Tab', 'Control', 'Delete', 'ArrowLeft', 'ArrowRight'];\n const isPasteShortcut = (ctrlKey || metaKey) && key === 'v';\n const isAllowedKey =\n allowedKeys.includes(key) || isPasteShortcut || !Number.isNaN(Number(key));\n\n if (!isAllowedKey) {\n event.preventDefault();\n return;\n }\n }\n\n switch (key) {\n case 'ArrowLeft':\n event.preventDefault();\n focusInputField('prev', index);\n break;\n\n case 'ArrowRight':\n event.preventDefault();\n focusInputField('next', index);\n break;\n\n case 'Tab':\n if (shiftKey) {\n if (index > 0 && manageFocus) {\n event.preventDefault();\n focusInputField('prev', index);\n }\n }\n break;\n\n case ' ':\n event.preventDefault();\n focusInputField('next', index);\n break;\n\n case 'Delete':\n event.preventDefault();\n setFieldValue('', index);\n break;\n\n case 'Backspace':\n if (inputValue === '') {\n event.preventDefault();\n focusInputField('prev', index);\n } else {\n setFieldValue('', index);\n if (index < currentLength - 1) {\n event.preventDefault();\n focusInputField('prev', index);\n }\n }\n break;\n\n default:\n if (inputValue.length > 0 && key === currentValue[index]) {\n event.preventDefault();\n focusInputField('next', index);\n }\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>, index: number) => {\n event.target.select();\n setFocusedIndex(index);\n };\n\n const handleBlur = () => {\n setFocusedIndex(-1);\n };\n\n const handlePaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n event.preventDefault();\n const pasteData = event.clipboardData.getData('text/plain').replace(/[\\n\\r\\s]+/g, '');\n const isValid = validate(pasteData.trim());\n\n if (isValid) {\n const pasteArray = createPinArray(currentLength, pasteData);\n setValues(pasteArray);\n const filledCount = pasteArray.filter((val) => val !== '').length;\n if (filledCount >= currentLength) {\n inputsRef.current[currentLength - 1]?.focus();\n } else {\n inputsRef.current[filledCount]?.focus();\n }\n }\n };\n\n return (\n <>\n <Group\n {...others}\n {...getStyles('root')}\n ref={rootRef}\n role=\"group\"\n id={uuid}\n gap={gap}\n unstyled={unstyled}\n wrap=\"nowrap\"\n variant={variant}\n __size={size}\n dir=\"ltr\"\n >\n {currentValue.map((char: string, index: number) => (\n <Input\n component=\"input\"\n {...getStyles('pinInput', {\n style: {\n '--input-padding': '0',\n '--input-text-align': 'center',\n } as React.CSSProperties,\n })}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n size={size}\n __staticSelector=\"PinInput\"\n id={`${uuid}-${index + 1}`}\n key={`${uuid}-${index}`}\n inputMode={inputMode || (type === 'number' ? 'numeric' : 'text')}\n onChange={(event) => handleChange(event, index)}\n onKeyDown={(event) => handleKeyDown(event, index)}\n onFocus={(event) => handleFocus(event, index)}\n onBlur={handleBlur}\n onPaste={handlePaste}\n type={inputType || (mask ? 'password' : type === 'number' ? 'tel' : 'text')}\n radius={radius}\n error={error}\n variant={variant}\n disabled={disabled}\n ref={(node) => {\n if (node) {\n index === 0 && assignRef(ref, node);\n inputsRef.current[index] = node;\n }\n }}\n autoComplete={oneTimeCode ? 'one-time-code' : 'off'}\n placeholder={focusedIndex === index ? '' : placeholder}\n value={char}\n autoFocus={autoFocus && index === 0}\n unstyled={unstyled}\n aria-label={ariaLabel}\n readOnly={readOnly}\n {...getInputProps?.(index)}\n />\n ))}\n </Group>\n\n <input type=\"hidden\" name={name} form={form} value={_valueToString} {...hiddenInputProps} />\n </>\n );\n});\n\nPinInput.classes = { ...classes, ...InputBase.classes };\nPinInput.varsResolver = varsResolver;\nPinInput.displayName = '@mantine/core/PinInput';\n\nexport namespace PinInput {\n export type Props = PinInputProps;\n export type StylesNames = PinInputStylesNames;\n export type Factory = PinInputFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,MAAM,QAAQ;CACZ,QAAQ;CACR,cAAc;CACf;AA2GD,MAAM,eAAe;CACnB,KAAK;CACL,QAAQ;CACR,aAAa;CACb,aAAa;CACb,aAAa;CACb,MAAM;CACN,WAAW;CACX,MAAM;CACP;AAED,MAAM,eAAeA,6BAAAA,oBAAqC,GAAG,EAAE,YAAY,EACzE,MAAM,EACJ,oBAAoBC,iBAAAA,QAAQ,QAAQ,MAAM,iBAAiB,EAC5D,EACF,EAAE;AAEH,M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ACF;GACV,GAAI,gBAAgB,MAAM;GAC1B,CAAA,CACF;EACI,CAAA,EAER,iBAAA,GAAA,kBAAA,KAAC,SAAD;EAAO,MAAK;EAAe;EAAY;EAAM,OAAO;EAAgB,GAAI;EAAoB,CAAA,CAC3F,EAAA,CAAA;EAEL;AAEF,SAAS,UAAU;CAAE,GAAGC,wBAAAA;CAAS,GAAGC,kBAAAA,UAAU;CAAS;AACvD,SAAS,eAAe;AACxB,SAAS,cAAc"}
|
|
1
|
+
{"version":3,"file":"PinInput.cjs","names":["createVarsResolver","getSize","factory","useProps","useStyles","useResolvedStylesApi","createPinArray","Group","Input","classes","InputBase"],"sources":["../../../src/components/PinInput/PinInput.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { assignRef, useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n DataAttributes,\n ElementProps,\n Factory,\n factory,\n getSize,\n MantineRadius,\n MantineSize,\n MantineSpacing,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { Group } from '../Group';\nimport { Input, InputProps } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { createPinArray } from './create-pin-array/create-pin-array';\nimport classes from './PinInput.module.css';\n\nconst regex = {\n number: /^[0-9]+$/,\n alphanumeric: /^[a-zA-Z0-9]+$/i,\n};\n\nexport type PinInputStylesNames = 'root' | 'pinInput' | 'input';\n\nexport type PinInputCssVariables = {\n root: '--pin-input-size';\n};\n\nexport interface PinInputProps\n extends BoxProps, StylesApiProps<PinInputFactory>, ElementProps<'div', 'onChange' | 'ref'> {\n ref?: React.Ref<HTMLInputElement>;\n\n /** Hidden input `name` attribute */\n name?: string;\n\n /** Hidden input `form` attribute */\n form?: string;\n\n /** Key of `theme.spacing` or any valid CSS value to set `gap` between inputs, numbers are converted to rem @default 'md' */\n gap?: MantineSpacing;\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius`, numbers are converted to rem @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Controls inputs `width` and `height` @default 'sm' */\n size?: MantineSize;\n\n /** If set, the first input is focused when component is mounted @default false */\n autoFocus?: boolean;\n\n /** Controlled component value */\n value?: string;\n\n /** Uncontrolled component default value */\n defaultValue?: string;\n\n /** Called when value changes */\n onChange?: (value: string) => void;\n\n /** Called when all inputs have value */\n onComplete?: (value: string) => void;\n\n /** Inputs placeholder @default '○' */\n placeholder?: string;\n\n /** Determines whether focus should be moved automatically to the next input once filled @default true */\n manageFocus?: boolean;\n\n /** Determines whether `autocomplete=\"one-time-code\"` attribute should be set on all inputs @default true */\n oneTimeCode?: boolean;\n\n /** Base id used to generate unique ids for inputs */\n id?: string;\n\n /** Adds disabled attribute to all inputs */\n disabled?: boolean;\n\n /** Sets `aria-invalid` attribute and applies error styles to all inputs */\n error?: boolean;\n\n /** Determines which values can be entered @default 'alphanumeric' */\n type?: 'alphanumeric' | 'number' | RegExp;\n\n /** Changes input type to `\"password\"` @default false */\n mask?: boolean;\n\n /** Number of inputs @default 4 */\n length?: number;\n\n /** If set, the user cannot edit the value */\n readOnly?: boolean;\n\n /** Inputs `type` attribute, inferred from the `type` prop if not specified */\n inputType?: React.HTMLInputTypeAttribute;\n\n /** `inputmode` attribute, inferred from the `type` prop if not specified */\n inputMode?:\n | 'none'\n | 'text'\n | 'tel'\n | 'url'\n | 'email'\n | 'numeric'\n | 'decimal'\n | 'search'\n | undefined;\n\n /** `aria-label` attribute */\n ariaLabel?: string;\n\n /** Props passed down to the hidden input */\n hiddenInputProps?: React.ComponentProps<'input'>;\n\n /** Assigns ref of the root element */\n rootRef?: React.Ref<HTMLDivElement>;\n\n /** Props added to the input element depending on its index */\n getInputProps?: (index: number) => InputProps & ElementProps<'input', 'size'> & DataAttributes;\n}\n\nexport type PinInputFactory = Factory<{\n props: PinInputProps;\n ref: HTMLDivElement;\n stylesNames: PinInputStylesNames;\n vars: PinInputCssVariables;\n}>;\n\nconst defaultProps = {\n gap: 'sm',\n length: 4,\n manageFocus: true,\n oneTimeCode: true,\n placeholder: '○',\n type: 'alphanumeric',\n ariaLabel: 'PinInput',\n size: 'sm',\n} satisfies Partial<PinInputProps>;\n\nconst varsResolver = createVarsResolver<PinInputFactory>((_, { size }) => ({\n root: {\n '--pin-input-size': getSize(size ?? 'sm', 'pin-input-size'),\n },\n}));\n\nexport const PinInput = factory<PinInputFactory>((props) => {\n const {\n name,\n form,\n className,\n value,\n defaultValue,\n variant,\n gap,\n style,\n size,\n classNames,\n styles,\n unstyled,\n length,\n onChange,\n onComplete,\n manageFocus,\n autoFocus,\n error,\n radius,\n disabled,\n oneTimeCode,\n placeholder,\n type,\n mask,\n readOnly,\n inputType,\n inputMode,\n ariaLabel,\n vars,\n id,\n hiddenInputProps,\n rootRef,\n getInputProps,\n attributes,\n ref,\n ...others\n } = useProps(['Input', 'PinInput'], defaultProps, props);\n\n const uuid = useId(id);\n\n const getStyles = useStyles<PinInputFactory>({\n name: 'PinInput',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<PinInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const [focusedIndex, setFocusedIndex] = useState(-1);\n const inputsRef = useRef<Array<HTMLInputElement>>([]);\n const currentLength = length ?? 4;\n\n const completedRef = useRef(false);\n\n const [_value, setValues] = useUncontrolled<string[]>({\n value: value !== undefined ? createPinArray(currentLength, value) : undefined,\n defaultValue: defaultValue?.split('').slice(0, currentLength),\n finalValue: createPinArray(currentLength, ''),\n onChange: (val) => {\n const stringValue = val.join('').trim();\n onChange?.(stringValue);\n if (stringValue.length === currentLength && !completedRef.current) {\n completedRef.current = true;\n onComplete?.(stringValue);\n } else if (stringValue.length < currentLength) {\n completedRef.current = false;\n }\n },\n });\n\n const currentValue =\n _value.length !== currentLength ? createPinArray(currentLength, _value.join('')) : _value;\n\n const _valueToString = currentValue.join('').trim();\n\n const validate = (code: string) => {\n const re = type instanceof RegExp ? type : type && type in regex ? regex[type] : null;\n return re?.test(code);\n };\n\n const focusInputField = (dir: 'next' | 'prev', index: number) => {\n if (!manageFocus) {\n return;\n }\n\n if (dir === 'next') {\n const nextIndex = index + 1;\n if (nextIndex < currentLength) {\n inputsRef.current[nextIndex]?.focus();\n }\n } else if (dir === 'prev') {\n const prevIndex = index - 1;\n if (prevIndex >= 0) {\n inputsRef.current[prevIndex]?.focus();\n }\n }\n };\n\n const setFieldValue = (val: string, index: number) => {\n const values = [...currentValue];\n values[index] = val;\n setValues(values);\n return values;\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>, index: number) => {\n const inputValue = event.target.value;\n\n if (inputValue.length > 1) {\n const isPaste = inputValue.length > 2;\n if (isPaste) {\n const isValid = validate(inputValue);\n if (isValid) {\n setValues(createPinArray(currentLength, inputValue));\n const filledCount = Math.min(inputValue.length, currentLength);\n if (filledCount < currentLength) {\n focusInputField('next', filledCount - 1);\n }\n }\n return;\n }\n\n const newChar = inputValue.split('')[inputValue.length - 1];\n if (validate(newChar)) {\n setFieldValue(newChar, index);\n focusInputField('next', index);\n }\n return;\n }\n\n if (inputValue.length === 1) {\n if (validate(inputValue)) {\n setFieldValue(inputValue, index);\n focusInputField('next', index);\n } else {\n setFieldValue('', index);\n }\n } else if (inputValue.length === 0) {\n setFieldValue('', index);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>, index: number) => {\n const { ctrlKey, metaKey, key, shiftKey, target } = event;\n const inputValue = (target as HTMLInputElement).value;\n\n if (inputMode === 'numeric') {\n const allowedKeys = ['Backspace', 'Tab', 'Control', 'Delete', 'ArrowLeft', 'ArrowRight'];\n const isPasteShortcut = (ctrlKey || metaKey) && key === 'v';\n const isAllowedKey =\n allowedKeys.includes(key) || isPasteShortcut || !Number.isNaN(Number(key));\n\n if (!isAllowedKey) {\n event.preventDefault();\n return;\n }\n }\n\n switch (key) {\n case 'ArrowLeft':\n event.preventDefault();\n focusInputField('prev', index);\n break;\n\n case 'ArrowRight':\n event.preventDefault();\n focusInputField('next', index);\n break;\n\n case 'Tab':\n if (shiftKey) {\n if (index > 0 && manageFocus) {\n event.preventDefault();\n focusInputField('prev', index);\n }\n }\n break;\n\n case ' ':\n event.preventDefault();\n focusInputField('next', index);\n break;\n\n case 'Delete':\n event.preventDefault();\n setFieldValue('', index);\n break;\n\n case 'Backspace':\n if (inputValue === '') {\n event.preventDefault();\n focusInputField('prev', index);\n } else {\n setFieldValue('', index);\n if (index < currentLength - 1) {\n event.preventDefault();\n focusInputField('prev', index);\n }\n }\n break;\n\n default:\n if (inputValue.length > 0 && key === currentValue[index]) {\n event.preventDefault();\n focusInputField('next', index);\n }\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>, index: number) => {\n event.target.select();\n setFocusedIndex(index);\n };\n\n const handleBlur = () => {\n setFocusedIndex(-1);\n };\n\n const handlePaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n event.preventDefault();\n const pasteData = event.clipboardData.getData('text/plain').replace(/[\\n\\r\\s]+/g, '');\n const isValid = validate(pasteData.trim());\n\n if (isValid) {\n const pasteArray = createPinArray(currentLength, pasteData);\n setValues(pasteArray);\n const filledCount = pasteArray.filter((val) => val !== '').length;\n if (filledCount >= currentLength) {\n inputsRef.current[currentLength - 1]?.focus();\n } else {\n inputsRef.current[filledCount]?.focus();\n }\n }\n };\n\n return (\n <>\n <Group\n {...others}\n {...getStyles('root')}\n ref={rootRef}\n role=\"group\"\n id={uuid}\n gap={gap}\n unstyled={unstyled}\n wrap=\"nowrap\"\n variant={variant}\n __size={size}\n dir=\"ltr\"\n >\n {currentValue.map((char: string, index: number) => (\n <Input\n component=\"input\"\n {...getStyles('pinInput', {\n style: {\n '--input-padding': '0',\n '--input-text-align': 'center',\n } as React.CSSProperties,\n })}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n size={size}\n __staticSelector=\"PinInput\"\n id={`${uuid}-${index + 1}`}\n key={`${uuid}-${index}`}\n inputMode={inputMode || (type === 'number' ? 'numeric' : 'text')}\n onChange={(event) => handleChange(event, index)}\n onKeyDown={(event) => handleKeyDown(event, index)}\n onFocus={(event) => handleFocus(event, index)}\n onBlur={handleBlur}\n onPaste={handlePaste}\n type={inputType || (mask ? 'password' : type === 'number' ? 'tel' : 'text')}\n radius={radius}\n error={error}\n variant={variant}\n disabled={disabled}\n ref={(node) => {\n if (node) {\n index === 0 && assignRef(ref, node);\n inputsRef.current[index] = node;\n }\n }}\n autoComplete={oneTimeCode ? 'one-time-code' : 'off'}\n placeholder={focusedIndex === index ? '' : placeholder}\n value={char}\n autoFocus={autoFocus && index === 0}\n unstyled={unstyled}\n aria-label={ariaLabel}\n readOnly={readOnly}\n {...getInputProps?.(index)}\n />\n ))}\n </Group>\n\n <input type=\"hidden\" name={name} form={form} value={_valueToString} {...hiddenInputProps} />\n </>\n );\n});\n\nPinInput.classes = { ...classes, ...InputBase.classes };\nPinInput.varsResolver = varsResolver;\nPinInput.displayName = '@mantine/core/PinInput';\n\nexport namespace PinInput {\n export type Props = PinInputProps;\n export type StylesNames = PinInputStylesNames;\n export type Factory = PinInputFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,MAAM,QAAQ;CACZ,QAAQ;CACR,cAAc;CACf;AA2GD,MAAM,eAAe;CACnB,KAAK;CACL,QAAQ;CACR,aAAa;CACb,aAAa;CACb,aAAa;CACb,MAAM;CACN,WAAW;CACX,MAAM;CACP;AAED,MAAM,eAAeA,6BAAAA,oBAAqC,GAAG,EAAE,YAAY,EACzE,MAAM,EACJ,oBAAoBC,iBAAAA,QAAQ,QAAQ,MAAM,iBAAiB,EAC5D,EACF,EAAE;AAEH,MAAa,WAAWC,gBAAAA,SAA0B,UAAU;CAC1D,MAAM,EACJ,MACA,MACA,WACA,OACA,cACA,SACA,KACA,OACA,MACA,YACA,QACA,UACA,QACA,UACA,YACA,aACA,WACA,OACA,QACA,UACA,aACA,aACA,MACA,MACA,UACA,WACA,WAC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,EAAA,CAAA;EAEL;AAEF,SAAS,UAAU;CAAE,GAAGC,wBAAAA;CAAS,GAAGC,kBAAAA,UAAU;CAAS;AACvD,SAAS,eAAe;AACxB,SAAS,cAAc"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
|
+
//#region packages/@mantine/core/src/components/RollingNumber/DigitColumn.tsx
|
|
5
|
+
const STRIP_CELLS = [
|
|
6
|
+
"0",
|
|
7
|
+
"1",
|
|
8
|
+
"2",
|
|
9
|
+
"3",
|
|
10
|
+
"4",
|
|
11
|
+
"5",
|
|
12
|
+
"6",
|
|
13
|
+
"7",
|
|
14
|
+
"8",
|
|
15
|
+
"9",
|
|
16
|
+
"0",
|
|
17
|
+
"1"
|
|
18
|
+
];
|
|
19
|
+
function DigitColumn({ digit, getStyles, previousDigit, empty, valueDirection }) {
|
|
20
|
+
const digitIndex = parseInt(digit, 10);
|
|
21
|
+
const previousDigitIndex = previousDigit !== null ? parseInt(previousDigit, 10) : digitIndex;
|
|
22
|
+
const animateToIndex = valueDirection === "up" && previousDigit !== null && digitIndex < previousDigitIndex && digitIndex <= 1 ? digitIndex + 10 : digitIndex;
|
|
23
|
+
const direction = digitIndex >= previousDigitIndex ? "up" : "down";
|
|
24
|
+
const digitStyles = getStyles("digit");
|
|
25
|
+
const columnStyles = getStyles("digitColumn");
|
|
26
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
27
|
+
...digitStyles,
|
|
28
|
+
"data-empty": empty || void 0,
|
|
29
|
+
"aria-hidden": "true",
|
|
30
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
31
|
+
...columnStyles,
|
|
32
|
+
style: {
|
|
33
|
+
...columnStyles.style,
|
|
34
|
+
transform: `translateY(${-digitIndex}em)`,
|
|
35
|
+
["--rn-roll-from"]: `translateY(${-previousDigitIndex}em)`,
|
|
36
|
+
["--rn-roll-to"]: `translateY(${-animateToIndex}em)`
|
|
37
|
+
},
|
|
38
|
+
"data-direction": direction,
|
|
39
|
+
children: STRIP_CELLS.map((d, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: d }, i))
|
|
40
|
+
}, digit)
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
exports.DigitColumn = DigitColumn;
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=DigitColumn.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DigitColumn.cjs","names":[],"sources":["../../../src/components/RollingNumber/DigitColumn.tsx"],"sourcesContent":["import { useStyles } from '../../core';\nimport type { RollingNumberFactory } from './RollingNumber';\n\nconst STRIP_CELLS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1'];\n\ninterface DigitColumnProps {\n digit: string;\n getStyles: ReturnType<typeof useStyles<RollingNumberFactory>>;\n previousDigit: string | null;\n empty?: boolean;\n valueDirection: 'up' | 'down';\n}\n\nexport function DigitColumn({\n digit,\n getStyles,\n previousDigit,\n empty,\n valueDirection,\n}: DigitColumnProps) {\n const digitIndex = parseInt(digit, 10);\n const previousDigitIndex = previousDigit !== null ? parseInt(previousDigit, 10) : digitIndex;\n\n const wrapsForward =\n valueDirection === 'up' &&\n previousDigit !== null &&\n digitIndex < previousDigitIndex &&\n digitIndex <= 1;\n\n const animateToIndex = wrapsForward ? digitIndex + 10 : digitIndex;\n const direction = digitIndex >= previousDigitIndex ? 'up' : 'down';\n\n const digitStyles = getStyles('digit');\n const columnStyles = getStyles('digitColumn');\n\n return (\n <span {...digitStyles} data-empty={empty || undefined} aria-hidden=\"true\">\n <span\n key={digit}\n {...columnStyles}\n style={{\n ...columnStyles.style,\n transform: `translateY(${-digitIndex}em)`,\n ['--rn-roll-from' as any]: `translateY(${-previousDigitIndex}em)`,\n ['--rn-roll-to' as any]: `translateY(${-animateToIndex}em)`,\n }}\n data-direction={direction}\n >\n {STRIP_CELLS.map((d, i) => (\n <span key={i}>{d}</span>\n ))}\n </span>\n </span>\n );\n}\n"],"mappings":";;;;AAGA,MAAM,cAAc;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAI;AAUhF,SAAgB,YAAY,EAC1B,OACA,WACA,eACA,OACA,kBACmB;CACnB,MAAM,aAAa,SAAS,OAAO,GAAG;CACtC,MAAM,qBAAqB,kBAAkB,OAAO,SAAS,eAAe,GAAG,GAAG;CAQlF,MAAM,iBALJ,mBAAmB,QACnB,kBAAkB,QAClB,aAAa,sBACb,cAAc,IAEsB,aAAa,KAAK;CACxD,MAAM,YAAY,cAAc,qBAAqB,OAAO;CAE5D,MAAM,cAAc,UAAU,QAAQ;CACtC,MAAM,eAAe,UAAU,cAAc;AAE7C,QACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;EAAM,GAAI;EAAa,cAAY,SAAS,KAAA;EAAW,eAAY;YACjE,iBAAA,GAAA,kBAAA,KAAC,QAAD;GAEE,GAAI;GACJ,OAAO;IACL,GAAG,aAAa;IAChB,WAAW,cAAc,CAAC,WAAW;KACpC,mBAA0B,cAAc,CAAC,mBAAmB;KAC5D,iBAAwB,cAAc,CAAC,eAAe;IACxD;GACD,kBAAgB;aAEf,YAAY,KAAK,GAAG,MACnB,iBAAA,GAAA,kBAAA,KAAC,QAAD,EAAA,UAAe,GAAS,EAAb,EAAa,CACxB;GACG,EAbA,MAaA;EACF,CAAA"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_create_vars_resolver = require("../../core/styles-api/create-vars-resolver/create-vars-resolver.cjs");
|
|
4
|
+
const require_use_props = require("../../core/MantineProvider/use-props/use-props.cjs");
|
|
5
|
+
const require_use_styles = require("../../core/styles-api/use-styles/use-styles.cjs");
|
|
6
|
+
const require_factory = require("../../core/factory/factory.cjs");
|
|
7
|
+
const require_Box = require("../../core/Box/Box.cjs");
|
|
8
|
+
const require_get_digit_parts = require("./get-digit-parts.cjs");
|
|
9
|
+
const require_build_value = require("./build-value.cjs");
|
|
10
|
+
const require_DigitColumn = require("./DigitColumn.cjs");
|
|
11
|
+
const require_get_render_slots = require("./get-render-slots.cjs");
|
|
12
|
+
const require_RollingNumber_module = require("./RollingNumber.module.cjs");
|
|
13
|
+
let react = require("react");
|
|
14
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
15
|
+
//#region packages/@mantine/core/src/components/RollingNumber/RollingNumber.tsx
|
|
16
|
+
const defaultProps = {
|
|
17
|
+
animationDuration: 600,
|
|
18
|
+
timingFunction: "ease",
|
|
19
|
+
decimalSeparator: ".",
|
|
20
|
+
tabularNumbers: true
|
|
21
|
+
};
|
|
22
|
+
const varsResolver = require_create_vars_resolver.createVarsResolver((_, { animationDuration, timingFunction }) => ({ root: {
|
|
23
|
+
"--rn-duration": `${animationDuration}ms`,
|
|
24
|
+
"--rn-timing-function": timingFunction
|
|
25
|
+
} }));
|
|
26
|
+
const RollingNumber = require_factory.factory((_props) => {
|
|
27
|
+
const props = require_use_props.useProps("RollingNumber", defaultProps, _props);
|
|
28
|
+
const { classNames, className, style, styles, unstyled, vars, value, prefix, suffix, decimalSeparator, thousandSeparator, decimalScale, fixedDecimalScale, animationDuration, timingFunction, tabularNumbers, withLiveRegion, mod, attributes, ...others } = props;
|
|
29
|
+
const getStyles = require_use_styles.useStyles({
|
|
30
|
+
name: "RollingNumber",
|
|
31
|
+
classes: require_RollingNumber_module.default,
|
|
32
|
+
props,
|
|
33
|
+
className,
|
|
34
|
+
style,
|
|
35
|
+
classNames,
|
|
36
|
+
styles,
|
|
37
|
+
unstyled,
|
|
38
|
+
attributes,
|
|
39
|
+
vars,
|
|
40
|
+
varsResolver
|
|
41
|
+
});
|
|
42
|
+
const previousValueRef = (0, react.useRef)(value);
|
|
43
|
+
const previousValue = previousValueRef.current;
|
|
44
|
+
(0, react.useEffect)(() => {
|
|
45
|
+
previousValueRef.current = value;
|
|
46
|
+
});
|
|
47
|
+
const valueDirection = value >= previousValue ? "up" : "down";
|
|
48
|
+
const slots = require_get_render_slots.getRenderSlots({
|
|
49
|
+
current: require_get_digit_parts.getDigitParts({
|
|
50
|
+
value,
|
|
51
|
+
decimalScale,
|
|
52
|
+
fixedDecimalScale
|
|
53
|
+
}),
|
|
54
|
+
previous: require_get_digit_parts.getDigitParts({
|
|
55
|
+
value: previousValue,
|
|
56
|
+
decimalScale,
|
|
57
|
+
fixedDecimalScale
|
|
58
|
+
}),
|
|
59
|
+
prefix,
|
|
60
|
+
suffix,
|
|
61
|
+
decimalSeparator,
|
|
62
|
+
thousandSeparator
|
|
63
|
+
});
|
|
64
|
+
const accessibleValue = require_build_value.buildValue({
|
|
65
|
+
value,
|
|
66
|
+
prefix,
|
|
67
|
+
suffix,
|
|
68
|
+
decimalSeparator,
|
|
69
|
+
thousandSeparator,
|
|
70
|
+
decimalScale,
|
|
71
|
+
fixedDecimalScale
|
|
72
|
+
});
|
|
73
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
|
|
74
|
+
...getStyles("root"),
|
|
75
|
+
mod: [{ "tabular-numbers": tabularNumbers }, mod],
|
|
76
|
+
role: withLiveRegion ? "status" : "img",
|
|
77
|
+
"aria-label": accessibleValue,
|
|
78
|
+
...others,
|
|
79
|
+
children: slots.map((slot) => {
|
|
80
|
+
if (slot.type === "digit") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_DigitColumn.DigitColumn, {
|
|
81
|
+
digit: slot.digit,
|
|
82
|
+
previousDigit: slot.previousDigit,
|
|
83
|
+
getStyles,
|
|
84
|
+
empty: slot.empty,
|
|
85
|
+
valueDirection
|
|
86
|
+
}, slot.key);
|
|
87
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
88
|
+
...getStyles("char"),
|
|
89
|
+
"data-empty": slot.empty || void 0,
|
|
90
|
+
"aria-hidden": "true",
|
|
91
|
+
children: slot.char
|
|
92
|
+
}, slot.key);
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
RollingNumber.classes = require_RollingNumber_module.default;
|
|
97
|
+
RollingNumber.varsResolver = varsResolver;
|
|
98
|
+
RollingNumber.displayName = "@mantine/core/RollingNumber";
|
|
99
|
+
//#endregion
|
|
100
|
+
exports.RollingNumber = RollingNumber;
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=RollingNumber.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RollingNumber.cjs","names":["createVarsResolver","factory","useProps","useStyles","getRenderSlots","getDigitParts","buildValue","Box","DigitColumn","classes"],"sources":["../../../src/components/RollingNumber/RollingNumber.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport { buildValue } from './build-value';\nimport { DigitColumn } from './DigitColumn';\nimport { getDigitParts } from './get-digit-parts';\nimport { getRenderSlots } from './get-render-slots';\nimport classes from './RollingNumber.module.css';\n\nexport type RollingNumberStylesNames = 'root' | 'digit' | 'digitColumn' | 'char';\nexport type RollingNumberCssVariables = {\n root: '--rn-duration' | '--rn-timing-function';\n};\n\nexport interface RollingNumberProps\n extends BoxProps, StylesApiProps<RollingNumberFactory>, ElementProps<'div'> {\n /** Number value to display */\n value: number;\n\n /** Prefix added before the value */\n prefix?: string;\n\n /** Suffix added after the value */\n suffix?: string;\n\n /** Character used as a decimal separator @default '.' */\n decimalSeparator?: string;\n\n /** Character used to separate thousands, set to `true` for `,` @default false */\n thousandSeparator?: string | boolean;\n\n /** Number of decimal places to display */\n decimalScale?: number;\n\n /** If set, trailing zeros are added to match `decimalScale` @default false */\n fixedDecimalScale?: boolean;\n\n /** Animation duration in milliseconds @default 600 */\n animationDuration?: number;\n\n /** CSS timing function for animation @default 'ease' */\n timingFunction?: string;\n\n /** If set, use tabular (monospace) numbers @default true */\n tabularNumbers?: boolean;\n\n /** If set, the root element acts as an `aria-live=\"polite\"` region (`role=\"status\"`) and screen readers announce every value change. When `false`, the root uses `role=\"img\"` so the current value is still accessible but updates are not announced. @default false */\n withLiveRegion?: boolean;\n}\n\nexport type RollingNumberFactory = Factory<{\n props: RollingNumberProps;\n ref: HTMLDivElement;\n stylesNames: RollingNumberStylesNames;\n vars: RollingNumberCssVariables;\n}>;\n\nconst defaultProps = {\n animationDuration: 600,\n timingFunction: 'ease',\n decimalSeparator: '.',\n tabularNumbers: true,\n} satisfies Partial<RollingNumberProps>;\n\nconst varsResolver = createVarsResolver<RollingNumberFactory>(\n (_, { animationDuration, timingFunction }) => ({\n root: {\n '--rn-duration': `${animationDuration}ms`,\n '--rn-timing-function': timingFunction,\n },\n })\n);\n\nexport const RollingNumber = factory<RollingNumberFactory>((_props) => {\n const props = useProps('RollingNumber', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n value,\n prefix,\n suffix,\n decimalSeparator,\n thousandSeparator,\n decimalScale,\n fixedDecimalScale,\n animationDuration,\n timingFunction,\n tabularNumbers,\n withLiveRegion,\n mod,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<RollingNumberFactory>({\n name: 'RollingNumber',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const previousValueRef = useRef(value);\n const previousValue = previousValueRef.current;\n\n useEffect(() => {\n previousValueRef.current = value;\n });\n\n const valueDirection: 'up' | 'down' = value >= previousValue ? 'up' : 'down';\n\n const current = getDigitParts({ value, decimalScale, fixedDecimalScale });\n const prev = getDigitParts({ value: previousValue, decimalScale, fixedDecimalScale });\n\n const slots = getRenderSlots({\n current,\n previous: prev,\n prefix,\n suffix,\n decimalSeparator,\n thousandSeparator,\n });\n\n const accessibleValue = buildValue({\n value,\n prefix,\n suffix,\n decimalSeparator,\n thousandSeparator,\n decimalScale,\n fixedDecimalScale,\n });\n\n return (\n <Box\n {...getStyles('root')}\n mod={[{ 'tabular-numbers': tabularNumbers }, mod]}\n role={withLiveRegion ? 'status' : 'img'}\n aria-label={accessibleValue}\n {...others}\n >\n {slots.map((slot) => {\n if (slot.type === 'digit') {\n return (\n <DigitColumn\n key={slot.key}\n digit={slot.digit}\n previousDigit={slot.previousDigit}\n getStyles={getStyles}\n empty={slot.empty}\n valueDirection={valueDirection}\n />\n );\n }\n\n return (\n <span\n key={slot.key}\n {...getStyles('char')}\n data-empty={slot.empty || undefined}\n aria-hidden=\"true\"\n >\n {slot.char}\n </span>\n );\n })}\n </Box>\n );\n});\n\nRollingNumber.classes = classes;\nRollingNumber.varsResolver = varsResolver;\nRollingNumber.displayName = '@mantine/core/RollingNumber';\n"],"mappings":";;;;;;;;;;;;;;;AAkEA,MAAM,eAAe;CACnB,mBAAmB;CACnB,gBAAgB;CAChB,kBAAkB;CAClB,gBAAgB;CACjB;AAED,MAAM,eAAeA,6BAAAA,oBAClB,GAAG,EAAE,mBAAmB,sBAAsB,EAC7C,MAAM;CACJ,iBAAiB,GAAG,kBAAkB;CACtC,wBAAwB;CACzB,EACF,EACF;AAED,MAAa,gBAAgBC,gBAAAA,SAA+B,WAAW;CACrE,MAAM,QAAQC,kBAAAA,SAAS,iBAAiB,cAAc,OAAO;CAC7D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,OACA,QACA,QACA,kBACA,mBACA,cACA,mBACA,mBACA,gBACA,gBACA,gBACA,KACA,YACA,GAAG,WACD;CAEJ,MAAM,YAAYC,mBAAAA,UAAgC;EAChD,MAAM;EACN,SAAA,6BAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,oBAAA,GAAA,MAAA,QAA0B,MAAM;CACtC,MAAM,gBAAgB,iBAAiB;AAEvC,EAAA,GAAA,MAAA,iBAAgB;AACd,mBAAiB,UAAU;GAC3B;CAEF,MAAM,iBAAgC,SAAS,gBAAgB,OAAO;CAKtE,MAAM,QAAQC,yBAAAA,eAAe;EAC3B,SAJcC,wBAAAA,cAAc;GAAE;GAAO;GAAc;GAAmB,CAAC;EAKvE,UAJWA,wBAAAA,cAAc;GAAE,OAAO;GAAe;GAAc;GAAmB,CAAC;EAKnF;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,kBAAkBC,oBAAAA,WAAW;EACjC;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,QACE,iBAAA,GAAA,kBAAA,KAACC,YAAAA,KAAD;EACE,GAAI,UAAU,OAAO;EACrB,KAAK,CAAC,EAAE,mBAAmB,gBAAgB,EAAE,IAAI;EACjD,MAAM,iBAAiB,WAAW;EAClC,cAAY;EACZ,GAAI;YAEH,MAAM,KAAK,SAAS;AACnB,OAAI,KAAK,SAAS,QAChB,QACE,iBAAA,GAAA,kBAAA,KAACC,oBAAAA,aAAD;IAEE,OAAO,KAAK;IACZ,eAAe,KAAK;IACT;IACX,OAAO,KAAK;IACI;IAChB,EANK,KAAK,IAMV;AAIN,UACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;IAEE,GAAI,UAAU,OAAO;IACrB,cAAY,KAAK,SAAS,KAAA;IAC1B,eAAY;cAEX,KAAK;IACD,EANA,KAAK,IAML;IAET;EACE,CAAA;EAER;AAEF,cAAc,UAAUC,6BAAAA;AACxB,cAAc,eAAe;AAC7B,cAAc,cAAc"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region packages/@mantine/core/src/components/RollingNumber/RollingNumber.module.css
|
|
3
|
+
var RollingNumber_module_default = {
|
|
4
|
+
"root": "m_47dd3981",
|
|
5
|
+
"digit": "m_b301d46e",
|
|
6
|
+
"digitColumn": "m_8ae40964",
|
|
7
|
+
"mantine-rolling-number-roll": "m_18d73873",
|
|
8
|
+
"char": "m_47d64bf5"
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.default = RollingNumber_module_default;
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=RollingNumber.module.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RollingNumber.module.cjs","names":[],"sources":["../../../src/components/RollingNumber/RollingNumber.module.css"],"sourcesContent":[".root {\n display: inline-flex;\n align-items: baseline;\n overflow: hidden;\n\n &[data-tabular-numbers] {\n font-variant-numeric: tabular-nums;\n }\n}\n\n.digit {\n display: inline-block;\n width: 1ch;\n height: 1em;\n overflow: hidden;\n line-height: 1;\n transition:\n width var(--rn-duration) var(--rn-timing-function),\n opacity var(--rn-duration) var(--rn-timing-function);\n\n &[data-empty] {\n width: 0;\n opacity: 0;\n }\n}\n\n.digitColumn {\n display: flex;\n flex-direction: column;\n animation: mantine-rolling-number-roll var(--rn-duration) var(--rn-timing-function);\n\n & > span {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 1em;\n }\n}\n\n.char {\n display: inline-block;\n overflow: hidden;\n white-space: pre;\n transition: opacity var(--rn-duration) var(--rn-timing-function);\n\n &[data-empty] {\n width: 0;\n opacity: 0;\n }\n}\n\n@keyframes mantine-rolling-number-roll {\n from {\n transform: var(--rn-roll-from);\n }\n\n to {\n transform: var(--rn-roll-to);\n }\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_get_digit_parts = require("./get-digit-parts.cjs");
|
|
3
|
+
//#region packages/@mantine/core/src/components/RollingNumber/build-value.ts
|
|
4
|
+
function buildValue({ value, prefix, suffix, decimalSeparator = ".", thousandSeparator, decimalScale, fixedDecimalScale }) {
|
|
5
|
+
const parts = require_get_digit_parts.getDigitParts({
|
|
6
|
+
value,
|
|
7
|
+
decimalScale,
|
|
8
|
+
fixedDecimalScale
|
|
9
|
+
});
|
|
10
|
+
let intStr = parts.intDigits.join("");
|
|
11
|
+
if (thousandSeparator) {
|
|
12
|
+
const sep = typeof thousandSeparator === "string" ? thousandSeparator : ",";
|
|
13
|
+
intStr = intStr.replace(/\B(?=(\d{3})+(?!\d))/g, sep);
|
|
14
|
+
}
|
|
15
|
+
let result = parts.negative ? `-${intStr}` : intStr;
|
|
16
|
+
if (parts.fracDigits.length > 0) result += `${decimalSeparator}${parts.fracDigits.join("")}`;
|
|
17
|
+
return `${prefix || ""}${result}${suffix || ""}`;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.buildValue = buildValue;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=build-value.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-value.cjs","names":["getDigitParts"],"sources":["../../../src/components/RollingNumber/build-value.ts"],"sourcesContent":["import { getDigitParts } from './get-digit-parts';\n\nexport interface BuildValueInput {\n value: number;\n prefix?: string;\n suffix?: string;\n decimalSeparator?: string;\n thousandSeparator?: string | boolean;\n decimalScale?: number;\n fixedDecimalScale?: boolean;\n}\n\nexport function buildValue({\n value,\n prefix,\n suffix,\n decimalSeparator = '.',\n thousandSeparator,\n decimalScale,\n fixedDecimalScale,\n}: BuildValueInput): string {\n const parts = getDigitParts({ value, decimalScale, fixedDecimalScale });\n let intStr = parts.intDigits.join('');\n\n if (thousandSeparator) {\n const sep = typeof thousandSeparator === 'string' ? thousandSeparator : ',';\n intStr = intStr.replace(/\\B(?=(\\d{3})+(?!\\d))/g, sep);\n }\n\n let result = parts.negative ? `-${intStr}` : intStr;\n if (parts.fracDigits.length > 0) {\n result += `${decimalSeparator}${parts.fracDigits.join('')}`;\n }\n\n return `${prefix || ''}${result}${suffix || ''}`;\n}\n"],"mappings":";;;AAYA,SAAgB,WAAW,EACzB,OACA,QACA,QACA,mBAAmB,KACnB,mBACA,cACA,qBAC0B;CAC1B,MAAM,QAAQA,wBAAAA,cAAc;EAAE;EAAO;EAAc;EAAmB,CAAC;CACvE,IAAI,SAAS,MAAM,UAAU,KAAK,GAAG;AAErC,KAAI,mBAAmB;EACrB,MAAM,MAAM,OAAO,sBAAsB,WAAW,oBAAoB;AACxE,WAAS,OAAO,QAAQ,yBAAyB,IAAI;;CAGvD,IAAI,SAAS,MAAM,WAAW,IAAI,WAAW;AAC7C,KAAI,MAAM,WAAW,SAAS,EAC5B,WAAU,GAAG,mBAAmB,MAAM,WAAW,KAAK,GAAG;AAG3D,QAAO,GAAG,UAAU,KAAK,SAAS,UAAU"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region packages/@mantine/core/src/components/RollingNumber/get-digit-parts.ts
|
|
3
|
+
const PLAIN_FORMAT = new Intl.NumberFormat("en-US", {
|
|
4
|
+
useGrouping: false,
|
|
5
|
+
maximumFractionDigits: 20
|
|
6
|
+
});
|
|
7
|
+
function toPlainString(num, decimalScale) {
|
|
8
|
+
if (!Number.isFinite(num)) return "0";
|
|
9
|
+
if (decimalScale !== void 0) return new Intl.NumberFormat("en-US", {
|
|
10
|
+
useGrouping: false,
|
|
11
|
+
minimumFractionDigits: decimalScale,
|
|
12
|
+
maximumFractionDigits: decimalScale
|
|
13
|
+
}).format(num);
|
|
14
|
+
const str = String(num);
|
|
15
|
+
if (!str.includes("e") && !str.includes("E")) return str;
|
|
16
|
+
return PLAIN_FORMAT.format(num);
|
|
17
|
+
}
|
|
18
|
+
function getDigitParts({ value, decimalScale, fixedDecimalScale }) {
|
|
19
|
+
let str = toPlainString(Math.abs(value), decimalScale);
|
|
20
|
+
if (!fixedDecimalScale && decimalScale !== void 0) {
|
|
21
|
+
const parts = str.split(".");
|
|
22
|
+
if (parts[1]) {
|
|
23
|
+
const trimmed = parts[1].replace(/0+$/, "");
|
|
24
|
+
str = trimmed ? `${parts[0]}.${trimmed}` : parts[0];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const dotIdx = str.indexOf(".");
|
|
28
|
+
const intStr = dotIdx >= 0 ? str.slice(0, dotIdx) : str;
|
|
29
|
+
const fracStr = dotIdx >= 0 ? str.slice(dotIdx + 1) : "";
|
|
30
|
+
return {
|
|
31
|
+
negative: value < 0,
|
|
32
|
+
intDigits: intStr.split(""),
|
|
33
|
+
fracDigits: fracStr ? fracStr.split("") : [],
|
|
34
|
+
hasDecimal: dotIdx >= 0
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.getDigitParts = getDigitParts;
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=get-digit-parts.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-digit-parts.cjs","names":[],"sources":["../../../src/components/RollingNumber/get-digit-parts.ts"],"sourcesContent":["export interface DigitParts {\n negative: boolean;\n intDigits: string[];\n fracDigits: string[];\n hasDecimal: boolean;\n}\n\nexport interface GetDigitPartsInput {\n value: number;\n decimalScale?: number;\n fixedDecimalScale?: boolean;\n}\n\nconst PLAIN_FORMAT = new Intl.NumberFormat('en-US', {\n useGrouping: false,\n maximumFractionDigits: 20,\n});\n\nfunction toPlainString(num: number, decimalScale?: number): string {\n if (!Number.isFinite(num)) {\n return '0';\n }\n\n if (decimalScale !== undefined) {\n return new Intl.NumberFormat('en-US', {\n useGrouping: false,\n minimumFractionDigits: decimalScale,\n maximumFractionDigits: decimalScale,\n }).format(num);\n }\n\n const str = String(num);\n if (!str.includes('e') && !str.includes('E')) {\n return str;\n }\n\n return PLAIN_FORMAT.format(num);\n}\n\nexport function getDigitParts({\n value,\n decimalScale,\n fixedDecimalScale,\n}: GetDigitPartsInput): DigitParts {\n const abs = Math.abs(value);\n let str = toPlainString(abs, decimalScale);\n\n if (!fixedDecimalScale && decimalScale !== undefined) {\n const parts = str.split('.');\n if (parts[1]) {\n const trimmed = parts[1].replace(/0+$/, '');\n str = trimmed ? `${parts[0]}.${trimmed}` : parts[0];\n }\n }\n\n const dotIdx = str.indexOf('.');\n const intStr = dotIdx >= 0 ? str.slice(0, dotIdx) : str;\n const fracStr = dotIdx >= 0 ? str.slice(dotIdx + 1) : '';\n\n return {\n negative: value < 0,\n intDigits: intStr.split(''),\n fracDigits: fracStr ? fracStr.split('') : [],\n hasDecimal: dotIdx >= 0,\n };\n}\n"],"mappings":";;AAaA,MAAM,eAAe,IAAI,KAAK,aAAa,SAAS;CAClD,aAAa;CACb,uBAAuB;CACxB,CAAC;AAEF,SAAS,cAAc,KAAa,cAA+B;AACjE,KAAI,CAAC,OAAO,SAAS,IAAI,CACvB,QAAO;AAGT,KAAI,iBAAiB,KAAA,EACnB,QAAO,IAAI,KAAK,aAAa,SAAS;EACpC,aAAa;EACb,uBAAuB;EACvB,uBAAuB;EACxB,CAAC,CAAC,OAAO,IAAI;CAGhB,MAAM,MAAM,OAAO,IAAI;AACvB,KAAI,CAAC,IAAI,SAAS,IAAI,IAAI,CAAC,IAAI,SAAS,IAAI,CAC1C,QAAO;AAGT,QAAO,aAAa,OAAO,IAAI;;AAGjC,SAAgB,cAAc,EAC5B,OACA,cACA,qBACiC;CAEjC,IAAI,MAAM,cADE,KAAK,IAAI,MAAM,EACE,aAAa;AAE1C,KAAI,CAAC,qBAAqB,iBAAiB,KAAA,GAAW;EACpD,MAAM,QAAQ,IAAI,MAAM,IAAI;AAC5B,MAAI,MAAM,IAAI;GACZ,MAAM,UAAU,MAAM,GAAG,QAAQ,OAAO,GAAG;AAC3C,SAAM,UAAU,GAAG,MAAM,GAAG,GAAG,YAAY,MAAM;;;CAIrD,MAAM,SAAS,IAAI,QAAQ,IAAI;CAC/B,MAAM,SAAS,UAAU,IAAI,IAAI,MAAM,GAAG,OAAO,GAAG;CACpD,MAAM,UAAU,UAAU,IAAI,IAAI,MAAM,SAAS,EAAE,GAAG;AAEtD,QAAO;EACL,UAAU,QAAQ;EAClB,WAAW,OAAO,MAAM,GAAG;EAC3B,YAAY,UAAU,QAAQ,MAAM,GAAG,GAAG,EAAE;EAC5C,YAAY,UAAU;EACvB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region packages/@mantine/core/src/components/RollingNumber/get-render-slots.ts
|
|
3
|
+
function padLeft(arr, length) {
|
|
4
|
+
return [...Array(length - arr.length).fill(null), ...arr];
|
|
5
|
+
}
|
|
6
|
+
function padRight(arr, length) {
|
|
7
|
+
return [...arr, ...Array(length - arr.length).fill(null)];
|
|
8
|
+
}
|
|
9
|
+
function getRenderSlots({ current, previous, prefix, suffix, decimalSeparator = ".", thousandSeparator }) {
|
|
10
|
+
const maxIntLen = Math.max(current.intDigits.length, previous.intDigits.length);
|
|
11
|
+
const maxFracLen = Math.max(current.fracDigits.length, previous.fracDigits.length);
|
|
12
|
+
const currIntPadded = padLeft(current.intDigits, maxIntLen);
|
|
13
|
+
const prevIntPadded = padLeft(previous.intDigits, maxIntLen);
|
|
14
|
+
const currFracPadded = padRight(current.fracDigits, maxFracLen);
|
|
15
|
+
const prevFracPadded = padRight(previous.fracDigits, maxFracLen);
|
|
16
|
+
const sep = thousandSeparator ? typeof thousandSeparator === "string" ? thousandSeparator : "," : null;
|
|
17
|
+
const slots = [];
|
|
18
|
+
if (prefix) for (let i = 0; i < prefix.length; i++) slots.push({
|
|
19
|
+
type: "char",
|
|
20
|
+
key: `prefix-${i}`,
|
|
21
|
+
char: prefix[i],
|
|
22
|
+
empty: false
|
|
23
|
+
});
|
|
24
|
+
if (current.negative || previous.negative) slots.push({
|
|
25
|
+
type: "char",
|
|
26
|
+
key: "sign",
|
|
27
|
+
char: "-",
|
|
28
|
+
empty: !current.negative
|
|
29
|
+
});
|
|
30
|
+
for (let i = 0; i < maxIntLen; i++) {
|
|
31
|
+
const posFromRight = maxIntLen - 1 - i;
|
|
32
|
+
const currDigit = currIntPadded[i];
|
|
33
|
+
const prevDigit = prevIntPadded[i];
|
|
34
|
+
const isEmpty = currDigit === null;
|
|
35
|
+
slots.push({
|
|
36
|
+
type: "digit",
|
|
37
|
+
key: `int-${posFromRight}`,
|
|
38
|
+
digit: currDigit ?? "0",
|
|
39
|
+
previousDigit: prevDigit,
|
|
40
|
+
empty: isEmpty
|
|
41
|
+
});
|
|
42
|
+
if (sep && posFromRight > 0 && posFromRight % 3 === 0) slots.push({
|
|
43
|
+
type: "char",
|
|
44
|
+
key: `sep-${posFromRight}`,
|
|
45
|
+
char: sep,
|
|
46
|
+
empty: isEmpty
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (current.hasDecimal || previous.hasDecimal) slots.push({
|
|
50
|
+
type: "char",
|
|
51
|
+
key: "dec",
|
|
52
|
+
char: decimalSeparator,
|
|
53
|
+
empty: !current.hasDecimal
|
|
54
|
+
});
|
|
55
|
+
for (let i = 0; i < maxFracLen; i++) {
|
|
56
|
+
const currDigit = currFracPadded[i];
|
|
57
|
+
const prevDigit = prevFracPadded[i];
|
|
58
|
+
const isEmpty = currDigit === null;
|
|
59
|
+
slots.push({
|
|
60
|
+
type: "digit",
|
|
61
|
+
key: `frac-${i}`,
|
|
62
|
+
digit: currDigit ?? "0",
|
|
63
|
+
previousDigit: prevDigit,
|
|
64
|
+
empty: isEmpty
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (suffix) for (let i = 0; i < suffix.length; i++) slots.push({
|
|
68
|
+
type: "char",
|
|
69
|
+
key: `suffix-${i}`,
|
|
70
|
+
char: suffix[i],
|
|
71
|
+
empty: false
|
|
72
|
+
});
|
|
73
|
+
return slots;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
exports.getRenderSlots = getRenderSlots;
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=get-render-slots.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-render-slots.cjs","names":[],"sources":["../../../src/components/RollingNumber/get-render-slots.ts"],"sourcesContent":["import { getDigitParts, type DigitParts } from './get-digit-parts';\n\nexport interface DigitSlot {\n type: 'digit';\n key: string;\n digit: string;\n previousDigit: string | null;\n empty: boolean;\n}\n\nexport interface CharSlot {\n type: 'char';\n key: string;\n char: string;\n empty: boolean;\n}\n\nexport type RenderSlot = DigitSlot | CharSlot;\n\nexport interface GetRenderSlotsInput {\n current: DigitParts;\n previous: DigitParts;\n prefix?: string;\n suffix?: string;\n decimalSeparator?: string;\n thousandSeparator?: string | boolean;\n}\n\nfunction padLeft(arr: string[], length: number): (string | null)[] {\n return [...Array(length - arr.length).fill(null), ...arr];\n}\n\nfunction padRight(arr: string[], length: number): (string | null)[] {\n return [...arr, ...Array(length - arr.length).fill(null)];\n}\n\nexport function getRenderSlots({\n current,\n previous,\n prefix,\n suffix,\n decimalSeparator = '.',\n thousandSeparator,\n}: GetRenderSlotsInput): RenderSlot[] {\n const maxIntLen = Math.max(current.intDigits.length, previous.intDigits.length);\n const maxFracLen = Math.max(current.fracDigits.length, previous.fracDigits.length);\n\n const currIntPadded = padLeft(current.intDigits, maxIntLen);\n const prevIntPadded = padLeft(previous.intDigits, maxIntLen);\n const currFracPadded = padRight(current.fracDigits, maxFracLen);\n const prevFracPadded = padRight(previous.fracDigits, maxFracLen);\n\n const sep = thousandSeparator\n ? typeof thousandSeparator === 'string'\n ? thousandSeparator\n : ','\n : null;\n\n const slots: RenderSlot[] = [];\n\n if (prefix) {\n for (let i = 0; i < prefix.length; i++) {\n slots.push({ type: 'char', key: `prefix-${i}`, char: prefix[i], empty: false });\n }\n }\n\n if (current.negative || previous.negative) {\n slots.push({ type: 'char', key: 'sign', char: '-', empty: !current.negative });\n }\n\n for (let i = 0; i < maxIntLen; i++) {\n const posFromRight = maxIntLen - 1 - i;\n const currDigit = currIntPadded[i];\n const prevDigit = prevIntPadded[i];\n const isEmpty = currDigit === null;\n\n slots.push({\n type: 'digit',\n key: `int-${posFromRight}`,\n digit: currDigit ?? '0',\n previousDigit: prevDigit,\n empty: isEmpty,\n });\n\n if (sep && posFromRight > 0 && posFromRight % 3 === 0) {\n slots.push({ type: 'char', key: `sep-${posFromRight}`, char: sep, empty: isEmpty });\n }\n }\n\n if (current.hasDecimal || previous.hasDecimal) {\n slots.push({\n type: 'char',\n key: 'dec',\n char: decimalSeparator,\n empty: !current.hasDecimal,\n });\n }\n\n for (let i = 0; i < maxFracLen; i++) {\n const currDigit = currFracPadded[i];\n const prevDigit = prevFracPadded[i];\n const isEmpty = currDigit === null;\n\n slots.push({\n type: 'digit',\n key: `frac-${i}`,\n digit: currDigit ?? '0',\n previousDigit: prevDigit,\n empty: isEmpty,\n });\n }\n\n if (suffix) {\n for (let i = 0; i < suffix.length; i++) {\n slots.push({ type: 'char', key: `suffix-${i}`, char: suffix[i], empty: false });\n }\n }\n\n return slots;\n}\n\nexport interface GetRenderSlotsFromValuesInput {\n value: number;\n previousValue: number;\n prefix?: string;\n suffix?: string;\n decimalSeparator?: string;\n thousandSeparator?: string | boolean;\n decimalScale?: number;\n fixedDecimalScale?: boolean;\n}\n\nexport function getRenderSlotsFromValues({\n value,\n previousValue,\n prefix,\n suffix,\n decimalSeparator,\n thousandSeparator,\n decimalScale,\n fixedDecimalScale,\n}: GetRenderSlotsFromValuesInput): RenderSlot[] {\n const current = getDigitParts({ value, decimalScale, fixedDecimalScale });\n const prev = getDigitParts({ value: previousValue, decimalScale, fixedDecimalScale });\n\n return getRenderSlots({\n current,\n previous: prev,\n prefix,\n suffix,\n decimalSeparator,\n thousandSeparator,\n });\n}\n"],"mappings":";;AA4BA,SAAS,QAAQ,KAAe,QAAmC;AACjE,QAAO,CAAC,GAAG,MAAM,SAAS,IAAI,OAAO,CAAC,KAAK,KAAK,EAAE,GAAG,IAAI;;AAG3D,SAAS,SAAS,KAAe,QAAmC;AAClE,QAAO,CAAC,GAAG,KAAK,GAAG,MAAM,SAAS,IAAI,OAAO,CAAC,KAAK,KAAK,CAAC;;AAG3D,SAAgB,eAAe,EAC7B,SACA,UACA,QACA,QACA,mBAAmB,KACnB,qBACoC;CACpC,MAAM,YAAY,KAAK,IAAI,QAAQ,UAAU,QAAQ,SAAS,UAAU,OAAO;CAC/E,MAAM,aAAa,K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,KAAK;GACT,MAAM;GACN,KAAK,QAAQ;GACb,OAAO,aAAa;GACpB,eAAe;GACf,OAAO;GACR,CAAC;;AAGJ,KAAI,OACF,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,IACjC,OAAM,KAAK;EAAE,MAAM;EAAQ,KAAK,UAAU;EAAK,MAAM,OAAO;EAAI,OAAO;EAAO,CAAC;AAInF,QAAO"}
|
|
@@ -21,7 +21,11 @@ const defaultProps = {
|
|
|
21
21
|
openOnFocus: true
|
|
22
22
|
};
|
|
23
23
|
const Select = require_factory.genericFactory((_props) => {
|
|
24
|
-
const props = require_use_props.useProps(
|
|
24
|
+
const props = require_use_props.useProps([
|
|
25
|
+
"Input",
|
|
26
|
+
"InputWrapper",
|
|
27
|
+
"Select"
|
|
28
|
+
], defaultProps, _props);
|
|
25
29
|
const { classNames, styles, unstyled, vars, dropdownOpened, defaultDropdownOpened, onDropdownClose, onDropdownOpen, onFocus, onBlur, onClick, onChange, data, value, defaultValue, selectFirstOptionOnChange, selectFirstOptionOnDropdownOpen, onOptionSubmit, comboboxProps, readOnly, disabled, filter, limit, withScrollArea, maxDropdownHeight, size, searchable, rightSection, checkIconPosition, withCheckIcon, withAlignedLabels, nothingFoundMessage, name, form, searchValue, defaultSearchValue, onSearchChange, allowDeselect, error, rightSectionPointerEvents, id, clearable, clearSectionMode, clearButtonProps, hiddenInputProps, renderOption, onClear, autoComplete, scrollAreaProps, __defaultRightSection, __clearSection, __clearable, chevronColor, autoSelectOnBlur, openOnFocus, attributes, ...others } = props;
|
|
26
30
|
const parsedData = (0, react.useMemo)(() => require_get_parsed_combobox_data.getParsedComboboxData(data), [data]);
|
|
27
31
|
const retainedSelectedOptions = (0, react.useRef)({});
|