@dnb/eufemia 10.70.1 → 10.71.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/CHANGELOG.md +18 -0
- package/cjs/components/date-picker/DatePickerContext.d.ts +0 -1
- package/cjs/components/date-picker/DatePickerContext.js.map +1 -1
- package/cjs/components/date-picker/DatePickerInput.js +7 -59
- package/cjs/components/date-picker/DatePickerInput.js.map +1 -1
- package/cjs/components/date-picker/DatePickerProvider.js +0 -2
- package/cjs/components/date-picker/DatePickerProvider.js.map +1 -1
- package/cjs/components/date-picker/hooks/useDates.d.ts +0 -2
- package/cjs/components/date-picker/hooks/useDates.js +5 -5
- package/cjs/components/date-picker/hooks/useDates.js.map +1 -1
- package/cjs/components/input-masked/InputMaskedHooks.js +11 -7
- package/cjs/components/input-masked/InputMaskedHooks.js.map +1 -1
- package/cjs/components/input-masked/InputMaskedUtils.d.ts +1 -1
- package/cjs/components/input-masked/InputMaskedUtils.js +2 -1
- package/cjs/components/input-masked/InputMaskedUtils.js.map +1 -1
- package/cjs/components/modal/ModalDocs.d.ts +2 -0
- package/cjs/components/modal/ModalDocs.js +11 -1
- package/cjs/components/modal/ModalDocs.js.map +1 -1
- package/cjs/components/upload/Upload.js +6 -3
- package/cjs/components/upload/Upload.js.map +1 -1
- package/cjs/components/upload/UploadDocs.d.ts +1 -0
- package/cjs/components/upload/UploadDocs.js +43 -1
- package/cjs/components/upload/UploadDocs.js.map +1 -1
- package/cjs/components/upload/UploadFileListCell.js +32 -12
- package/cjs/components/upload/UploadFileListCell.js.map +1 -1
- package/cjs/components/upload/types.d.ts +7 -0
- package/cjs/components/upload/types.js.map +1 -1
- package/cjs/extensions/forms/DataContext/Provider/ProviderDocs.js +1 -1
- package/cjs/extensions/forms/DataContext/Provider/ProviderDocs.js.map +1 -1
- package/cjs/extensions/forms/Field/Number/Number.js +3 -6
- package/cjs/extensions/forms/Field/Number/Number.js.map +1 -1
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumber.d.ts +6 -4
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumber.js +33 -25
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumber.js.map +1 -1
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.d.ts +2 -2
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js +8 -3
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js.map +1 -1
- package/cjs/extensions/forms/Field/Provider/useFieldProvider.d.ts +3 -3
- package/cjs/extensions/forms/Field/Upload/Upload.d.ts +1 -1
- package/cjs/extensions/forms/Field/Upload/Upload.js +3 -1
- package/cjs/extensions/forms/Field/Upload/Upload.js.map +1 -1
- package/cjs/extensions/forms/FieldBlock/FieldBlock.js +11 -4
- package/cjs/extensions/forms/FieldBlock/FieldBlock.js.map +1 -1
- package/cjs/extensions/forms/FieldBlock/FieldBlockContext.d.ts +1 -1
- package/cjs/extensions/forms/FieldBlock/FieldBlockContext.js.map +1 -1
- package/cjs/extensions/forms/hooks/DataValueWritePropsDocs.js +1 -1
- package/cjs/extensions/forms/hooks/DataValueWritePropsDocs.js.map +1 -1
- package/cjs/extensions/forms/hooks/useFieldProps.js +50 -17
- package/cjs/extensions/forms/hooks/useFieldProps.js.map +1 -1
- package/cjs/extensions/forms/types.d.ts +8 -5
- package/cjs/extensions/forms/types.js.map +1 -1
- package/cjs/extensions/forms/utils/FormError.d.ts +20 -16
- package/cjs/extensions/forms/utils/FormError.js.map +1 -1
- package/cjs/shared/Eufemia.d.ts +1 -1
- package/cjs/shared/Eufemia.js +2 -2
- package/cjs/shared/Eufemia.js.map +1 -1
- package/cjs/style/core/scopes.scss +1 -1
- package/cjs/style/dnb-ui-basis.css +1 -1
- package/cjs/style/dnb-ui-basis.min.css +1 -1
- package/cjs/style/dnb-ui-body.css +1 -1
- package/cjs/style/dnb-ui-body.min.css +1 -1
- package/cjs/style/dnb-ui-core.css +1 -1
- package/cjs/style/dnb-ui-core.min.css +1 -1
- package/components/date-picker/DatePickerContext.d.ts +0 -1
- package/components/date-picker/DatePickerContext.js.map +1 -1
- package/components/date-picker/DatePickerInput.js +7 -59
- package/components/date-picker/DatePickerInput.js.map +1 -1
- package/components/date-picker/DatePickerProvider.js +0 -2
- package/components/date-picker/DatePickerProvider.js.map +1 -1
- package/components/date-picker/hooks/useDates.d.ts +0 -2
- package/components/date-picker/hooks/useDates.js +3 -5
- package/components/date-picker/hooks/useDates.js.map +1 -1
- package/components/input-masked/InputMaskedHooks.js +11 -7
- package/components/input-masked/InputMaskedHooks.js.map +1 -1
- package/components/input-masked/InputMaskedUtils.d.ts +1 -1
- package/components/input-masked/InputMaskedUtils.js +2 -1
- package/components/input-masked/InputMaskedUtils.js.map +1 -1
- package/components/modal/ModalDocs.d.ts +2 -0
- package/components/modal/ModalDocs.js +10 -0
- package/components/modal/ModalDocs.js.map +1 -1
- package/components/upload/Upload.js +6 -3
- package/components/upload/Upload.js.map +1 -1
- package/components/upload/UploadDocs.d.ts +1 -0
- package/components/upload/UploadDocs.js +42 -0
- package/components/upload/UploadDocs.js.map +1 -1
- package/components/upload/UploadFileListCell.js +32 -12
- package/components/upload/UploadFileListCell.js.map +1 -1
- package/components/upload/types.d.ts +7 -0
- package/components/upload/types.js.map +1 -1
- package/es/components/date-picker/DatePickerContext.d.ts +0 -1
- package/es/components/date-picker/DatePickerContext.js.map +1 -1
- package/es/components/date-picker/DatePickerInput.js +2 -53
- package/es/components/date-picker/DatePickerInput.js.map +1 -1
- package/es/components/date-picker/DatePickerProvider.js +0 -2
- package/es/components/date-picker/DatePickerProvider.js.map +1 -1
- package/es/components/date-picker/hooks/useDates.d.ts +0 -2
- package/es/components/date-picker/hooks/useDates.js +3 -5
- package/es/components/date-picker/hooks/useDates.js.map +1 -1
- package/es/components/input-masked/InputMaskedHooks.js +11 -7
- package/es/components/input-masked/InputMaskedHooks.js.map +1 -1
- package/es/components/input-masked/InputMaskedUtils.d.ts +1 -1
- package/es/components/input-masked/InputMaskedUtils.js +2 -1
- package/es/components/input-masked/InputMaskedUtils.js.map +1 -1
- package/es/components/modal/ModalDocs.d.ts +2 -0
- package/es/components/modal/ModalDocs.js +6 -0
- package/es/components/modal/ModalDocs.js.map +1 -1
- package/es/components/upload/Upload.js +6 -3
- package/es/components/upload/Upload.js.map +1 -1
- package/es/components/upload/UploadDocs.d.ts +1 -0
- package/es/components/upload/UploadDocs.js +42 -0
- package/es/components/upload/UploadDocs.js.map +1 -1
- package/es/components/upload/UploadFileListCell.js +32 -12
- package/es/components/upload/UploadFileListCell.js.map +1 -1
- package/es/components/upload/types.d.ts +7 -0
- package/es/components/upload/types.js.map +1 -1
- package/es/extensions/forms/DataContext/Provider/ProviderDocs.js +1 -1
- package/es/extensions/forms/DataContext/Provider/ProviderDocs.js.map +1 -1
- package/es/extensions/forms/Field/Number/Number.js +3 -6
- package/es/extensions/forms/Field/Number/Number.js.map +1 -1
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumber.d.ts +6 -4
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumber.js +24 -16
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumber.js.map +1 -1
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.d.ts +2 -2
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js +7 -2
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js.map +1 -1
- package/es/extensions/forms/Field/Provider/useFieldProvider.d.ts +3 -3
- package/es/extensions/forms/Field/Upload/Upload.d.ts +1 -1
- package/es/extensions/forms/Field/Upload/Upload.js +3 -1
- package/es/extensions/forms/Field/Upload/Upload.js.map +1 -1
- package/es/extensions/forms/FieldBlock/FieldBlock.js +11 -4
- package/es/extensions/forms/FieldBlock/FieldBlock.js.map +1 -1
- package/es/extensions/forms/FieldBlock/FieldBlockContext.d.ts +1 -1
- package/es/extensions/forms/FieldBlock/FieldBlockContext.js.map +1 -1
- package/es/extensions/forms/hooks/DataValueWritePropsDocs.js +1 -1
- package/es/extensions/forms/hooks/DataValueWritePropsDocs.js.map +1 -1
- package/es/extensions/forms/hooks/useFieldProps.js +51 -18
- package/es/extensions/forms/hooks/useFieldProps.js.map +1 -1
- package/es/extensions/forms/types.d.ts +8 -5
- package/es/extensions/forms/types.js.map +1 -1
- package/es/extensions/forms/utils/FormError.d.ts +20 -16
- package/es/extensions/forms/utils/FormError.js +1 -0
- package/es/extensions/forms/utils/FormError.js.map +1 -1
- package/es/shared/Eufemia.d.ts +1 -1
- package/es/shared/Eufemia.js +2 -2
- package/es/shared/Eufemia.js.map +1 -1
- package/es/style/core/scopes.scss +1 -1
- package/es/style/dnb-ui-basis.css +1 -1
- package/es/style/dnb-ui-basis.min.css +1 -1
- package/es/style/dnb-ui-body.css +1 -1
- package/es/style/dnb-ui-body.min.css +1 -1
- package/es/style/dnb-ui-core.css +1 -1
- package/es/style/dnb-ui-core.min.css +1 -1
- package/esm/dnb-ui-basis.min.mjs +1 -1
- package/esm/dnb-ui-components.min.mjs +1 -1
- package/esm/dnb-ui-elements.min.mjs +1 -1
- package/esm/dnb-ui-extensions.min.mjs +1 -1
- package/esm/dnb-ui-lib.min.mjs +1 -1
- package/extensions/forms/DataContext/Provider/ProviderDocs.js +1 -1
- package/extensions/forms/DataContext/Provider/ProviderDocs.js.map +1 -1
- package/extensions/forms/Field/Number/Number.js +3 -6
- package/extensions/forms/Field/Number/Number.js.map +1 -1
- package/extensions/forms/Field/PhoneNumber/PhoneNumber.d.ts +6 -4
- package/extensions/forms/Field/PhoneNumber/PhoneNumber.js +33 -25
- package/extensions/forms/Field/PhoneNumber/PhoneNumber.js.map +1 -1
- package/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.d.ts +2 -2
- package/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js +7 -2
- package/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js.map +1 -1
- package/extensions/forms/Field/Provider/useFieldProvider.d.ts +3 -3
- package/extensions/forms/Field/Upload/Upload.d.ts +1 -1
- package/extensions/forms/Field/Upload/Upload.js +3 -1
- package/extensions/forms/Field/Upload/Upload.js.map +1 -1
- package/extensions/forms/FieldBlock/FieldBlock.js +11 -4
- package/extensions/forms/FieldBlock/FieldBlock.js.map +1 -1
- package/extensions/forms/FieldBlock/FieldBlockContext.d.ts +1 -1
- package/extensions/forms/FieldBlock/FieldBlockContext.js.map +1 -1
- package/extensions/forms/hooks/DataValueWritePropsDocs.js +1 -1
- package/extensions/forms/hooks/DataValueWritePropsDocs.js.map +1 -1
- package/extensions/forms/hooks/useFieldProps.js +51 -18
- package/extensions/forms/hooks/useFieldProps.js.map +1 -1
- package/extensions/forms/types.d.ts +8 -5
- package/extensions/forms/types.js.map +1 -1
- package/extensions/forms/utils/FormError.d.ts +20 -16
- package/extensions/forms/utils/FormError.js.map +1 -1
- package/package.json +1 -1
- package/shared/Eufemia.d.ts +1 -1
- package/shared/Eufemia.js +2 -2
- package/shared/Eufemia.js.map +1 -1
- package/style/core/scopes.scss +1 -1
- package/style/dnb-ui-basis.css +1 -1
- package/style/dnb-ui-basis.min.css +1 -1
- package/style/dnb-ui-body.css +1 -1
- package/style/dnb-ui-body.min.css +1 -1
- package/style/dnb-ui-core.css +1 -1
- package/style/dnb-ui-core.min.css +1 -1
- package/umd/dnb-ui-basis.min.js +1 -1
- package/umd/dnb-ui-components.min.js +1 -1
- package/umd/dnb-ui-elements.min.js +1 -1
- package/umd/dnb-ui-extensions.min.js +1 -1
- package/umd/dnb-ui-lib.min.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputMaskedHooks.js","names":["React","useCallback","classnames","cleanNumber","getCurrencySymbol","isTrue","dispatchCustomElementEvent","extendPropsWithContext","keycode","safeSetSelection","TextMask","createNumberMask","InputMaskedContext","isRequestingLocaleSupport","isRequestingNumberMask","correctNumberValue","handlePercentMask","handleCurrencyMask","handleNumberMask","correctCaretPosition","getSoftKeyboardAttributes","handleThousandsSeparator","handleDecimalSeparator","fromJSON","invisibleSpace","useLayoutEffect","window","useEffect","useFilteredProps","props","useContext","mask","number_mask","currency_mask","number_format","mask_options","as_currency","as_number","as_percent","locale","show_mask","show_guide","pipe","keep_char_positions","placeholder_char","attributes","_objectWithoutProperties","_excluded","htmlAttributes","Object","freeze","useTranslation","context","useLocalValue","maskParams","useNumberMaskParams","localValue","setLocalValue","useState","value","useNumberMask","useMask","numberMask","useMaskParams","placeholder","showMask","placeholderChar","showGuide","keepCharPositions","useInputElement","inner_ref","isFn","refHook","useRef","ref","current","inputElementRef","createElement","params","innerRef","_extends","inputRef","inputElement","guide","className","useEventMapping","_ref","callEvent","useCallEvent","onBeforeInput","event","onFocus","onBlur","onMouseUp","onMouseDown","onKeyDown","onSubmit","onChange","on_focus","undefined","on_blur","on_key_down","on_submit","on_change","_ref2","isNumberMask","decimalSeparators","isUnidentified","_ref3","name","target","selStart","selectionStart","keyCode","which","data","key","disallowLeadingZeroes","replace","test","testValue","slice","length","preventDefault","decimalSymbol","hasDecimalSymbol","includes","allowedDecimals","decimalLimit","allowDecimal","charAtSelection","index","indexOf","thousandsSeparatorSymbol","num","prefix","suffix","decimalSeparator","thousandsSeparator","numberValue","Number","cleanedValue","String","charAt","runCorrectCaretPosition","__getCorrectCaretPosition","result","_currency_mask","_objectSpread","currency","_currency_mask2","currencyDisplay"],"sources":["../../../../src/components/input-masked/InputMaskedHooks.js"],"sourcesContent":["/**\n * Web InputMasked Component\n *\n */\n\nimport React, { useCallback } from 'react'\nimport classnames from 'classnames'\nimport {\n cleanNumber,\n getCurrencySymbol,\n} from '../number-format/NumberUtils'\nimport {\n isTrue,\n dispatchCustomElementEvent,\n extendPropsWithContext,\n keycode,\n} from '../../shared/component-helper'\nimport { safeSetSelection } from './text-mask/createTextMaskInputElement'\n\nimport TextMask from './TextMask'\nimport createNumberMask from './addons/createNumberMask'\nimport InputMaskedContext from './InputMaskedContext'\n\nimport {\n isRequestingLocaleSupport,\n isRequestingNumberMask,\n correctNumberValue,\n handlePercentMask,\n handleCurrencyMask,\n handleNumberMask,\n correctCaretPosition,\n getSoftKeyboardAttributes,\n handleThousandsSeparator,\n handleDecimalSeparator,\n fromJSON,\n invisibleSpace,\n} from './InputMaskedUtils'\n\n// SSR warning fix: https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85\nconst useLayoutEffect =\n typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect\n\n/**\n * Takes all component properties and filters out all internal used properties\n *\n * @returns object {props, htmlAttributes}\n */\nexport const useFilteredProps = () => {\n const { props } = React.useContext(InputMaskedContext)\n\n const {\n mask, // eslint-disable-line\n number_mask, // eslint-disable-line\n currency_mask, // eslint-disable-line\n number_format, // eslint-disable-line\n mask_options, // eslint-disable-line\n as_currency, // eslint-disable-line\n as_number, // eslint-disable-line\n as_percent, // eslint-disable-line\n locale, // eslint-disable-line\n show_mask, // eslint-disable-line\n show_guide, // eslint-disable-line\n pipe, // eslint-disable-line\n keep_char_positions, // eslint-disable-line\n placeholder_char, // eslint-disable-line\n\n // Get get rest of possible attributes\n ...attributes\n } = props\n\n return { props, htmlAttributes: Object.freeze(attributes) }\n}\n\n/**\n * Returns locale from either component or context\n *\n * @returns string\n */\nexport const useTranslation = () => {\n const { props, context } = React.useContext(InputMaskedContext)\n\n let { locale } = props\n if (!locale && context?.locale) {\n locale = context.locale\n }\n\n return locale\n}\n\n/**\n * Handle internal value state\n *\n * It handles both the value state given as a prop form outside,\n * along with the current written and internal value.\n *\n * @returns object with internal value state and state setter\n */\nexport const useLocalValue = () => {\n const { props, context } = React.useContext(InputMaskedContext)\n const maskParams = useNumberMaskParams() || {}\n const locale = useTranslation()\n\n const [localValue, setLocalValue] = React.useState(() =>\n correctNumberValue({\n locale,\n props,\n maskParams,\n })\n )\n\n /**\n * Use an effect here, just;\n * because when a property gets changed from outside\n */\n React.useEffect(() => {\n const value = correctNumberValue({\n localValue,\n locale,\n props,\n maskParams,\n })\n\n setLocalValue(value)\n\n // Do not set \"localValue\" and \"maskParams\" here\n }, [props, context, locale]) // eslint-disable-line\n\n return { localValue, setLocalValue }\n}\n\n/**\n * Create createNumberMask if number mask parameters exists\n *\n * @returns mask function\n */\nexport const useNumberMask = () => {\n const maskParams = useNumberMaskParams()\n const { props } = React.useContext(InputMaskedContext)\n\n if (!maskParams || !isRequestingNumberMask(props)) {\n return null\n }\n\n const mask = createNumberMask(maskParams)\n\n mask.maskParams = maskParams\n\n return mask\n}\n\n/**\n * Returns either internal mask or given property mask\n *\n * @returns mask function\n */\nexport const useMask = () => {\n const { props } = React.useContext(InputMaskedContext)\n\n const numberMask = useNumberMask()\n if (numberMask) {\n return numberMask\n }\n\n return props.mask\n}\n\n/**\n * Returns the final mask params\n *\n * @returns mask params\n */\nexport const useMaskParams = () => {\n const { props } = React.useContext(InputMaskedContext)\n\n const {\n keep_char_positions,\n show_guide,\n show_mask,\n placeholder_char,\n placeholder,\n } = props\n\n const mask = useMask()\n const maskParams = useNumberMaskParams() || {}\n\n maskParams.showMask = !placeholder && isTrue(show_mask)\n\n // Revalidated placeholder char to a zero width space\n maskParams.placeholderChar = placeholder_char\n if (typeof mask?.placeholderChar !== 'undefined') {\n maskParams.placeholderChar = mask.placeholderChar\n }\n if (maskParams.placeholderChar === null) {\n maskParams.placeholderChar = invisibleSpace\n }\n\n if (typeof mask?.showMask !== 'undefined') {\n maskParams.showMask = mask.showMask\n }\n\n maskParams.showGuide = isTrue(show_guide)\n maskParams.keepCharPositions = isTrue(keep_char_positions)\n\n return maskParams\n}\n\n/**\n * Handle the TextMask dependency\n *\n * @returns React Element\n */\nexport const useInputElement = () => {\n const { props } = React.useContext(InputMaskedContext)\n const { pipe, inner_ref } = props\n\n const mask = useMask()\n const { showMask, showGuide, placeholderChar, keepCharPositions } =\n useMaskParams()\n\n const isFn = typeof inner_ref === 'function'\n const refHook = React.useRef()\n const ref = (!isFn && inner_ref) || refHook\n\n useLayoutEffect(() => {\n if (isFn) {\n inner_ref?.(ref.current)\n }\n }, [inner_ref, isFn, ref])\n\n // Create the actual input element\n const inputElementRef = React.useRef(<input ref={ref} />)\n\n return useCallback(\n (params, innerRef) => {\n // Set ref for Eufemia input\n innerRef.current = ref.current\n\n return (\n <TextMask\n inputRef={ref}\n inputElement={inputElementRef.current}\n pipe={pipe}\n mask={mask || createNumberMask()}\n showMask={showMask}\n guide={showGuide}\n keepCharPositions={keepCharPositions}\n placeholderChar={placeholderChar}\n {...getSoftKeyboardAttributes(mask)}\n {...params}\n className={classnames(\n params.className,\n showMask &&\n showGuide &&\n placeholderChar &&\n placeholderChar !== invisibleSpace &&\n 'dnb-input-masked--guide' // will use --font-family-monospace\n )}\n />\n )\n },\n [\n keepCharPositions,\n mask,\n pipe,\n placeholderChar,\n ref,\n showGuide,\n showMask,\n ]\n )\n}\n\n/**\n * Will map some events we need to map during typing\n *\n * @param {object} param0\n * @property {function} setLocalValue setState handler\n * @returns object of events to handle\n */\nexport const useEventMapping = ({ setLocalValue }) => {\n const callEvent = useCallEvent({ setLocalValue })\n\n return {\n onBeforeInput: (event) => callEvent({ event }, 'on_before_input'),\n onFocus: (params) => callEvent(params, 'on_focus'),\n onBlur: (params) => callEvent(params, 'on_blur'),\n onMouseUp: (event) => callEvent({ event }, 'on_mouse_up'),\n onMouseDown: (event) => callEvent({ event }, 'on_mouse_down'),\n onKeyDown: (params) => callEvent(params, 'on_key_down'),\n onSubmit: (params) => callEvent(params, 'on_submit'),\n onChange: (params) => callEvent(params, 'on_change'),\n\n on_focus: undefined,\n on_blur: undefined,\n on_key_down: undefined,\n on_submit: undefined,\n on_change: undefined,\n }\n}\n\n/**\n * Will map some events we need to map during typing\n *\n * @param {object} param0\n * @property {function} setLocalValue setState handler\n * @returns event handler function\n */\nconst useCallEvent = ({ setLocalValue }) => {\n const { props } = React.useContext(InputMaskedContext)\n const maskParams = useMaskParams()\n const isNumberMask = useNumberMask()\n\n // Source: https://en.wikipedia.org/wiki/Decimal_separator\n const decimalSeparators = /[,.'·]/\n let isUnidentified = false\n\n const callEvent = ({ event, value }, name) => {\n value = value || event.target.value\n const selStart = event.target.selectionStart\n let keyCode = keycode(event)\n\n // Android issue: https://bugs.chromium.org/p/chromium/issues/detail?id=118639\n if (\n name === 'on_key_down' &&\n (event.which === 229 || keyCode === undefined)\n ) {\n isUnidentified = true\n }\n\n // Android issue: https://bugs.chromium.org/p/chromium/issues/detail?id=118639\n // so we use this solution instead\n if (\n isUnidentified &&\n name === 'on_before_input' &&\n typeof event?.data !== 'undefined'\n ) {\n name = 'on_key_down'\n keyCode = event.data\n isUnidentified = false\n }\n\n // Add support for \"await userEvent.type(input, '0...')\"\n if (isUnidentified && event.key === '0') {\n keyCode = '0'\n isUnidentified = false\n }\n\n // Prevent entering a leading zero\n if (\n name === 'on_key_down' &&\n !isUnidentified &&\n maskParams?.disallowLeadingZeroes &&\n (keyCode === '0' ||\n keyCode === 'numpad 0' ||\n (value.replace(/[^\\d]/g, '') === '' &&\n decimalSeparators.test(keyCode)))\n ) {\n const testValue = (\n value.slice(0, selStart) +\n '0' +\n value.slice(selStart + 1, value.length)\n ).replace(/[^\\d]/g, '')\n\n if (/^0/.test(testValue)) {\n event.preventDefault()\n }\n }\n\n if (\n name === 'on_key_down' &&\n isNumberMask &&\n !isUnidentified &&\n maskParams?.decimalSymbol\n ) {\n const hasDecimalSymbol = value.includes(maskParams.decimalSymbol)\n const allowedDecimals =\n maskParams.decimalLimit > 0 || maskParams.allowDecimal !== false\n\n if (!allowedDecimals && decimalSeparators.test(keyCode)) {\n event.preventDefault()\n }\n\n const charAtSelection = value.slice(selStart, selStart + 1)\n\n if (allowedDecimals) {\n // if we have already a decimal ...\n if (hasDecimalSymbol && decimalSeparators.test(keyCode)) {\n // ... we set the cursor on after the decimalSeparators\n if (decimalSeparators.test(charAtSelection)) {\n const index = value.indexOf(maskParams.decimalSymbol)\n if (index > -1) {\n safeSetSelection(event.target, index + 1)\n }\n }\n\n // ... we do not allow to type another\n event.preventDefault()\n }\n\n // replace other decimal\n else if (\n !hasDecimalSymbol &&\n keyCode !== maskParams.decimalSymbol &&\n decimalSeparators.test(keyCode)\n ) {\n value = value.slice(0, selStart)\n setLocalValue(value + maskParams.decimalSymbol)\n event.target.value = value + maskParams.decimalSymbol\n event.preventDefault()\n }\n }\n\n // move cursor to right if key is delete and char at selection is thousand separator\n if (\n keyCode === 'delete' &&\n charAtSelection === (maskParams.thousandsSeparatorSymbol || ' ')\n ) {\n safeSetSelection(event.target, selStart + 1)\n event.preventDefault()\n }\n }\n\n let num = cleanNumber(value, {\n prefix: maskParams.prefix,\n suffix: maskParams.suffix,\n decimalSeparator: maskParams.decimalSymbol || ',',\n thousandsSeparator: maskParams.thousandsSeparatorSymbol || ' ',\n })\n\n // We don't want to return NaN, so we set it to 0\n if (num === '-') {\n num = -0\n }\n\n const numberValue = Number(num)\n\n // Return '' (empty string) when the user has entered something invalid\n const cleanedValue =\n numberValue === 0 && String(num).charAt(0) !== '0' ? '' : num\n\n switch (name) {\n case 'on_focus':\n case 'on_key_down':\n case 'on_mouse_down':\n case 'on_mouse_up':\n event.target.runCorrectCaretPosition = () =>\n correctCaretPosition(event.target, maskParams, props)\n if (!event.target.__getCorrectCaretPosition) {\n event.target.runCorrectCaretPosition()\n }\n break\n }\n\n const result = dispatchCustomElementEvent(props, name, {\n event,\n value,\n numberValue,\n cleanedValue,\n })\n\n if (name === 'on_change') {\n setLocalValue(value)\n }\n\n return result\n }\n\n return callEvent\n}\n\n/**\n * Returns number mask parameters if requested by the component properties\n *\n * @returns object of number mask parameter\n */\nconst useNumberMaskParams = () => {\n const { props } = React.useContext(InputMaskedContext)\n const locale = useTranslation()\n\n if (!isRequestingNumberMask(props)) {\n return { ...fromJSON(props.mask_options) }\n }\n\n let { number_mask, currency_mask, mask_options } = props\n const { as_number, as_percent, as_currency, value } = props\n\n mask_options = fromJSON(mask_options)\n number_mask = isTrue(number_mask) ? {} : fromJSON(number_mask)\n currency_mask = isTrue(currency_mask)\n ? {}\n : fromJSON(currency_mask, {\n currency: currency_mask,\n })\n if (!currency_mask?.currency) {\n delete currency_mask.currency\n }\n\n if (isRequestingLocaleSupport(props)) {\n const thousandsSeparatorSymbol = handleThousandsSeparator(locale)\n const decimalSymbol = handleDecimalSeparator(locale)\n\n if (isTrue(as_number) || isTrue(as_percent)) {\n number_mask = extendPropsWithContext(number_mask, null, {\n decimalSymbol,\n thousandsSeparatorSymbol,\n })\n } else if (as_currency) {\n currency_mask = extendPropsWithContext(currency_mask, null, {\n decimalSymbol,\n thousandsSeparatorSymbol,\n currency: getCurrencySymbol(\n locale,\n typeof as_currency === 'string' ? as_currency : null,\n currency_mask?.currencyDisplay,\n value\n ),\n })\n }\n }\n\n let maskParams = null\n\n if (number_mask) {\n maskParams = handleNumberMask({\n mask_options,\n number_mask,\n })\n\n if (isTrue(as_percent)) {\n maskParams = handlePercentMask({ props, locale, maskParams })\n }\n } else if (currency_mask) {\n maskParams = handleCurrencyMask({\n mask_options,\n currency_mask,\n })\n }\n\n return maskParams\n}\n"],"mappings":";;;;;;;;AAKA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAC1C,OAAOC,UAAU,MAAM,YAAY;AACnC,SACEC,WAAW,EACXC,iBAAiB,QACZ,8BAA8B;AACrC,SACEC,MAAM,EACNC,0BAA0B,EAC1BC,sBAAsB,EACtBC,OAAO,QACF,+BAA+B;AACtC,SAASC,gBAAgB,QAAQ,wCAAwC;AAEzE,OAAOC,QAAQ,MAAM,YAAY;AACjC,OAAOC,gBAAgB,MAAM,2BAA2B;AACxD,OAAOC,kBAAkB,MAAM,sBAAsB;AAErD,SACEC,yBAAyB,EACzBC,sBAAsB,EACtBC,kBAAkB,EAClBC,iBAAiB,EACjBC,kBAAkB,EAClBC,gBAAgB,EAChBC,oBAAoB,EACpBC,yBAAyB,EACzBC,wBAAwB,EACxBC,sBAAsB,EACtBC,QAAQ,EACRC,cAAc,QACT,oBAAoB;AAG3B,MAAMC,eAAe,GACnB,OAAOC,MAAM,KAAK,WAAW,GA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B,UAAU;AACnB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"InputMaskedHooks.js","names":["React","useCallback","classnames","cleanNumber","getCurrencySymbol","isTrue","dispatchCustomElementEvent","extendPropsWithContext","keycode","safeSetSelection","TextMask","createNumberMask","InputMaskedContext","isRequestingLocaleSupport","isRequestingNumberMask","correctNumberValue","handlePercentMask","handleCurrencyMask","handleNumberMask","correctCaretPosition","getSoftKeyboardAttributes","handleThousandsSeparator","handleDecimalSeparator","fromJSON","invisibleSpace","useLayoutEffect","window","useEffect","useFilteredProps","props","useContext","mask","number_mask","currency_mask","number_format","mask_options","as_currency","as_number","as_percent","locale","show_mask","show_guide","pipe","keep_char_positions","placeholder_char","attributes","_objectWithoutProperties","_excluded","htmlAttributes","Object","freeze","useTranslation","context","useLocalValue","maskParams","useNumberMaskParams","localValue","setLocalValue","useState","value","useNumberMask","useMask","numberMask","useMaskParams","placeholder","showMask","placeholderChar","showGuide","keepCharPositions","useInputElement","inner_ref","isFn","refHook","useRef","ref","current","inputElementRef","createElement","params","innerRef","_extends","inputRef","inputElement","guide","className","useEventMapping","_ref","callEvent","useCallEvent","onBeforeInput","event","onFocus","onBlur","onMouseUp","onMouseDown","onKeyDown","onSubmit","onChange","on_focus","undefined","on_blur","on_key_down","on_submit","on_change","_ref2","maskParamsRef","isNumberMask","decimalSeparators","isUnidentified","_ref3","name","target","selStart","selectionStart","keyCode","which","data","key","disallowLeadingZeroes","replace","test","testValue","slice","length","preventDefault","decimalSymbol","hasDecimalSymbol","includes","allowedDecimals","decimalLimit","allowDecimal","charAtSelection","index","indexOf","thousandsSeparatorSymbol","num","prefix","suffix","decimalSeparator","thousandsSeparator","numberValue","Number","cleanedValue","String","charAt","runCorrectCaretPosition","__getCorrectCaretPosition","result","_currency_mask","_objectSpread","currency","_currency_mask2","currencyDisplay"],"sources":["../../../../src/components/input-masked/InputMaskedHooks.js"],"sourcesContent":["/**\n * Web InputMasked Component\n *\n */\n\nimport React, { useCallback } from 'react'\nimport classnames from 'classnames'\nimport {\n cleanNumber,\n getCurrencySymbol,\n} from '../number-format/NumberUtils'\nimport {\n isTrue,\n dispatchCustomElementEvent,\n extendPropsWithContext,\n keycode,\n} from '../../shared/component-helper'\nimport { safeSetSelection } from './text-mask/createTextMaskInputElement'\n\nimport TextMask from './TextMask'\nimport createNumberMask from './addons/createNumberMask'\nimport InputMaskedContext from './InputMaskedContext'\n\nimport {\n isRequestingLocaleSupport,\n isRequestingNumberMask,\n correctNumberValue,\n handlePercentMask,\n handleCurrencyMask,\n handleNumberMask,\n correctCaretPosition,\n getSoftKeyboardAttributes,\n handleThousandsSeparator,\n handleDecimalSeparator,\n fromJSON,\n invisibleSpace,\n} from './InputMaskedUtils'\n\n// SSR warning fix: https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85\nconst useLayoutEffect =\n typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect\n\n/**\n * Takes all component properties and filters out all internal used properties\n *\n * @returns object {props, htmlAttributes}\n */\nexport const useFilteredProps = () => {\n const { props } = React.useContext(InputMaskedContext)\n\n const {\n mask, // eslint-disable-line\n number_mask, // eslint-disable-line\n currency_mask, // eslint-disable-line\n number_format, // eslint-disable-line\n mask_options, // eslint-disable-line\n as_currency, // eslint-disable-line\n as_number, // eslint-disable-line\n as_percent, // eslint-disable-line\n locale, // eslint-disable-line\n show_mask, // eslint-disable-line\n show_guide, // eslint-disable-line\n pipe, // eslint-disable-line\n keep_char_positions, // eslint-disable-line\n placeholder_char, // eslint-disable-line\n\n // Get get rest of possible attributes\n ...attributes\n } = props\n\n return { props, htmlAttributes: Object.freeze(attributes) }\n}\n\n/**\n * Returns locale from either component or context\n *\n * @returns string\n */\nexport const useTranslation = () => {\n const { props, context } = React.useContext(InputMaskedContext)\n\n let { locale } = props\n if (!locale && context?.locale) {\n locale = context.locale\n }\n\n return locale\n}\n\n/**\n * Handle internal value state\n *\n * It handles both the value state given as a prop form outside,\n * along with the current written and internal value.\n *\n * @returns object with internal value state and state setter\n */\nexport const useLocalValue = () => {\n const { props, context } = React.useContext(InputMaskedContext)\n const maskParams = useNumberMaskParams() || {}\n const locale = useTranslation()\n\n const [localValue, setLocalValue] = React.useState(() => {\n return correctNumberValue({\n locale,\n props,\n maskParams,\n })\n })\n\n /**\n * Use an effect here, just;\n * because when a property gets changed from outside\n */\n React.useEffect(() => {\n const value = correctNumberValue({\n localValue,\n locale,\n props,\n maskParams,\n })\n\n setLocalValue(value)\n\n // Do not set \"localValue\" and \"maskParams\" here\n }, [props, context, locale]) // eslint-disable-line\n\n return { localValue, setLocalValue }\n}\n\n/**\n * Create createNumberMask if number mask parameters exists\n *\n * @returns mask function\n */\nexport const useNumberMask = () => {\n const maskParams = useNumberMaskParams()\n const { props } = React.useContext(InputMaskedContext)\n\n if (!maskParams || !isRequestingNumberMask(props)) {\n return null\n }\n\n const mask = createNumberMask(maskParams)\n\n mask.maskParams = maskParams\n\n return mask\n}\n\n/**\n * Returns either internal mask or given property mask\n *\n * @returns mask function\n */\nexport const useMask = () => {\n const { props } = React.useContext(InputMaskedContext)\n\n const numberMask = useNumberMask()\n if (numberMask) {\n return numberMask\n }\n\n return props.mask\n}\n\n/**\n * Returns the final mask params\n *\n * @returns mask params\n */\nexport const useMaskParams = () => {\n const { props } = React.useContext(InputMaskedContext)\n\n const {\n keep_char_positions,\n show_guide,\n show_mask,\n placeholder_char,\n placeholder,\n } = props\n\n const mask = useMask()\n const maskParams = useNumberMaskParams() || {}\n\n maskParams.showMask = !placeholder && isTrue(show_mask)\n\n // Revalidated placeholder char to a zero width space\n maskParams.placeholderChar = placeholder_char\n if (typeof mask?.placeholderChar !== 'undefined') {\n maskParams.placeholderChar = mask.placeholderChar\n }\n if (maskParams.placeholderChar === null) {\n maskParams.placeholderChar = invisibleSpace\n }\n\n if (typeof mask?.showMask !== 'undefined') {\n maskParams.showMask = mask.showMask\n }\n\n maskParams.showGuide = isTrue(show_guide)\n maskParams.keepCharPositions = isTrue(keep_char_positions)\n\n return maskParams\n}\n\n/**\n * Handle the TextMask dependency\n *\n * @returns React Element\n */\nexport const useInputElement = () => {\n const { props } = React.useContext(InputMaskedContext)\n const { pipe, inner_ref } = props\n\n const mask = useMask()\n const { showMask, showGuide, placeholderChar, keepCharPositions } =\n useMaskParams()\n\n const isFn = typeof inner_ref === 'function'\n const refHook = React.useRef()\n const ref = (!isFn && inner_ref) || refHook\n\n useLayoutEffect(() => {\n if (isFn) {\n inner_ref?.(ref.current)\n }\n }, [inner_ref, isFn, ref])\n\n // Create the actual input element\n const inputElementRef = React.useRef(<input ref={ref} />)\n\n return useCallback(\n (params, innerRef) => {\n // Set ref for Eufemia input\n innerRef.current = ref.current\n\n return (\n <TextMask\n inputRef={ref}\n inputElement={inputElementRef.current}\n pipe={pipe}\n mask={mask || createNumberMask()}\n showMask={showMask}\n guide={showGuide}\n keepCharPositions={keepCharPositions}\n placeholderChar={placeholderChar}\n {...getSoftKeyboardAttributes(mask)}\n {...params}\n className={classnames(\n params.className,\n showMask &&\n showGuide &&\n placeholderChar &&\n placeholderChar !== invisibleSpace &&\n 'dnb-input-masked--guide' // will use --font-family-monospace\n )}\n />\n )\n },\n [\n keepCharPositions,\n mask,\n pipe,\n placeholderChar,\n ref,\n showGuide,\n showMask,\n ]\n )\n}\n\n/**\n * Will map some events we need to map during typing\n *\n * @param {object} param0\n * @property {function} setLocalValue setState handler\n * @returns object of events to handle\n */\nexport const useEventMapping = ({ setLocalValue }) => {\n const callEvent = useCallEvent({ setLocalValue })\n\n return {\n onBeforeInput: (event) => callEvent({ event }, 'on_before_input'),\n onFocus: (params) => callEvent(params, 'on_focus'),\n onBlur: (params) => callEvent(params, 'on_blur'),\n onMouseUp: (event) => callEvent({ event }, 'on_mouse_up'),\n onMouseDown: (event) => callEvent({ event }, 'on_mouse_down'),\n onKeyDown: (params) => callEvent(params, 'on_key_down'),\n onSubmit: (params) => callEvent(params, 'on_submit'),\n onChange: (params) => callEvent(params, 'on_change'),\n\n on_focus: undefined,\n on_blur: undefined,\n on_key_down: undefined,\n on_submit: undefined,\n on_change: undefined,\n }\n}\n\n/**\n * Will map some events we need to map during typing\n *\n * @param {object} param0\n * @property {function} setLocalValue setState handler\n * @returns event handler function\n */\nconst useCallEvent = ({ setLocalValue }) => {\n const maskParamsRef = React.useRef()\n maskParamsRef.current = useMaskParams()\n\n const { props } = React.useContext(InputMaskedContext)\n const isNumberMask = useNumberMask()\n\n // Source: https://en.wikipedia.org/wiki/Decimal_separator\n const decimalSeparators = /[,.'·]/\n let isUnidentified = false\n\n const callEvent = ({ event, value }, name) => {\n const maskParams = maskParamsRef.current\n value = value || event.target.value\n const selStart = event.target.selectionStart\n let keyCode = keycode(event)\n\n // Android issue: https://bugs.chromium.org/p/chromium/issues/detail?id=118639\n if (\n name === 'on_key_down' &&\n (event.which === 229 || keyCode === undefined)\n ) {\n isUnidentified = true\n }\n\n // Android issue: https://bugs.chromium.org/p/chromium/issues/detail?id=118639\n // so we use this solution instead\n if (\n isUnidentified &&\n name === 'on_before_input' &&\n typeof event?.data !== 'undefined'\n ) {\n name = 'on_key_down'\n keyCode = event.data\n isUnidentified = false\n }\n\n // Add support for \"await userEvent.type(input, '0...')\"\n if (isUnidentified && event.key === '0') {\n keyCode = '0'\n isUnidentified = false\n }\n\n // Prevent entering a leading zero\n if (\n name === 'on_key_down' &&\n !isUnidentified &&\n maskParams?.disallowLeadingZeroes &&\n (keyCode === '0' ||\n keyCode === 'numpad 0' ||\n (value.replace(/[^\\d]/g, '') === '' &&\n decimalSeparators.test(keyCode)))\n ) {\n const testValue = (\n value.slice(0, selStart) +\n '0' +\n value.slice(selStart + 1, value.length)\n ).replace(/[^\\d]/g, '')\n\n if (/^0/.test(testValue)) {\n event.preventDefault()\n }\n }\n\n if (\n name === 'on_key_down' &&\n isNumberMask &&\n !isUnidentified &&\n maskParams?.decimalSymbol\n ) {\n const hasDecimalSymbol = value.includes(maskParams.decimalSymbol)\n const allowedDecimals =\n maskParams.decimalLimit > 0 || maskParams.allowDecimal !== false\n\n if (!allowedDecimals && decimalSeparators.test(keyCode)) {\n event.preventDefault()\n }\n\n const charAtSelection = value.slice(selStart, selStart + 1)\n\n if (allowedDecimals) {\n // if we have already a decimal ...\n if (hasDecimalSymbol && decimalSeparators.test(keyCode)) {\n // ... we set the cursor on after the decimalSeparators\n if (decimalSeparators.test(charAtSelection)) {\n const index = value.indexOf(maskParams.decimalSymbol)\n if (index > -1) {\n safeSetSelection(event.target, index + 1)\n }\n }\n\n // ... we do not allow to type another\n event.preventDefault()\n }\n\n // replace other decimal\n else if (\n !hasDecimalSymbol &&\n keyCode !== maskParams.decimalSymbol &&\n decimalSeparators.test(keyCode)\n ) {\n value = value.slice(0, selStart)\n setLocalValue(value + maskParams.decimalSymbol)\n event.target.value = value + maskParams.decimalSymbol\n event.preventDefault()\n }\n }\n\n // move cursor to right if key is delete and char at selection is thousand separator\n if (\n keyCode === 'delete' &&\n charAtSelection === (maskParams.thousandsSeparatorSymbol || ' ')\n ) {\n safeSetSelection(event.target, selStart + 1)\n event.preventDefault()\n }\n }\n\n let num = cleanNumber(value, {\n prefix: maskParams.prefix,\n suffix: maskParams.suffix,\n decimalSeparator: maskParams.decimalSymbol || ',',\n thousandsSeparator: maskParams.thousandsSeparatorSymbol || ' ',\n })\n\n // We don't want to return NaN, so we set it to 0\n if (num === '-') {\n num = -0\n }\n\n const numberValue = Number(num)\n\n // Return '' (empty string) when the user has entered something invalid\n const cleanedValue =\n numberValue === 0 && String(num).charAt(0) !== '0' ? '' : num\n\n switch (name) {\n case 'on_focus':\n case 'on_key_down':\n case 'on_mouse_down':\n case 'on_mouse_up':\n event.target.runCorrectCaretPosition = () =>\n correctCaretPosition(event.target, maskParamsRef, props)\n if (!event.target.__getCorrectCaretPosition) {\n event.target.runCorrectCaretPosition()\n }\n break\n }\n\n const result = dispatchCustomElementEvent(props, name, {\n event,\n value,\n numberValue,\n cleanedValue,\n })\n\n if (name === 'on_change') {\n setLocalValue(value)\n }\n\n return result\n }\n\n return callEvent\n}\n\n/**\n * Returns number mask parameters if requested by the component properties\n *\n * @returns object of number mask parameter\n */\nconst useNumberMaskParams = () => {\n const { props } = React.useContext(InputMaskedContext)\n const locale = useTranslation()\n\n if (!isRequestingNumberMask(props)) {\n return { ...fromJSON(props.mask_options) }\n }\n\n let { number_mask, currency_mask, mask_options } = props\n const { as_number, as_percent, as_currency, value } = props\n\n mask_options = fromJSON(mask_options)\n number_mask = isTrue(number_mask) ? {} : fromJSON(number_mask)\n currency_mask = isTrue(currency_mask)\n ? {}\n : fromJSON(currency_mask, {\n currency: currency_mask,\n })\n if (!currency_mask?.currency) {\n delete currency_mask.currency\n }\n\n if (isRequestingLocaleSupport(props)) {\n const thousandsSeparatorSymbol = handleThousandsSeparator(locale)\n const decimalSymbol = handleDecimalSeparator(locale)\n\n if (isTrue(as_number) || isTrue(as_percent)) {\n number_mask = extendPropsWithContext(number_mask, null, {\n decimalSymbol,\n thousandsSeparatorSymbol,\n })\n } else if (as_currency) {\n currency_mask = extendPropsWithContext(currency_mask, null, {\n decimalSymbol,\n thousandsSeparatorSymbol,\n currency: getCurrencySymbol(\n locale,\n typeof as_currency === 'string' ? as_currency : null,\n currency_mask?.currencyDisplay,\n value\n ),\n })\n }\n }\n\n let maskParams = null\n\n if (number_mask) {\n maskParams = handleNumberMask({\n mask_options,\n number_mask,\n })\n\n if (isTrue(as_percent)) {\n maskParams = handlePercentMask({ props, locale, maskParams })\n }\n } else if (currency_mask) {\n maskParams = handleCurrencyMask({\n mask_options,\n currency_mask,\n })\n }\n\n return maskParams\n}\n"],"mappings":";;;;;;;;AAKA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAC1C,OAAOC,UAAU,MAAM,YAAY;AACnC,SACEC,WAAW,EACXC,iBAAiB,QACZ,8BAA8B;AACrC,SACEC,MAAM,EACNC,0BAA0B,EAC1BC,sBAAsB,EACtBC,OAAO,QACF,+BAA+B;AACtC,SAASC,gBAAgB,QAAQ,wCAAwC;AAEzE,O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AAsH,eAAA,uBAAbA,eAAA,CAAeC,eAAe,EAC9B7F,KACF;MACF,CAAC,CAAC;IACJ;EACF;EAEA,IAAIL,UAAU,GAAG,IAAI;EAErB,IAAItB,WAAW,EAAE;IACfsB,UAAU,GAAGpC,gBAAgB,CAAC;MAC5BiB,YAAY;MACZH;IACF,CAAC,CAAC;IAEF,IAAI3B,MAAM,CAACiC,UAAU,CAAC,EAAE;MACtBgB,UAAU,GAAGtC,iBAAiB,CAAC;QAAEa,KAAK;QAAEU,MAAM;QAAEe;MAAW,CAAC,CAAC;IAC/D;EACF,CAAC,MAAM,IAAIrB,aAAa,EAAE;IACxBqB,UAAU,GAAGrC,kBAAkB,CAAC;MAC9BkB,YAAY;MACZF;IACF,CAAC,CAAC;EACJ;EAEA,OAAOqB,UAAU;AACnB,CAAC","ignoreList":[]}
|
|
@@ -33,7 +33,7 @@ export const invisibleSpace: "";
|
|
|
33
33
|
export function isRequestingLocaleSupport(props: object): boolean;
|
|
34
34
|
export function isRequestingNumberMask(props: object): boolean;
|
|
35
35
|
export function correctNumberValue({ localValue, props, locale, maskParams, }: object): string;
|
|
36
|
-
export function correctCaretPosition(element: Element,
|
|
36
|
+
export function correctCaretPosition(element: Element, maskParamsRef: any, props: any): void;
|
|
37
37
|
export function handlePercentMask({ props, locale, maskParams }: object): any;
|
|
38
38
|
export function handleCurrencyMask({ mask_options, currency_mask }: object): any;
|
|
39
39
|
export function handleNumberMask({ mask_options, number_mask }: object): any;
|
|
@@ -85,9 +85,10 @@ export const correctNumberValue = _ref3 => {
|
|
|
85
85
|
}
|
|
86
86
|
return value;
|
|
87
87
|
};
|
|
88
|
-
export const correctCaretPosition = (element,
|
|
88
|
+
export const correctCaretPosition = (element, maskParamsRef, props) => {
|
|
89
89
|
const correction = () => {
|
|
90
90
|
try {
|
|
91
|
+
const maskParams = maskParamsRef === null || maskParamsRef === void 0 ? void 0 : maskParamsRef.current;
|
|
91
92
|
const suffix = maskParams === null || maskParams === void 0 ? void 0 : maskParams.suffix;
|
|
92
93
|
const prefix = maskParams === null || maskParams === void 0 ? void 0 : maskParams.prefix;
|
|
93
94
|
const start = element.selectionStart;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputMaskedUtils.js","names":["format","getDecimalSeparator","getThousandsSeparator","warn","IS_IOS","safeSetSelection","enableLocaleSupportWhen","enableNumberMaskWhen","invisibleSpace","isRequestingLocaleSupport","props","Object","entries","some","_ref","k","v","includes","isRequestingNumberMask","_ref2","correctNumberValue","_ref3","localValue","locale","maskParams","value","undefined","String","isNaN","parseFloat","decimalPos","indexOf","integerLimit","limit","integers","split","isNegative","length","decimals","slice","shouldHaveDecimals","allowDecimal","decimalLimit","number_format","options","_objectSpread","decimalSymbol","replace","localNumberValue","numberValue","valueHasDecimal","endsWithDecimal","endsWith","endsWithZeroAndDecimal","startsWith","test","correctCaretPosition","element","correction","suffix","prefix","start","selectionStart","end","selectionEnd","suffixStart","suffixEnd","pos","placeholderChar","prefixStart","prefixEnd","char","mask","chars","l","i","RegExp","n","_mask$test","call","e","window","requestAnimationFrame","handlePercentMask","_ref4","_String","_String$match","percent","match","handleCurrencyMask","_ref5","mask_options","currency_mask","givenParams","paramsWithDefaults","showMask","currency","handleNumberMask","_ref6","number_mask","getSoftKeyboardAttributes","instanceOf","allowNegative","inputMode","handleThousandsSeparator","handleDecimalSeparator","fromJSON","str","fallback","arguments","JSON","parse"],"sources":["../../../../src/components/input-masked/InputMaskedUtils.js"],"sourcesContent":["/**\n * Web InputMasked Component\n *\n */\n\nimport {\n format,\n getDecimalSeparator,\n getThousandsSeparator,\n} from '../number-format/NumberUtils'\nimport { warn } from '../../shared/component-helper'\nimport { IS_IOS } from '../../shared/helpers'\nimport { safeSetSelection } from './text-mask/createTextMaskInputElement'\n\nconst enableLocaleSupportWhen = ['as_number', 'as_percent', 'as_currency']\nconst enableNumberMaskWhen = [\n 'as_number',\n 'as_percent',\n 'as_currency',\n 'number_mask',\n 'currency_mask',\n]\n\nexport const invisibleSpace = '\\u200B'\n\n/**\n * Will return true if a prop needs Locale support\n *\n * @param {object} props object with given component props\n * @returns boolean\n */\nexport const isRequestingLocaleSupport = (props) => {\n return Object.entries(props).some(\n ([k, v]) => v && enableLocaleSupportWhen.includes(k)\n )\n}\n\n/**\n * Will return true if a prop will enable the internal NumberMask\n *\n * @param {object} props object with given component props\n * @returns boolean\n */\nexport const isRequestingNumberMask = (props) => {\n return Object.entries(props).some(\n ([k, v]) => v && enableNumberMaskWhen.includes(k)\n )\n}\n\n/**\n * Probably the most complex part of this component\n * It will modify a given value based on certain criteria's\n *\n * @param {object} param0 object with properties\n * @property {string} localValue optional – if given, it will uses its ending to determine of what to return\n * @property {number|string} value component property value\n * @property {object} context Eufemia Context\n * @property {string} locale Eufemia locale (either from component or context)\n * @property {object} maskParams predefined mask parameters\n * @returns string Value\n */\nexport const correctNumberValue = ({\n localValue = null,\n props,\n locale,\n maskParams,\n}) => {\n let value =\n props.value === null\n ? null\n : props.value === undefined\n ? undefined\n : String(props.value)\n\n if (isNaN(parseFloat(value))) {\n return value\n }\n\n const decimalPos = value.indexOf('.')\n\n if (\n maskParams.integerLimit &&\n typeof maskParams.integerLimit === 'number'\n ) {\n const limit = maskParams.integerLimit\n const integers = value.split('.')[0]\n const isNegative = parseFloat(integers) < 0\n if (integers.length - (isNegative ? 1 : 0) > limit) {\n const decimals = decimalPos > 0 ? value.slice(decimalPos) : ''\n value = integers.slice(0, limit + (isNegative ? 1 : 0)) + decimals\n }\n }\n\n const shouldHaveDecimals =\n maskParams.allowDecimal ||\n (maskParams.decimalLimit > 0 && maskParams.allowDecimal !== false)\n\n if (!shouldHaveDecimals) {\n if (decimalPos > -1) {\n value = value.slice(0, decimalPos)\n }\n }\n\n /**\n * This only runs IF \"number_format\" is set – we do not use it else\n */\n if (props.number_format) {\n const options = {\n locale,\n decimals: 0,\n ...props.number_format,\n }\n if (shouldHaveDecimals) {\n options.decimals = maskParams.decimalLimit\n }\n value = format(value, options)\n }\n\n const decimalSymbol = maskParams.decimalSymbol\n value = value.replace('.', decimalSymbol)\n\n if (localValue !== null) {\n const localNumberValue = localValue.replace(/[^\\d,.-]/g, '')\n const numberValue = value.replace(/[^\\d,.-]/g, '')\n const valueHasDecimal = numberValue.includes(decimalSymbol)\n\n if (!valueHasDecimal) {\n const endsWithDecimal = localNumberValue.endsWith(decimalSymbol)\n const endsWithZeroAndDecimal = localNumberValue.endsWith(\n `${decimalSymbol}0`\n )\n\n if (endsWithDecimal) {\n value = `${value}${decimalSymbol}`\n } else if (\n endsWithZeroAndDecimal &&\n !numberValue.endsWith(`${decimalSymbol}0`)\n ) {\n /**\n * When the users has 20,02, then hits \"backspace\",\n * the returned {numberValue} in the onChange event would then be \"20\",\n * but we want it to be 20,0\n */\n value = `${value}${decimalSymbol}0`\n }\n }\n\n /**\n * If the user removes a leading digit and we have left a leading zero.\n *\n * The users enters these steps:\n * Step 1. 1012\n * Step 2. 012 -> user removes 1, now use \"localValue\"\n * Step 3. 2012\n *\n * If a dev listens on_change and sends the number value back in,\n * for this, we also ensure that \"numberValue\" and \"localNumberValue\" is the same.\n */\n if (\n localNumberValue !== '0' &&\n localNumberValue.startsWith('0') &&\n parseFloat(numberValue.replace(decimalSymbol, '.')) ===\n parseFloat(localNumberValue.replace(decimalSymbol, '.'))\n ) {\n value = localValue\n }\n\n /**\n * While typing;\n * If the local value is - or -0 we use it.\n * Also, because of invisible whitespace we remove everything else\n */\n if (/^(-|-0)$/.test(localValue.replace(/[^\\d-0]/g, ''))) {\n value = localValue\n } else if (localNumberValue === '' && numberValue === '0') {\n value = ''\n }\n }\n\n return value\n}\n\n/**\n * This is a helper for setting the cursor position,\n * when it is on a not allowed position\n *\n * @param {Element} element Input Element\n * @param {Object} maskParams Mask parameters, containing eventually suffix or prefix\n */\nexport const correctCaretPosition = (element, maskParams, props) => {\n const correction = () => {\n try {\n const suffix = maskParams?.suffix\n const prefix = maskParams?.prefix\n\n const start = element.selectionStart\n const end = element.selectionEnd\n\n if (start !== end) {\n return // stop here\n }\n\n if (suffix || prefix) {\n const suffixStart = element.value.indexOf(suffix)\n const suffixEnd = suffixStart + suffix?.length\n let pos = undefined\n\n if (start >= suffixStart && start <= suffixEnd) {\n pos = suffixStart\n\n // If there is a placeholder,\n // and the user clicks after the suffix\n // we want the position to be \"before\" the placeholderChar\n if (\n maskParams.placeholderChar !== invisibleSpace &&\n element.value.length - 1 === String(suffix + prefix).length\n ) {\n pos = pos - 1\n }\n } else {\n const prefixStart = element.value.indexOf(prefix)\n const prefixEnd = prefixStart + prefix?.length || 0\n\n if (start >= prefixStart && start <= prefixEnd) {\n pos = prefixEnd\n }\n }\n\n const char = element.value.slice(pos - 1, pos)\n if (char === invisibleSpace) {\n pos = suffixStart - 1\n }\n\n if (!isNaN(parseFloat(pos))) {\n safeSetSelection(element, pos)\n }\n } else if (props?.mask && element.value.length === end) {\n const chars = element.value.split('')\n\n for (let l = chars.length, i = l - 1; i >= 0; i--) {\n const char = chars[i]\n const mask = props.mask[i]\n if (\n char &&\n char !== invisibleSpace &&\n mask instanceof RegExp &&\n mask.test(char)\n ) {\n for (let n = i + 1; n < l; n++) {\n const mask = props.mask[n]\n if (mask?.test?.(char)) {\n safeSetSelection(element, n)\n break\n }\n }\n\n break\n }\n }\n }\n } catch (e) {\n warn(e)\n }\n }\n\n if (typeof window !== 'undefined') {\n window.requestAnimationFrame(correction)\n }\n}\n\n/**\n * Manipulate needed mask for handle: percent\n *\n * @param {object} param0 object with properties\n * @property {object} props Component property\n * @property {string} locale Eufemia locale (either from component or context)\n * @property {object} maskParams predefined mask parameters\n * @returns object maskParams\n */\nexport const handlePercentMask = ({ props, locale, maskParams }) => {\n const value = format(props.value, { locale, percent: true })\n maskParams.suffix = String(value)?.match(/((\\s|)%)$/g, '$1')?.[0] || ' %'\n\n return maskParams\n}\n\n/**\n * Return needed mask for handle: currency\n *\n * @param {object} param0 object with properties\n * @property {object} context Eufemia context\n * @property {object} mask_options Component property for change the mask parameters\n * @property {object} currency_mask Component property for change the currency parameters\n * @returns object maskParams\n */\nexport const handleCurrencyMask = ({ mask_options, currency_mask }) => {\n const givenParams = {\n ...mask_options,\n ...currency_mask,\n }\n const paramsWithDefaults = {\n showMask: true,\n placeholderChar: null,\n allowDecimal: true,\n decimalLimit: 2,\n decimalSymbol: ',',\n ...givenParams,\n }\n\n const suffix =\n typeof currency_mask === 'string'\n ? currency_mask\n : typeof givenParams.currency === 'string'\n ? givenParams.currency\n : 'kr'\n paramsWithDefaults.suffix = ` ${suffix}`\n\n if (\n typeof givenParams?.allowDecimal === 'undefined' &&\n typeof givenParams?.decimalLimit === 'number'\n ) {\n paramsWithDefaults.allowDecimal = givenParams.decimalLimit > 0\n }\n\n return paramsWithDefaults\n}\n\n/**\n * Return needed mask for handle: number\n *\n * @param {object} param0 object with properties\n * @property {object} context Eufemia context\n * @property {object} mask_options Component property for change the mask parameters\n * @property {object} number_mask Component property for change the number parameters\n * @returns object maskParams\n */\nexport const handleNumberMask = ({ mask_options, number_mask }) => {\n const maskParams = {\n decimalSymbol: ',',\n ...mask_options,\n ...number_mask,\n }\n\n if (typeof maskParams.allowDecimal === 'undefined') {\n maskParams.allowDecimal = maskParams.decimalLimit > 0\n }\n\n return maskParams\n}\n\n/**\n * Returns the type of what inputMode or type attribute should be used\n *\n * @param {function} mask mask function\n * @returns undefined|decimal|numeric\n */\nexport function getSoftKeyboardAttributes(mask) {\n if (mask?.instanceOf !== 'createNumberMask') {\n return undefined\n }\n\n const maskParams = mask?.maskParams\n\n // because of the missing minus key, we still have to use text on iOS\n if (IS_IOS && maskParams?.allowNegative !== false) {\n return undefined\n }\n\n return {\n inputMode:\n maskParams.allowDecimal && maskParams.decimalLimit !== 0\n ? 'decimal'\n : 'numeric',\n }\n}\n\n/**\n * Returns the thousands separator character\n *\n * @param {string} locale Component or context locale\n * @returns string\n */\nexport function handleThousandsSeparator(locale) {\n return getThousandsSeparator(locale).replace(' ', ' ') // replace non-breaking space with a regular space\n}\n\n/**\n * Returns the decimal separator character\n *\n * @param {string} locale Component or context locale\n * @returns string\n */\nexport function handleDecimalSeparator(locale) {\n let decimalSymbol = getDecimalSeparator(locale)\n\n return decimalSymbol\n}\n\n/**\n * Will take a JSON and return it parsed\n *\n * @param {string} str\n * @param {*} fallback optional fallback\n * @returns parsed json\n */\nexport function fromJSON(str, fallback = null) {\n if (typeof str === 'string' && str[0] === '{') {\n return JSON.parse(str)\n }\n\n return str || fallback\n}\n"],"mappings":";;;;;AAKA,SACEA,MAAM,EACNC,mBAAmB,EACnBC,qBAAqB,QAChB,8BAA8B;AACrC,SAASC,IAAI,QAAQ,+BAA+B;AACpD,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SAASC,gBAAgB,QAAQ,wCAAwC;AAEzE,MAAMC,uBAAuB,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,aAAa,CAAC;AAC1E,MAAMC,oBAAoB,GAAG,CAC3B,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACb,eAAe,CAChB;AAED,OAAO,MAAMC,cAAc,GAAG,QAAQ;AAQtC,OAAO,MAAMC,yBAAyB,GAAIC,KAAK,IAAK;EAClD,OAAOC,MAAM,CAACC,OAAO,CAACF,KAAK,CAAC,CAACG,IAAI,CAC/BC,IAAA;IAAA,IAAC,CAACC,CAAC,EAAEC,CAAC,CAAC,GAAAF,IAAA;IAAA,OAAKE,CAAC,IAAIV,uBAAuB,CAACW,QAAQ,CAACF,CAAC,CAAC;EAAA,CACtD,CAAC;AACH,CAAC;AAQD,OAAO,MAAMG,sBAAsB,GAAIR,KAAK,IAAK;EAC/C,OAAOC,MAAM,CAACC,OAAO,CAACF,KAAK,CAAC,CAACG,IAAI,CAC/BM,KAAA;IAAA,IAAC,CAACJ,CAAC,EAAEC,CAAC,CAAC,GAAAG,KAAA;IAAA,OAAKH,CAAC,IAAIT,oBAAoB,CAACU,QAAQ,CAACF,CAAC,CAAC;EAAA,CACnD,CAAC;AACH,CAAC;AAcD,OAAO,MAAMK,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C,QAAQ;AACxB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"InputMaskedUtils.js","names":["format","getDecimalSeparator","getThousandsSeparator","warn","IS_IOS","safeSetSelection","enableLocaleSupportWhen","enableNumberMaskWhen","invisibleSpace","isRequestingLocaleSupport","props","Object","entries","some","_ref","k","v","includes","isRequestingNumberMask","_ref2","correctNumberValue","_ref3","localValue","locale","maskParams","value","undefined","String","isNaN","parseFloat","decimalPos","indexOf","integerLimit","limit","integers","split","isNegative","length","decimals","slice","shouldHaveDecimals","allowDecimal","decimalLimit","number_format","options","_objectSpread","decimalSymbol","replace","localNumberValue","numberValue","valueHasDecimal","endsWithDecimal","endsWith","endsWithZeroAndDecimal","startsWith","test","correctCaretPosition","element","maskParamsRef","correction","current","suffix","prefix","start","selectionStart","end","selectionEnd","suffixStart","suffixEnd","pos","placeholderChar","prefixStart","prefixEnd","char","mask","chars","l","i","RegExp","n","_mask$test","call","e","window","requestAnimationFrame","handlePercentMask","_ref4","_String","_String$match","percent","match","handleCurrencyMask","_ref5","mask_options","currency_mask","givenParams","paramsWithDefaults","showMask","currency","handleNumberMask","_ref6","number_mask","getSoftKeyboardAttributes","instanceOf","allowNegative","inputMode","handleThousandsSeparator","handleDecimalSeparator","fromJSON","str","fallback","arguments","JSON","parse"],"sources":["../../../../src/components/input-masked/InputMaskedUtils.js"],"sourcesContent":["/**\n * Web InputMasked Component\n *\n */\n\nimport {\n format,\n getDecimalSeparator,\n getThousandsSeparator,\n} from '../number-format/NumberUtils'\nimport { warn } from '../../shared/component-helper'\nimport { IS_IOS } from '../../shared/helpers'\nimport { safeSetSelection } from './text-mask/createTextMaskInputElement'\n\nconst enableLocaleSupportWhen = ['as_number', 'as_percent', 'as_currency']\nconst enableNumberMaskWhen = [\n 'as_number',\n 'as_percent',\n 'as_currency',\n 'number_mask',\n 'currency_mask',\n]\n\nexport const invisibleSpace = '\\u200B'\n\n/**\n * Will return true if a prop needs Locale support\n *\n * @param {object} props object with given component props\n * @returns boolean\n */\nexport const isRequestingLocaleSupport = (props) => {\n return Object.entries(props).some(\n ([k, v]) => v && enableLocaleSupportWhen.includes(k)\n )\n}\n\n/**\n * Will return true if a prop will enable the internal NumberMask\n *\n * @param {object} props object with given component props\n * @returns boolean\n */\nexport const isRequestingNumberMask = (props) => {\n return Object.entries(props).some(\n ([k, v]) => v && enableNumberMaskWhen.includes(k)\n )\n}\n\n/**\n * Probably the most complex part of this component\n * It will modify a given value based on certain criteria's\n *\n * @param {object} param0 object with properties\n * @property {string} localValue optional – if given, it will uses its ending to determine of what to return\n * @property {number|string} value component property value\n * @property {object} context Eufemia Context\n * @property {string} locale Eufemia locale (either from component or context)\n * @property {object} maskParams predefined mask parameters\n * @returns string Value\n */\nexport const correctNumberValue = ({\n localValue = null,\n props,\n locale,\n maskParams,\n}) => {\n let value =\n props.value === null\n ? null\n : props.value === undefined\n ? undefined\n : String(props.value)\n\n if (isNaN(parseFloat(value))) {\n return value\n }\n\n const decimalPos = value.indexOf('.')\n\n if (\n maskParams.integerLimit &&\n typeof maskParams.integerLimit === 'number'\n ) {\n const limit = maskParams.integerLimit\n const integers = value.split('.')[0]\n const isNegative = parseFloat(integers) < 0\n if (integers.length - (isNegative ? 1 : 0) > limit) {\n const decimals = decimalPos > 0 ? value.slice(decimalPos) : ''\n value = integers.slice(0, limit + (isNegative ? 1 : 0)) + decimals\n }\n }\n\n const shouldHaveDecimals =\n maskParams.allowDecimal ||\n (maskParams.decimalLimit > 0 && maskParams.allowDecimal !== false)\n\n if (!shouldHaveDecimals) {\n if (decimalPos > -1) {\n value = value.slice(0, decimalPos)\n }\n }\n\n /**\n * This only runs IF \"number_format\" is set – we do not use it else\n */\n if (props.number_format) {\n const options = {\n locale,\n decimals: 0,\n ...props.number_format,\n }\n if (shouldHaveDecimals) {\n options.decimals = maskParams.decimalLimit\n }\n value = format(value, options)\n }\n\n const decimalSymbol = maskParams.decimalSymbol\n value = value.replace('.', decimalSymbol)\n\n if (localValue !== null) {\n const localNumberValue = localValue.replace(/[^\\d,.-]/g, '')\n const numberValue = value.replace(/[^\\d,.-]/g, '')\n const valueHasDecimal = numberValue.includes(decimalSymbol)\n\n if (!valueHasDecimal) {\n const endsWithDecimal = localNumberValue.endsWith(decimalSymbol)\n const endsWithZeroAndDecimal = localNumberValue.endsWith(\n `${decimalSymbol}0`\n )\n\n if (endsWithDecimal) {\n value = `${value}${decimalSymbol}`\n } else if (\n endsWithZeroAndDecimal &&\n !numberValue.endsWith(`${decimalSymbol}0`)\n ) {\n /**\n * When the users has 20,02, then hits \"backspace\",\n * the returned {numberValue} in the onChange event would then be \"20\",\n * but we want it to be 20,0\n */\n value = `${value}${decimalSymbol}0`\n }\n }\n\n /**\n * If the user removes a leading digit and we have left a leading zero.\n *\n * The users enters these steps:\n * Step 1. 1012\n * Step 2. 012 -> user removes 1, now use \"localValue\"\n * Step 3. 2012\n *\n * If a dev listens on_change and sends the number value back in,\n * for this, we also ensure that \"numberValue\" and \"localNumberValue\" is the same.\n */\n if (\n localNumberValue !== '0' &&\n localNumberValue.startsWith('0') &&\n parseFloat(numberValue.replace(decimalSymbol, '.')) ===\n parseFloat(localNumberValue.replace(decimalSymbol, '.'))\n ) {\n value = localValue\n }\n\n /**\n * While typing;\n * If the local value is - or -0 we use it.\n * Also, because of invisible whitespace we remove everything else\n */\n if (/^(-|-0)$/.test(localValue.replace(/[^\\d-0]/g, ''))) {\n value = localValue\n } else if (localNumberValue === '' && numberValue === '0') {\n value = ''\n }\n }\n\n return value\n}\n\n/**\n * This is a helper for setting the cursor position,\n * when it is on a not allowed position\n *\n * @param {Element} element Input Element\n * @param {Object} maskParams Mask parameters, containing eventually suffix or prefix\n */\nexport const correctCaretPosition = (element, maskParamsRef, props) => {\n const correction = () => {\n try {\n const maskParams = maskParamsRef?.current\n\n const suffix = maskParams?.suffix\n const prefix = maskParams?.prefix\n\n const start = element.selectionStart\n const end = element.selectionEnd\n\n if (start !== end) {\n return // stop here\n }\n\n if (suffix || prefix) {\n const suffixStart = element.value.indexOf(suffix)\n const suffixEnd = suffixStart + suffix?.length\n let pos = undefined\n\n if (start >= suffixStart && start <= suffixEnd) {\n pos = suffixStart\n\n // If there is a placeholder,\n // and the user clicks after the suffix\n // we want the position to be \"before\" the placeholderChar\n if (\n maskParams.placeholderChar !== invisibleSpace &&\n element.value.length - 1 === String(suffix + prefix).length\n ) {\n pos = pos - 1\n }\n } else {\n const prefixStart = element.value.indexOf(prefix)\n const prefixEnd = prefixStart + prefix?.length || 0\n\n if (start >= prefixStart && start <= prefixEnd) {\n pos = prefixEnd\n }\n }\n\n const char = element.value.slice(pos - 1, pos)\n if (char === invisibleSpace) {\n pos = suffixStart - 1\n }\n\n if (!isNaN(parseFloat(pos))) {\n safeSetSelection(element, pos)\n }\n } else if (props?.mask && element.value.length === end) {\n const chars = element.value.split('')\n\n for (let l = chars.length, i = l - 1; i >= 0; i--) {\n const char = chars[i]\n const mask = props.mask[i]\n if (\n char &&\n char !== invisibleSpace &&\n mask instanceof RegExp &&\n mask.test(char)\n ) {\n for (let n = i + 1; n < l; n++) {\n const mask = props.mask[n]\n if (mask?.test?.(char)) {\n safeSetSelection(element, n)\n break\n }\n }\n\n break\n }\n }\n }\n } catch (e) {\n warn(e)\n }\n }\n\n if (typeof window !== 'undefined') {\n window.requestAnimationFrame(correction)\n }\n}\n\n/**\n * Manipulate needed mask for handle: percent\n *\n * @param {object} param0 object with properties\n * @property {object} props Component property\n * @property {string} locale Eufemia locale (either from component or context)\n * @property {object} maskParams predefined mask parameters\n * @returns object maskParams\n */\nexport const handlePercentMask = ({ props, locale, maskParams }) => {\n const value = format(props.value, { locale, percent: true })\n maskParams.suffix = String(value)?.match(/((\\s|)%)$/g, '$1')?.[0] || ' %'\n\n return maskParams\n}\n\n/**\n * Return needed mask for handle: currency\n *\n * @param {object} param0 object with properties\n * @property {object} context Eufemia context\n * @property {object} mask_options Component property for change the mask parameters\n * @property {object} currency_mask Component property for change the currency parameters\n * @returns object maskParams\n */\nexport const handleCurrencyMask = ({ mask_options, currency_mask }) => {\n const givenParams = {\n ...mask_options,\n ...currency_mask,\n }\n const paramsWithDefaults = {\n showMask: true,\n placeholderChar: null,\n allowDecimal: true,\n decimalLimit: 2,\n decimalSymbol: ',',\n ...givenParams,\n }\n\n const suffix =\n typeof currency_mask === 'string'\n ? currency_mask\n : typeof givenParams.currency === 'string'\n ? givenParams.currency\n : 'kr'\n paramsWithDefaults.suffix = ` ${suffix}`\n\n if (\n typeof givenParams?.allowDecimal === 'undefined' &&\n typeof givenParams?.decimalLimit === 'number'\n ) {\n paramsWithDefaults.allowDecimal = givenParams.decimalLimit > 0\n }\n\n return paramsWithDefaults\n}\n\n/**\n * Return needed mask for handle: number\n *\n * @param {object} param0 object with properties\n * @property {object} context Eufemia context\n * @property {object} mask_options Component property for change the mask parameters\n * @property {object} number_mask Component property for change the number parameters\n * @returns object maskParams\n */\nexport const handleNumberMask = ({ mask_options, number_mask }) => {\n const maskParams = {\n decimalSymbol: ',',\n ...mask_options,\n ...number_mask,\n }\n\n if (typeof maskParams.allowDecimal === 'undefined') {\n maskParams.allowDecimal = maskParams.decimalLimit > 0\n }\n\n return maskParams\n}\n\n/**\n * Returns the type of what inputMode or type attribute should be used\n *\n * @param {function} mask mask function\n * @returns undefined|decimal|numeric\n */\nexport function getSoftKeyboardAttributes(mask) {\n if (mask?.instanceOf !== 'createNumberMask') {\n return undefined\n }\n\n const maskParams = mask?.maskParams\n\n // because of the missing minus key, we still have to use text on iOS\n if (IS_IOS && maskParams?.allowNegative !== false) {\n return undefined\n }\n\n return {\n inputMode:\n maskParams.allowDecimal && maskParams.decimalLimit !== 0\n ? 'decimal'\n : 'numeric',\n }\n}\n\n/**\n * Returns the thousands separator character\n *\n * @param {string} locale Component or context locale\n * @returns string\n */\nexport function handleThousandsSeparator(locale) {\n return getThousandsSeparator(locale).replace(' ', ' ') // replace non-breaking space with a regular space\n}\n\n/**\n * Returns the decimal separator character\n *\n * @param {string} locale Component or context locale\n * @returns string\n */\nexport function handleDecimalSeparator(locale) {\n let decimalSymbol = getDecimalSeparator(locale)\n\n return decimalSymbol\n}\n\n/**\n * Will take a JSON and return it parsed\n *\n * @param {string} str\n * @param {*} fallback optional fallback\n * @returns parsed json\n */\nexport function fromJSON(str, fallback = null) {\n if (typeof str === 'string' && str[0] === '{') {\n return JSON.parse(str)\n }\n\n return str || fallback\n}\n"],"mappings":";;;;;AAKA,SACEA,MAAM,EACNC,mBAAmB,EACnBC,qBAAqB,QAChB,8BAA8B;AACrC,SAASC,IAAI,QAAQ,+BAA+B;AACpD,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SAASC,gBAAgB,QAAQ,wCAAwC;AAEzE,MAAMC,uBAAuB,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,aAAa,CAAC;AAC1E,MAAMC,oBAAoB,GAAG,CAC3B,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACb,eAAe,CAChB;AAED,OAAO,MAAMC,cAAc,GAAG,QAAQ;AAQtC,OAAO,MAAMC,yBAAyB,GAAIC,KAAK,IAAK;EAClD,OAAOC,MAAM,CAACC,OAAO,CAACF,KAAK,CAAC,CAACG,IAAI,CAC/BC,IAAA;IAAA,IAAC,CAACC,CAAC,EAAEC,CAAC,CAAC,GAAAF,IAAA;IAAA,OAAKE,CAAC,IAAIV,uBAAuB,CAACW,QAAQ,CAACF,CAAC,CAAC;EAAA,CACtD,CAAC;AACH,CAAC;AAQD,OAAO,MAAMG,sBAAsB,GAAIR,KAAK,IAAK;EAC/C,OAAOC,MAAM,CAACC,OAAO,CAACF,KAAK,CAAC,CAACG,IAAI,CAC/BM,KAAA;IAAA,IAAC,CAACJ,CAAC,EAAEC,CAAC,CAAC,GAAAG,KAAA;IAAA,OAAKH,CAAC,IAAIT,oBAAoB,CAACU,QAAQ,CAACF,CAAC,CAAC;EAAA,CACnD,CAAC;AACH,CAAC;AAcD,OAAO,MAAMK,kBAAkB,GAAGC,KAAA,IAK5B;EAAA,IAL6B;IACjCC,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,OAAOA,GAAG,IAAIC,QAAQ;AACxB","ignoreList":[]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { PropertiesTableProps } from '../../shared/types';
|
|
2
2
|
export declare const ModalProperties: PropertiesTableProps;
|
|
3
|
+
export declare const ModalPropertiesWithSnakeCase: PropertiesTableProps;
|
|
3
4
|
export declare const ModalEvents: PropertiesTableProps;
|
|
5
|
+
export declare const ModalEventsWithSnakeCase: PropertiesTableProps;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
2
|
+
import { toSnakeCase } from '../../shared/component-helper';
|
|
3
|
+
const transformPropertyNamesWithSnakeCase = properties => {
|
|
4
|
+
return Object.fromEntries(Object.entries(properties).map(_ref => {
|
|
5
|
+
let [key, value] = _ref;
|
|
6
|
+
return [key !== key.toLowerCase() ? `${key} / ${toSnakeCase(key)}` : key, value];
|
|
7
|
+
}));
|
|
8
|
+
};
|
|
1
9
|
export const ModalProperties = {
|
|
2
10
|
id: {
|
|
3
11
|
doc: 'The id used internal for the trigger button and Modal component.',
|
|
@@ -165,6 +173,7 @@ export const ModalProperties = {
|
|
|
165
173
|
status: 'optional'
|
|
166
174
|
}
|
|
167
175
|
};
|
|
176
|
+
export const ModalPropertiesWithSnakeCase = transformPropertyNamesWithSnakeCase(ModalProperties);
|
|
168
177
|
export const ModalEvents = {
|
|
169
178
|
onOpen: {
|
|
170
179
|
doc: 'This event gets triggered once the modal shows up. Returns the modal id: `{ id }`.',
|
|
@@ -182,4 +191,5 @@ export const ModalEvents = {
|
|
|
182
191
|
status: 'optional'
|
|
183
192
|
}
|
|
184
193
|
};
|
|
194
|
+
export const ModalEventsWithSnakeCase = transformPropertyNamesWithSnakeCase(ModalEvents);
|
|
185
195
|
//# sourceMappingURL=ModalDocs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalDocs.js","names":["ModalProperties","id","doc","type","status","rootId","contentId","labelledBy","children","fullscreen","openState","openDelay","disabled","noAnimation","noAnimationOnMobile","animationDuration","preventClose","preventOverlayClose","openModal","closeModal","focusSelector","overlayClass","contentClass","omitTriggerButton","trigger","triggerAttributes","dialogTitle","directDomReturn","bypassInvalidationSelectors","scrollRef","contentRef","spacing","closeTitle","hideCloseButton","class","className","ModalEvents","onOpen","onClose","onClosePrevent"],"sources":["../../../../src/components/modal/ModalDocs.ts"],"sourcesContent":["import { PropertiesTableProps } from '../../shared/types'\n\nexport const ModalProperties: PropertiesTableProps = {\n id: {\n doc: 'The id used internal for the trigger button and Modal component.',\n type: 'string',\n status: 'optional',\n },\n rootId: {\n doc: 'The id used internal in the modal root element. Defaults to `root`, so the element id will be `dnb-modal-root`.',\n type: 'string',\n status: 'optional',\n },\n contentId: {\n doc: 'Defines an unique identifier to a modal. Use it in case you have to refer in some way to the modal content.',\n type: 'string',\n status: 'optional',\n },\n labelledBy: {\n doc: 'The ID of the trigger component, describing the modal content. Defaults to the internal `trigger`, so make sure you define the `title` in `triggerAttributes`.',\n type: 'string',\n status: 'optional',\n },\n children: {\n doc: 'the content which will appear when triggering open the modal. If a function is given, you get a close method `() => ({ close })` in the arguments.',\n type: ['React.ReactNode', 'function'],\n status: 'optional',\n },\n fullscreen: {\n doc: 'If set to `true` then the modal content will be shown as fullscreen, without showing the original content behind. Can be set to `false` to omit the auto fullscreen. Defaults to `auto`.',\n type: 'boolean',\n status: 'optional',\n },\n openState: {\n doc: 'use this property to control the open/close state by setting either: `opened` / `closed` or `true` / `false`.',\n type: ['boolean', 'opened', 'closed'],\n status: 'optional',\n },\n openDelay: {\n doc: 'forces the modal to delay the opening. The delay is given in `ms`.',\n type: ['number', 'string'],\n status: 'optional',\n },\n disabled: {\n doc: 'Will disable the trigger button.',\n type: 'boolean',\n status: 'optional',\n },\n noAnimation: {\n doc: 'if set to `true`, no open/close animation will be shown. Defaults to `false`.',\n type: 'boolean',\n status: 'optional',\n },\n noAnimationOnMobile: {\n doc: 'same as `noAnimation`, but gets triggered only if the viewport width is less than `40em`. Defaults to `false`.',\n type: 'boolean',\n status: 'optional',\n },\n animationDuration: {\n doc: 'Duration of animation open/close in ms. Defaults to 300ms.',\n type: ['number', 'string'],\n status: 'optional',\n },\n preventClose: {\n doc: \"if set to `true` (boolean or string), then the user can't close the modal.\",\n type: 'boolean',\n status: 'optional',\n },\n preventOverlayClose: {\n doc: 'Disable clicking the background overlay to close the modal. PS! Pressing `esc` key will still close the modal.',\n type: 'boolean',\n status: 'optional',\n },\n openModal: {\n doc: 'set a function to call the callback function, once the modal should open: `openModal={(open) => open()}`.',\n type: 'function',\n status: 'optional',\n },\n closeModal: {\n doc: 'set a function to call the callback function, once the modal should close: `closeModal={(close) => close()}`.',\n type: 'function',\n status: 'optional',\n },\n focusSelector: {\n doc: 'The Modal handles the first focus – automatically. However, you can define a custom focus selector the will be used instead `focusSelector=\".css-selector\"`.',\n type: 'string',\n status: 'optional',\n },\n overlayClass: {\n doc: 'give the page overlay a custom class name (maps to `dnb-modal__overlay`).',\n type: 'string',\n status: 'optional',\n },\n contentClass: {\n doc: 'give the content wrapper a custom class name (maps to `dnb-modal__content`).',\n type: 'string',\n status: 'optional',\n },\n omitTriggerButton: {\n doc: 'omits default showing trigger button.',\n type: 'boolean',\n status: 'optional',\n },\n trigger: {\n doc: 'provide a custom trigger component. Like `trigger={<Anchor href=\"/\" />}`. It will set the focus on it when the modal gets closed.',\n type: ['React.ReactNode', 'function'],\n status: 'optional',\n },\n triggerAttributes: {\n doc: 'send along with custom HTML attributes or properties to the trigger button.',\n type: 'Various',\n status: 'optional',\n },\n dialogTitle: {\n doc: 'The aria label of the dialog when no labelledBy and no title is given. Defaults to `Vindu`.',\n type: 'string',\n status: 'optional',\n },\n directDomReturn: {\n doc: 'If true, the modal will not open in a new DOM but directly in current DOM. Defaults to `false`. Be aware of the side effects of setting this property to `true`.',\n type: 'boolean',\n status: 'optional',\n },\n bypassInvalidationSelectors: {\n doc: \"Define an array with HTML class selectors (`['.element-selector']`) which should not get invalidated when the modal opens/closes. Use this in order to let some parts of your site still be accessible by screen readers.\",\n type: 'boolean',\n status: 'optional',\n },\n scrollRef: {\n doc: 'To get the scroll Element, pass in your own React ref.',\n type: 'React.RefObject',\n status: 'optional',\n },\n contentRef: {\n doc: 'To get the inner content Element, pass in your own React ref.',\n type: 'React.RefObject',\n status: 'optional',\n },\n '[Space](/uilib/layout/space/properties)': {\n doc: 'Spacing properties like `top` or `bottom` are supported.',\n type: ['string', 'object'],\n status: 'optional',\n },\n spacing: {\n doc: 'if set to `false` then the modal content will be shown without any spacing. Defaults to `true`.',\n type: 'boolean',\n status: 'deprecated',\n },\n closeTitle: {\n doc: 'the title of the close button. Defaults to _Lukk_.',\n type: 'string',\n status: 'deprecated',\n },\n hideCloseButton: {\n doc: 'if true, the close button will not be shown.',\n type: 'boolean',\n status: 'deprecated',\n },\n class: {\n doc: 'give the inner content wrapper a class name (maps to `dnb-modal__content__inner`).',\n type: 'string',\n status: 'optional',\n },\n className: {\n doc: 'give the inner content wrapper a class name (maps to `dnb-modal__content__inner`).',\n type: 'string',\n status: 'optional',\n },\n}\n\nexport const ModalEvents: PropertiesTableProps = {\n onOpen: {\n doc: 'This event gets triggered once the modal shows up. Returns the modal id: `{ id }`.',\n type: 'function',\n status: 'optional',\n },\n onClose: {\n doc: 'This event gets triggered once the modal gets closed. Returns the modal id: `{ id, event, triggeredBy }`.',\n type: 'function',\n status: 'optional',\n },\n onClosePrevent: {\n doc: 'This event gets triggered once the user tries to close the modal, but `preventClose` is set to **true**. Returns a callback `close` you can call to trigger the close mechanism. More details below. Returns the modal id: `{ id, event, close: Method, triggeredBy }`.',\n type: 'function',\n status: 'optional',\n },\n}\n"],"mappings":"AAEA,OAAO,MAAMA,eAAqC,GAAG;EACnDC,EAAE,EAAE;IACFC,GAAG,EAAE,kEAAkE;IACvEC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDC,MAAM,EAAE;IACNH,GAAG,EAAE,iHAAiH;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,EAAE,UAAU;IAChBC,MAAM,EAAE;EACV;AACF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ModalDocs.js","names":["toSnakeCase","transformPropertyNamesWithSnakeCase","properties","Object","fromEntries","entries","map","_ref","key","value","toLowerCase","ModalProperties","id","doc","type","status","rootId","contentId","labelledBy","children","fullscreen","openState","openDelay","disabled","noAnimation","noAnimationOnMobile","animationDuration","preventClose","preventOverlayClose","openModal","closeModal","focusSelector","overlayClass","contentClass","omitTriggerButton","trigger","triggerAttributes","dialogTitle","directDomReturn","bypassInvalidationSelectors","scrollRef","contentRef","spacing","closeTitle","hideCloseButton","class","className","ModalPropertiesWithSnakeCase","ModalEvents","onOpen","onClose","onClosePrevent","ModalEventsWithSnakeCase"],"sources":["../../../../src/components/modal/ModalDocs.ts"],"sourcesContent":["import { PropertiesTableProps } from '../../shared/types'\nimport { toSnakeCase } from '../../shared/component-helper'\n\nconst transformPropertyNamesWithSnakeCase = (\n properties: PropertiesTableProps\n) => {\n return Object.fromEntries(\n Object.entries(properties).map(([key, value]) => [\n key !== key.toLowerCase() ? `${key} / ${toSnakeCase(key)}` : key,\n value,\n ])\n )\n}\n\nexport const ModalProperties: PropertiesTableProps = {\n id: {\n doc: 'The id used internal for the trigger button and Modal component.',\n type: 'string',\n status: 'optional',\n },\n rootId: {\n doc: 'The id used internal in the modal root element. Defaults to `root`, so the element id will be `dnb-modal-root`.',\n type: 'string',\n status: 'optional',\n },\n contentId: {\n doc: 'Defines an unique identifier to a modal. Use it in case you have to refer in some way to the modal content.',\n type: 'string',\n status: 'optional',\n },\n labelledBy: {\n doc: 'The ID of the trigger component, describing the modal content. Defaults to the internal `trigger`, so make sure you define the `title` in `triggerAttributes`.',\n type: 'string',\n status: 'optional',\n },\n children: {\n doc: 'the content which will appear when triggering open the modal. If a function is given, you get a close method `() => ({ close })` in the arguments.',\n type: ['React.ReactNode', 'function'],\n status: 'optional',\n },\n fullscreen: {\n doc: 'If set to `true` then the modal content will be shown as fullscreen, without showing the original content behind. Can be set to `false` to omit the auto fullscreen. Defaults to `auto`.',\n type: 'boolean',\n status: 'optional',\n },\n openState: {\n doc: 'use this property to control the open/close state by setting either: `opened` / `closed` or `true` / `false`.',\n type: ['boolean', 'opened', 'closed'],\n status: 'optional',\n },\n openDelay: {\n doc: 'forces the modal to delay the opening. The delay is given in `ms`.',\n type: ['number', 'string'],\n status: 'optional',\n },\n disabled: {\n doc: 'Will disable the trigger button.',\n type: 'boolean',\n status: 'optional',\n },\n noAnimation: {\n doc: 'if set to `true`, no open/close animation will be shown. Defaults to `false`.',\n type: 'boolean',\n status: 'optional',\n },\n noAnimationOnMobile: {\n doc: 'same as `noAnimation`, but gets triggered only if the viewport width is less than `40em`. Defaults to `false`.',\n type: 'boolean',\n status: 'optional',\n },\n animationDuration: {\n doc: 'Duration of animation open/close in ms. Defaults to 300ms.',\n type: ['number', 'string'],\n status: 'optional',\n },\n preventClose: {\n doc: \"if set to `true` (boolean or string), then the user can't close the modal.\",\n type: 'boolean',\n status: 'optional',\n },\n preventOverlayClose: {\n doc: 'Disable clicking the background overlay to close the modal. PS! Pressing `esc` key will still close the modal.',\n type: 'boolean',\n status: 'optional',\n },\n openModal: {\n doc: 'set a function to call the callback function, once the modal should open: `openModal={(open) => open()}`.',\n type: 'function',\n status: 'optional',\n },\n closeModal: {\n doc: 'set a function to call the callback function, once the modal should close: `closeModal={(close) => close()}`.',\n type: 'function',\n status: 'optional',\n },\n focusSelector: {\n doc: 'The Modal handles the first focus – automatically. However, you can define a custom focus selector the will be used instead `focusSelector=\".css-selector\"`.',\n type: 'string',\n status: 'optional',\n },\n overlayClass: {\n doc: 'give the page overlay a custom class name (maps to `dnb-modal__overlay`).',\n type: 'string',\n status: 'optional',\n },\n contentClass: {\n doc: 'give the content wrapper a custom class name (maps to `dnb-modal__content`).',\n type: 'string',\n status: 'optional',\n },\n omitTriggerButton: {\n doc: 'omits default showing trigger button.',\n type: 'boolean',\n status: 'optional',\n },\n trigger: {\n doc: 'provide a custom trigger component. Like `trigger={<Anchor href=\"/\" />}`. It will set the focus on it when the modal gets closed.',\n type: ['React.ReactNode', 'function'],\n status: 'optional',\n },\n triggerAttributes: {\n doc: 'send along with custom HTML attributes or properties to the trigger button.',\n type: 'Various',\n status: 'optional',\n },\n dialogTitle: {\n doc: 'The aria label of the dialog when no labelledBy and no title is given. Defaults to `Vindu`.',\n type: 'string',\n status: 'optional',\n },\n directDomReturn: {\n doc: 'If true, the modal will not open in a new DOM but directly in current DOM. Defaults to `false`. Be aware of the side effects of setting this property to `true`.',\n type: 'boolean',\n status: 'optional',\n },\n bypassInvalidationSelectors: {\n doc: \"Define an array with HTML class selectors (`['.element-selector']`) which should not get invalidated when the modal opens/closes. Use this in order to let some parts of your site still be accessible by screen readers.\",\n type: 'boolean',\n status: 'optional',\n },\n scrollRef: {\n doc: 'To get the scroll Element, pass in your own React ref.',\n type: 'React.RefObject',\n status: 'optional',\n },\n contentRef: {\n doc: 'To get the inner content Element, pass in your own React ref.',\n type: 'React.RefObject',\n status: 'optional',\n },\n '[Space](/uilib/layout/space/properties)': {\n doc: 'Spacing properties like `top` or `bottom` are supported.',\n type: ['string', 'object'],\n status: 'optional',\n },\n spacing: {\n doc: 'if set to `false` then the modal content will be shown without any spacing. Defaults to `true`.',\n type: 'boolean',\n status: 'deprecated',\n },\n closeTitle: {\n doc: 'the title of the close button. Defaults to _Lukk_.',\n type: 'string',\n status: 'deprecated',\n },\n hideCloseButton: {\n doc: 'if true, the close button will not be shown.',\n type: 'boolean',\n status: 'deprecated',\n },\n class: {\n doc: 'give the inner content wrapper a class name (maps to `dnb-modal__content__inner`).',\n type: 'string',\n status: 'optional',\n },\n className: {\n doc: 'give the inner content wrapper a class name (maps to `dnb-modal__content__inner`).',\n type: 'string',\n status: 'optional',\n },\n}\n\nexport const ModalPropertiesWithSnakeCase: PropertiesTableProps =\n transformPropertyNamesWithSnakeCase(ModalProperties)\n\nexport const ModalEvents: PropertiesTableProps = {\n onOpen: {\n doc: 'This event gets triggered once the modal shows up. Returns the modal id: `{ id }`.',\n type: 'function',\n status: 'optional',\n },\n onClose: {\n doc: 'This event gets triggered once the modal gets closed. Returns the modal id: `{ id, event, triggeredBy }`.',\n type: 'function',\n status: 'optional',\n },\n onClosePrevent: {\n doc: 'This event gets triggered once the user tries to close the modal, but `preventClose` is set to **true**. Returns a callback `close` you can call to trigger the close mechanism. More details below. Returns the modal id: `{ id, event, close: Method, triggeredBy }`.',\n type: 'function',\n status: 'optional',\n },\n}\n\nexport const ModalEventsWithSnakeCase: PropertiesTableProps =\n transformPropertyNamesWithSnakeCase(ModalEvents)\n"],"mappings":";AACA,SAASA,WAAW,QAAQ,+BAA+B;AAE3D,MAAMC,mCAAmC,GACvCC,UAAgC,IAC7B;EACH,OAAOC,MAAM,CAACC,WAAW,CACvBD,MAAM,CAACE,OAAO,CAACH,UAAU,CAAC,CAACI,GAAG,CAACC,IAAA;IAAA,IAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;IAAA,OAAK,CAC/CC,GAAG,KAAKA,GAAG,CAACE,WAAW,CAAC,CAAC,GAAG,GAAGF,GAAG,MAAMR,WAAW,CAACQ,GAAG,CAAC,EAAE,GAAGA,GAAG,EAChEC,KAAK,CACN;EAAA,EACH,CAAC;AACH,CAAC;AAED,OAAO,MAAME,eAAqC,GAAG;EACnDC,EAAE,EAAE;IACFC,GAAG,EAAE,kEAAkE;IACvEC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDC,MAAM,EAAE;IACNH,GAAG,EAAE,iHAAiH;IACtHC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDE,SAAS,EAAE;IACTJ,GAAG,EAAE,6GAA6G;IAClHC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDG,UAAU,EAAE;IACVL,GAAG,EAAE,gKAAgK;IACrKC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;E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Property";
|
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
5
|
var _UploadInfo, _UploadFileList;
|
|
6
6
|
const _excluded = ["buttonTextSingular", "textSingular"],
|
|
7
|
-
_excluded2 = ["id", "skeleton", "className", "acceptedFileTypes", "filesAmountLimit", "fileMaxSize", "onChange", "onFileDelete", "onFileClick", "download", "allowDuplicates", "title", "text", "fileTypeTableCaption", "fileTypeDescription", "fileSizeDescription", "fileAmountDescription", "fileSizeContent", "buttonText", "loadingText", "errorLargeFile", "errorUnsupportedFile", "errorAmountLimit", "deleteButton", "fileListAriaLabel"];
|
|
7
|
+
_excluded2 = ["id", "skeleton", "className", "acceptedFileTypes", "filesAmountLimit", "fileMaxSize", "onChange", "onFileDelete", "onFileClick", "download", "allowDuplicates", "title", "text", "fileTypeTableCaption", "fileTypeDescription", "fileSizeDescription", "fileAmountDescription", "fileSizeContent", "buttonText", "loadingText", "errorLargeFile", "errorUnsupportedFile", "errorAmountLimit", "deleteButton", "fileListAriaLabel", "disableDragAndDrop"];
|
|
8
8
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
9
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
10
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
@@ -15,6 +15,7 @@ import Provider from '../../shared/Provider';
|
|
|
15
15
|
import Context from '../../shared/Context';
|
|
16
16
|
import { extendPropsWithContext, makeUniqueId } from '../../shared/component-helper';
|
|
17
17
|
import useId from '../../shared/helpers/useId';
|
|
18
|
+
import HeightAnimation from '../height-animation/HeightAnimation';
|
|
18
19
|
import UploadFileInput from './UploadFileInput';
|
|
19
20
|
import useUpload from './useUpload';
|
|
20
21
|
import UploadDropzone from './UploadDropzone';
|
|
@@ -63,7 +64,8 @@ const Upload = localProps => {
|
|
|
63
64
|
errorUnsupportedFile,
|
|
64
65
|
errorAmountLimit,
|
|
65
66
|
deleteButton,
|
|
66
|
-
fileListAriaLabel
|
|
67
|
+
fileListAriaLabel,
|
|
68
|
+
disableDragAndDrop
|
|
67
69
|
} = extendedProps,
|
|
68
70
|
props = _objectWithoutProperties(extendedProps, _excluded2);
|
|
69
71
|
const spacingClasses = createSpacingClasses(props);
|
|
@@ -106,6 +108,7 @@ const Upload = localProps => {
|
|
|
106
108
|
}
|
|
107
109
|
return validFiles;
|
|
108
110
|
}, [acceptedFileTypes, errorLargeFile, errorUnsupportedFile, fileMaxSize, files, filesAmountLimit, getExistingFile, onChange, setFiles, setInternalFiles]);
|
|
111
|
+
const UploadWrapper = disableDragAndDrop ? HeightAnimation : UploadDropzone;
|
|
109
112
|
return React.createElement(UploadContext.Provider, {
|
|
110
113
|
value: _objectSpread(_objectSpread({}, extendedProps), {}, {
|
|
111
114
|
id,
|
|
@@ -113,7 +116,7 @@ const Upload = localProps => {
|
|
|
113
116
|
})
|
|
114
117
|
}, React.createElement(Provider, {
|
|
115
118
|
skeleton: skeleton
|
|
116
|
-
}, React.createElement(
|
|
119
|
+
}, React.createElement(UploadWrapper, {
|
|
117
120
|
className: classnames('dnb-upload', spacingClasses, className)
|
|
118
121
|
}, _UploadInfo || (_UploadInfo = React.createElement(UploadInfo, null)), React.createElement(UploadFileInput, props), _UploadFileList || (_UploadFileList = React.createElement(UploadFileList, null)))));
|
|
119
122
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Upload.js","names":["React","useCallback","classnames","createSpacingClasses","Provider","Context","extendPropsWithContext","makeUniqueId","useId","UploadFileInput","useUpload","UploadDropzone","UploadContext","defaultProps","verifyFiles","UploadFileList","UploadInfo","Upload","localProps","context","useContext","_context$getTranslati","getTranslation","buttonTextSingular","textSingular","translations","_objectWithoutProperties","_excluded","filesAmountLimit","buttonText","text","extendedProps","skeleton","id","idProp","className","acceptedFileTypes","fileMaxSize","onChange","onFileDelete","onFileClick","download","allowDuplicates","title","fileTypeTableCaption","fileTypeDescription","fileSizeDescription","fileAmountDescription","fileSizeContent","loadingText","errorLargeFile","errorUnsupportedFile","errorAmountLimit","deleteButton","fileListAriaLabel","props","_excluded2","spacingClasses","files","setFiles","setInternalFiles","getExistingFile","onInputUpload","newFiles","mergedFiles","map","fileItem","file","existingFile","exists","Boolean","filesToVerify","filter","_ref","verifiedFiles","validFiles","slice","createElement","value","_objectSpread","_UploadInfo","_UploadFileList","_formElement","_supportsSpacingProps"],"sources":["../../../../src/components/upload/Upload.tsx"],"sourcesContent":["import React, { useCallback } from 'react'\nimport classnames from 'classnames'\n\n// Shared\nimport { createSpacingClasses } from '../space/SpacingHelper'\nimport Provider from '../../shared/Provider'\nimport Context from '../../shared/Context'\nimport {\n extendPropsWithContext,\n makeUniqueId,\n} from '../../shared/component-helper'\nimport useId from '../../shared/helpers/useId'\n\n// Internal\nimport UploadFileInput from './UploadFileInput'\nimport useUpload from './useUpload'\nimport UploadDropzone from './UploadDropzone'\nimport { UploadContext, defaultProps } from './UploadContext'\nimport { verifyFiles } from './UploadVerify'\n\nimport type { UploadFile, UploadAllProps } from './types'\nimport UploadFileList from './UploadFileList'\nimport UploadInfo from './UploadInfo'\n\nexport type * from './types'\nexport { defaultProps }\n\nconst Upload = (localProps: UploadAllProps) => {\n const context = React.useContext(Context)\n\n const { buttonTextSingular, textSingular, ...translations } =\n context.getTranslation(localProps).Upload\n\n if (localProps?.filesAmountLimit === 1) {\n translations.buttonText = buttonTextSingular\n translations.text = textSingular\n }\n\n const extendedProps = extendPropsWithContext(\n localProps,\n defaultProps,\n { skeleton: context?.skeleton },\n translations,\n context.Upload\n )\n\n const {\n id: idProp,\n skeleton,\n className,\n acceptedFileTypes,\n filesAmountLimit,\n fileMaxSize,\n onChange,\n onFileDelete, // eslint-disable-line\n onFileClick, // eslint-disable-line\n download, // eslint-disable-line\n allowDuplicates
|
|
1
|
+
{"version":3,"file":"Upload.js","names":["React","useCallback","classnames","createSpacingClasses","Provider","Context","extendPropsWithContext","makeUniqueId","useId","HeightAnimation","UploadFileInput","useUpload","UploadDropzone","UploadContext","defaultProps","verifyFiles","UploadFileList","UploadInfo","Upload","localProps","context","useContext","_context$getTranslati","getTranslation","buttonTextSingular","textSingular","translations","_objectWithoutProperties","_excluded","filesAmountLimit","buttonText","text","extendedProps","skeleton","id","idProp","className","acceptedFileTypes","fileMaxSize","onChange","onFileDelete","onFileClick","download","allowDuplicates","title","fileTypeTableCaption","fileTypeDescription","fileSizeDescription","fileAmountDescription","fileSizeContent","loadingText","errorLargeFile","errorUnsupportedFile","errorAmountLimit","deleteButton","fileListAriaLabel","disableDragAndDrop","props","_excluded2","spacingClasses","files","setFiles","setInternalFiles","getExistingFile","onInputUpload","newFiles","mergedFiles","map","fileItem","file","existingFile","exists","Boolean","filesToVerify","filter","_ref","verifiedFiles","validFiles","slice","UploadWrapper","createElement","value","_objectSpread","_UploadInfo","_UploadFileList","_formElement","_supportsSpacingProps"],"sources":["../../../../src/components/upload/Upload.tsx"],"sourcesContent":["import React, { useCallback } from 'react'\nimport classnames from 'classnames'\n\n// Shared\nimport { createSpacingClasses } from '../space/SpacingHelper'\nimport Provider from '../../shared/Provider'\nimport Context from '../../shared/Context'\nimport {\n extendPropsWithContext,\n makeUniqueId,\n} from '../../shared/component-helper'\nimport useId from '../../shared/helpers/useId'\nimport HeightAnimation from '../height-animation/HeightAnimation'\n\n// Internal\nimport UploadFileInput from './UploadFileInput'\nimport useUpload from './useUpload'\nimport UploadDropzone from './UploadDropzone'\nimport { UploadContext, defaultProps } from './UploadContext'\nimport { verifyFiles } from './UploadVerify'\n\nimport type { UploadFile, UploadAllProps } from './types'\nimport UploadFileList from './UploadFileList'\nimport UploadInfo from './UploadInfo'\n\nexport type * from './types'\nexport { defaultProps }\n\nconst Upload = (localProps: UploadAllProps) => {\n const context = React.useContext(Context)\n\n const { buttonTextSingular, textSingular, ...translations } =\n context.getTranslation(localProps).Upload\n\n if (localProps?.filesAmountLimit === 1) {\n translations.buttonText = buttonTextSingular\n translations.text = textSingular\n }\n\n const extendedProps = extendPropsWithContext(\n localProps,\n defaultProps,\n { skeleton: context?.skeleton },\n translations,\n context.Upload\n )\n\n const {\n id: idProp,\n skeleton,\n className,\n acceptedFileTypes,\n filesAmountLimit,\n fileMaxSize,\n onChange,\n onFileDelete, // eslint-disable-line\n onFileClick, // eslint-disable-line\n download, // eslint-disable-line\n allowDuplicates,\n title, // eslint-disable-line\n text, // eslint-disable-line\n fileTypeTableCaption, // eslint-disable-line\n fileTypeDescription, // eslint-disable-line\n fileSizeDescription, // eslint-disable-line\n fileAmountDescription, // eslint-disable-line\n fileSizeContent, // eslint-disable-line\n buttonText, // eslint-disable-line\n loadingText, // eslint-disable-line\n errorLargeFile,\n errorUnsupportedFile,\n errorAmountLimit, // eslint-disable-line\n deleteButton, // eslint-disable-line\n fileListAriaLabel, // eslint-disable-line\n disableDragAndDrop,\n ...props\n } = extendedProps\n\n const spacingClasses = createSpacingClasses(props)\n\n const id = useId(idProp)\n\n const { files, setFiles, setInternalFiles, getExistingFile } =\n useUpload(id)\n\n const onInputUpload = useCallback(\n (newFiles: Array<UploadFile>) => {\n const mergedFiles = [\n ...files,\n ...newFiles.map((fileItem) => {\n const { file } = fileItem\n\n const existingFile = getExistingFile(file, files)\n\n fileItem.exists = Boolean(existingFile)\n fileItem.id =\n fileItem.exists && !allowDuplicates\n ? existingFile.id\n : makeUniqueId()\n\n return fileItem\n }),\n ]\n\n const filesToVerify = allowDuplicates\n ? mergedFiles\n : mergedFiles.filter(({ exists }) => !exists)\n\n const verifiedFiles = verifyFiles(filesToVerify, {\n fileMaxSize,\n acceptedFileTypes,\n errorUnsupportedFile,\n errorLargeFile,\n })\n\n const validFiles = [...verifiedFiles].slice(\n 0,\n filesAmountLimit\n ) as Array<UploadFile>\n\n setFiles(validFiles)\n setInternalFiles(mergedFiles)\n\n if (typeof onChange === 'function') {\n onChange({ files: validFiles })\n }\n\n return validFiles\n },\n [\n acceptedFileTypes,\n errorLargeFile,\n errorUnsupportedFile,\n fileMaxSize,\n files,\n filesAmountLimit,\n getExistingFile,\n onChange,\n setFiles,\n setInternalFiles,\n ]\n )\n\n const UploadWrapper = disableDragAndDrop\n ? HeightAnimation\n : UploadDropzone\n\n return (\n <UploadContext.Provider\n value={{\n ...extendedProps,\n id,\n onInputUpload,\n }}\n >\n <Provider skeleton={skeleton}>\n <UploadWrapper\n className={classnames('dnb-upload', spacingClasses, className)}\n >\n <UploadInfo />\n\n <UploadFileInput {...props} />\n\n <UploadFileList />\n </UploadWrapper>\n </Provider>\n </UploadContext.Provider>\n )\n}\n\nUpload.useUpload = useUpload\n\nUpload._formElement = true\nUpload._supportsSpacingProps = true\n\nexport default Upload\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAC1C,OAAOC,UAAU,MAAM,YAAY;AAGnC,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,OAAOC,QAAQ,MAAM,uBAAuB;AAC5C,OAAOC,OAAO,MAAM,sBAAsB;AAC1C,SACEC,sBAAsB,EACtBC,YAAY,QACP,+BAA+B;AACtC,OAAOC,KAAK,MAAM,4BAA4B;AAC9C,OAAOC,eAAe,MAAM,qCAAqC;AAGjE,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,OAAOC,SAAS,MAAM,aAAa;AACnC,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,SAASC,aAAa,EAAEC,YAAY,QAAQ,iBAAiB;AAC7D,SAASC,WAAW,QAAQ,gBAAgB;AA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EiB;MAAW,CAAC,CAAC;IACjC;IAEA,OAAOA,UAAU;EACnB,CAAC,EACD,CACExC,iBAAiB,EACjBc,cAAc,EACdC,oBAAoB,EACpBd,WAAW,EACXsB,KAAK,EACL/B,gBAAgB,EAChBkC,eAAe,EACfxB,QAAQ,EACRsB,QAAQ,EACRC,gBAAgB,CAEpB,CAAC;EAED,MAAMiB,aAAa,GAAGvB,kBAAkB,GACpC/C,eAAe,GACfG,cAAc;EAElB,OACEZ,KAAA,CAAAgF,aAAA,CAACnE,aAAa,CAACT,QAAQ;IACrB6E,KAAK,EAAAC,aAAA,CAAAA,aAAA,KACAlD,aAAa;MAChBE,EAAE;MACF8B;IAAa;EACb,GAEFhE,KAAA,CAAAgF,aAAA,CAAC5E,QAAQ;IAAC6B,QAAQ,EAAEA;EAAS,GAC3BjC,KAAA,CAAAgF,aAAA,CAACD,aAAa;IACZ3C,SAAS,EAAElC,UAAU,CAAC,YAAY,EAAEyD,cAAc,EAAEvB,SAAS;EAAE,GAAA+C,WAAA,KAAAA,WAAA,GAE/DnF,KAAA,CAAAgF,aAAA,CAAC/D,UAAU,MAAE,CAAC,GAEdjB,KAAA,CAAAgF,aAAA,CAACtE,eAAe,EAAK+C,KAAQ,CAAC,EAAA2B,eAAA,KAAAA,eAAA,GAE9BpF,KAAA,CAAAgF,aAAA,CAAChE,cAAc,MAAE,CAAC,CACL,CACP,CACY,CAAC;AAE7B,CAAC;AAEDE,MAAM,CAACP,SAAS,GAAGA,SAAS;AAE5BO,MAAM,CAACmE,YAAY,GAAG,IAAI;AAC1BnE,MAAM,CAACoE,qBAAqB,GAAG,IAAI;AAEnC,eAAepE,MAAM","ignoreList":[]}
|
|
@@ -2,3 +2,4 @@ import { PropertiesTableProps } from '../../shared/types';
|
|
|
2
2
|
export declare const UploadProperties: PropertiesTableProps;
|
|
3
3
|
export declare const AcceptedFileTypeProperties: PropertiesTableProps;
|
|
4
4
|
export declare const UploadEvents: PropertiesTableProps;
|
|
5
|
+
export declare const FileItemProperties: PropertiesTableProps;
|
|
@@ -39,6 +39,11 @@ export const UploadProperties = {
|
|
|
39
39
|
type: 'boolean',
|
|
40
40
|
status: 'optional'
|
|
41
41
|
},
|
|
42
|
+
disableDragAndDrop: {
|
|
43
|
+
doc: 'Disables file drag and drop, by removing the drop zone. Defaults to `false`.',
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
status: 'optional'
|
|
46
|
+
},
|
|
42
47
|
skeleton: {
|
|
43
48
|
doc: 'Skeleton should be applied when loading content.',
|
|
44
49
|
type: 'boolean',
|
|
@@ -79,4 +84,41 @@ export const UploadEvents = {
|
|
|
79
84
|
status: 'optional'
|
|
80
85
|
}
|
|
81
86
|
};
|
|
87
|
+
export const FileItemProperties = {
|
|
88
|
+
file: {
|
|
89
|
+
doc: 'The file object. This is the same object as the one returned by the `File` API.',
|
|
90
|
+
type: 'File',
|
|
91
|
+
status: 'required'
|
|
92
|
+
},
|
|
93
|
+
id: {
|
|
94
|
+
doc: 'Unique ID for the file item. This ID is generated by the component and is not user-defined.',
|
|
95
|
+
type: 'string',
|
|
96
|
+
status: 'required'
|
|
97
|
+
},
|
|
98
|
+
exists: {
|
|
99
|
+
doc: 'Indicates if the file item already exists in the list of files. This is useful for distinguishing between new and existing files.',
|
|
100
|
+
type: 'boolean',
|
|
101
|
+
status: 'optional'
|
|
102
|
+
},
|
|
103
|
+
isLoading: {
|
|
104
|
+
doc: 'Indicates if the file item is currently being loaded. This is useful for showing a loading state while the file is being processed.',
|
|
105
|
+
type: 'boolean',
|
|
106
|
+
status: 'optional'
|
|
107
|
+
},
|
|
108
|
+
errorMessage: {
|
|
109
|
+
doc: 'Provide an error message to be displayed. This is useful for indicating issues with the file upload process.',
|
|
110
|
+
type: 'React.ReactNode',
|
|
111
|
+
status: 'optional'
|
|
112
|
+
},
|
|
113
|
+
description: {
|
|
114
|
+
doc: 'Provide a description to be displayed. This is useful for providing additional information about the file.',
|
|
115
|
+
type: 'React.ReactNode',
|
|
116
|
+
status: 'optional'
|
|
117
|
+
},
|
|
118
|
+
removeDeleteButton: {
|
|
119
|
+
doc: 'Set to `true` to remove the delete button from the file item. This is useful for preventing users from deleting files.',
|
|
120
|
+
type: 'boolean',
|
|
121
|
+
status: 'optional'
|
|
122
|
+
}
|
|
123
|
+
};
|
|
82
124
|
//# sourceMappingURL=UploadDocs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadDocs.js","names":["UploadProperties","id","doc","type","status","acceptedFileTypes","filesAmountLimit","fileMaxSize","title","text","download","allowDuplicates","skeleton","AcceptedFileTypeProperties","fileType","UploadEvents","onChange","onFileDelete","onFileClick"],"sources":["../../../../src/components/upload/UploadDocs.ts"],"sourcesContent":["import { PropertiesTableProps } from '../../shared/types'\n\nexport const UploadProperties: PropertiesTableProps = {\n id: {\n doc: 'Unique id used with the useUpload hook to manage the files. Needed when wanting to connect with the useUpload hook.',\n type: ['string', 'Function', 'Object', 'React.Context'],\n status: 'optional',\n },\n acceptedFileTypes: {\n doc: 'List of accepted file types. Either as string or [AcceptedFileType](/uilib/components/upload/properties/#acceptedfiletype). When providing a list of [AcceptedFileType](/uilib/components/upload/properties/#acceptedfiletype), the accepted file types will be presented in a table(see [example](/uilib/components/upload/demos/#upload-with-file-max-size-based-on-file-type)).',\n type: ['Array<string>', 'Array<AcceptedFileType>'],\n status: 'required',\n },\n filesAmountLimit: {\n doc: 'Defines the amount of files the user can select and upload. Defaults to 100.',\n type: 'number',\n status: 'optional',\n },\n fileMaxSize: {\n doc: 'Defines the max file size of each file in MB. Use either `0` or `false` to disable. Defaults to 5 MB.',\n type: ['number', 'false'],\n status: 'optional',\n },\n title: {\n doc: 'Custom text property. Replaces the default title. Can be disabled using `false`.',\n type: 'string',\n status: 'optional',\n },\n text: {\n doc: 'Custom text property. Replaces the default text. Can be disabled using `false`.',\n type: 'string',\n status: 'optional',\n },\n download: {\n doc: 'Causes the browser to treat all listed files as downloadable instead of opening them in a new browser tab or window. Defaults to `false`.',\n type: 'boolean',\n status: 'optional',\n },\n allowDuplicates: {\n doc: 'Allows uploading of duplicate files. Defaults to `false`.',\n type: 'boolean',\n status: 'optional',\n },\n skeleton: {\n doc: 'Skeleton should be applied when loading content.',\n type: 'boolean',\n status: 'optional',\n },\n '[Space](/uilib/layout/space/properties)': {\n doc: 'Spacing properties like `top` or `bottom` are supported.',\n type: ['string', 'object'],\n status: 'optional',\n },\n}\n\nexport const AcceptedFileTypeProperties: PropertiesTableProps = {\n fileType: {\n doc: 'The name of the accepted file type.',\n type: 'string',\n status: 'required',\n },\n fileMaxSize: {\n doc: 'Defines the max file size of the given file type in MB. Use either `0` or `false` to disable. If not provided, it defaults to the value of [Uploads](/uilib/components/upload/properties/#properties) `fileMaxSize` which defaults to 5 MB.',\n type: ['number', 'false'],\n status: 'optional',\n },\n}\n\nexport const UploadEvents: PropertiesTableProps = {\n onChange: {\n doc: 'Will be called on `files` changes made by the user. Access the files with `{ files }` (containing each a `fileItem`).',\n type: 'function',\n status: 'optional',\n },\n onFileDelete: {\n doc: 'Will be called once a file gets deleted by the user. Access the deleted file with `{ fileItem }`.',\n type: 'function',\n status: 'optional',\n },\n onFileClick: {\n doc: 'Will be called once a file gets clicked on by the user. Access the clicked file with `{ fileItem }`.',\n type: 'function',\n status: 'optional',\n },\n}\n"],"mappings":"AAEA,OAAO,MAAMA,gBAAsC,GAAG;EACpDC,EAAE,EAAE;IACFC,GAAG,EAAE,qHAAqH;IAC1HC,IAAI,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,eAAe,CAAC;IACvDC,MAAM,EAAE;EACV,CAAC;EACDC,iBAAiB,EAAE;IACjBH,GAAG,EAAE,oXAAoX;IACzXC,IAAI,EAAE,CAAC,eAAe,EAAE,yBAAyB,CAAC;IAClDC,MAAM,EAAE;EACV,CAAC;EACDE,gBAAgB,EAAE;IAChBJ,GAAG,EAAE,8EAA8E;IACnFC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDG,WAAW,EAAE;IACXL,GAAG,EAAE,uGAAuG;IAC5GC,IAAI,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;IACzBC,MAAM,EAAE;EACV,CAAC;EACDI,KAAK,EAAE;IACLN,GAAG,EAAE,kFAAkF;IACvFC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDK,IAAI,EAAE;IACJP,GAAG,EAAE,iFAAiF;IACtFC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDM,QAAQ,EAAE;IACRR,GAAG,EAAE,2IAA2I;IAChJC,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE;EACV,CAAC;EACDO,eAAe,EAAE;IACfT,GAAG,EAAE,2DAA2D;IAChEC,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE;EACV,CAAC;EACDQ,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"UploadDocs.js","names":["UploadProperties","id","doc","type","status","acceptedFileTypes","filesAmountLimit","fileMaxSize","title","text","download","allowDuplicates","disableDragAndDrop","skeleton","AcceptedFileTypeProperties","fileType","UploadEvents","onChange","onFileDelete","onFileClick","FileItemProperties","file","exists","isLoading","errorMessage","description","removeDeleteButton"],"sources":["../../../../src/components/upload/UploadDocs.ts"],"sourcesContent":["import { PropertiesTableProps } from '../../shared/types'\n\nexport const UploadProperties: PropertiesTableProps = {\n id: {\n doc: 'Unique id used with the useUpload hook to manage the files. Needed when wanting to connect with the useUpload hook.',\n type: ['string', 'Function', 'Object', 'React.Context'],\n status: 'optional',\n },\n acceptedFileTypes: {\n doc: 'List of accepted file types. Either as string or [AcceptedFileType](/uilib/components/upload/properties/#acceptedfiletype). When providing a list of [AcceptedFileType](/uilib/components/upload/properties/#acceptedfiletype), the accepted file types will be presented in a table(see [example](/uilib/components/upload/demos/#upload-with-file-max-size-based-on-file-type)).',\n type: ['Array<string>', 'Array<AcceptedFileType>'],\n status: 'required',\n },\n filesAmountLimit: {\n doc: 'Defines the amount of files the user can select and upload. Defaults to 100.',\n type: 'number',\n status: 'optional',\n },\n fileMaxSize: {\n doc: 'Defines the max file size of each file in MB. Use either `0` or `false` to disable. Defaults to 5 MB.',\n type: ['number', 'false'],\n status: 'optional',\n },\n title: {\n doc: 'Custom text property. Replaces the default title. Can be disabled using `false`.',\n type: 'string',\n status: 'optional',\n },\n text: {\n doc: 'Custom text property. Replaces the default text. Can be disabled using `false`.',\n type: 'string',\n status: 'optional',\n },\n download: {\n doc: 'Causes the browser to treat all listed files as downloadable instead of opening them in a new browser tab or window. Defaults to `false`.',\n type: 'boolean',\n status: 'optional',\n },\n allowDuplicates: {\n doc: 'Allows uploading of duplicate files. Defaults to `false`.',\n type: 'boolean',\n status: 'optional',\n },\n disableDragAndDrop: {\n doc: 'Disables file drag and drop, by removing the drop zone. Defaults to `false`.',\n type: 'boolean',\n status: 'optional',\n },\n skeleton: {\n doc: 'Skeleton should be applied when loading content.',\n type: 'boolean',\n status: 'optional',\n },\n '[Space](/uilib/layout/space/properties)': {\n doc: 'Spacing properties like `top` or `bottom` are supported.',\n type: ['string', 'object'],\n status: 'optional',\n },\n}\n\nexport const AcceptedFileTypeProperties: PropertiesTableProps = {\n fileType: {\n doc: 'The name of the accepted file type.',\n type: 'string',\n status: 'required',\n },\n fileMaxSize: {\n doc: 'Defines the max file size of the given file type in MB. Use either `0` or `false` to disable. If not provided, it defaults to the value of [Uploads](/uilib/components/upload/properties/#properties) `fileMaxSize` which defaults to 5 MB.',\n type: ['number', 'false'],\n status: 'optional',\n },\n}\n\nexport const UploadEvents: PropertiesTableProps = {\n onChange: {\n doc: 'Will be called on `files` changes made by the user. Access the files with `{ files }` (containing each a `fileItem`).',\n type: 'function',\n status: 'optional',\n },\n onFileDelete: {\n doc: 'Will be called once a file gets deleted by the user. Access the deleted file with `{ fileItem }`.',\n type: 'function',\n status: 'optional',\n },\n onFileClick: {\n doc: 'Will be called once a file gets clicked on by the user. Access the clicked file with `{ fileItem }`.',\n type: 'function',\n status: 'optional',\n },\n}\n\nexport const FileItemProperties: PropertiesTableProps = {\n file: {\n doc: 'The file object. This is the same object as the one returned by the `File` API.',\n type: 'File',\n status: 'required',\n },\n id: {\n doc: 'Unique ID for the file item. This ID is generated by the component and is not user-defined.',\n type: 'string',\n status: 'required',\n },\n exists: {\n doc: 'Indicates if the file item already exists in the list of files. This is useful for distinguishing between new and existing files.',\n type: 'boolean',\n status: 'optional',\n },\n isLoading: {\n doc: 'Indicates if the file item is currently being loaded. This is useful for showing a loading state while the file is being processed.',\n type: 'boolean',\n status: 'optional',\n },\n errorMessage: {\n doc: 'Provide an error message to be displayed. This is useful for indicating issues with the file upload process.',\n type: 'React.ReactNode',\n status: 'optional',\n },\n description: {\n doc: 'Provide a description to be displayed. This is useful for providing additional information about the file.',\n type: 'React.ReactNode',\n status: 'optional',\n },\n removeDeleteButton: {\n doc: 'Set to `true` to remove the delete button from the file item. This is useful for preventing users from deleting files.',\n type: 'boolean',\n status: 'optional',\n },\n}\n"],"mappings":"AAEA,OAAO,MAAMA,gBAAsC,GAAG;EACpDC,EAAE,EAAE;IACFC,GAAG,EAAE,qHAAqH;IAC1HC,IAAI,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,eAAe,CAAC;IACvDC,MAAM,EAAE;EACV,CAAC;EACDC,iBAAiB,EAAE;IACjBH,GAAG,EAAE,oXAAoX;IACzXC,IAAI,EAAE,CAAC,eAAe,EAAE,yBAAyB,CAAC;IAClDC,MAAM,EAAE;EACV,CAAC;EACDE,gBAAgB,EAAE;IAChBJ,GAAG,EAAE,8EAA8E;IACnFC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDG,WAAW,EAAE;IACXL,GAAG,EAAE,uGAAuG;IAC5GC,IAAI,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;IACzBC,MAAM,EAAE;EACV,CAAC;EACDI,KAAK,EAAE;IACLN,GAAG,EAAE,kFAAkF;IACvFC,IA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