fictoan-react 2.0.0-beta.17 → 2.0.0-beta.18
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/dist/components/Accordion/Accordion.d.ts.map +1 -1
- package/dist/components/Accordion/Accordion.js +27 -0
- package/dist/components/Accordion/Accordion.js.map +1 -0
- package/dist/components/Badge/Badge.d.ts.map +1 -1
- package/dist/components/Badge/Badge.js +56 -0
- package/dist/components/Badge/Badge.js.map +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +65 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js.map +1 -0
- package/dist/components/Button/Button.js +28 -0
- package/dist/components/Button/Button.js.map +1 -0
- package/dist/components/ButtonGroup/ButtonGroup.js +27 -0
- package/dist/components/ButtonGroup/ButtonGroup.js.map +1 -0
- package/dist/components/Callout/Callout.js +31 -0
- package/dist/components/Callout/Callout.js.map +1 -0
- package/dist/components/Card/Card.js +27 -0
- package/dist/components/Card/Card.js.map +1 -0
- package/dist/components/CodeBlock/CodeBlock.js +191 -0
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -0
- package/dist/components/Divider/Divider.js +29 -0
- package/dist/components/Divider/Divider.js.map +1 -0
- package/dist/components/Drawer/Drawer.d.ts +3 -0
- package/dist/components/Drawer/Drawer.d.ts.map +1 -1
- package/dist/components/Drawer/Drawer.js +96 -0
- package/dist/components/Drawer/Drawer.js.map +1 -0
- package/dist/components/Element/Element.d.ts +6 -2
- package/dist/components/Element/Element.d.ts.map +1 -1
- package/dist/components/Element/Element.js +152 -0
- package/dist/components/Element/Element.js.map +1 -0
- package/dist/components/Element/Tags.js +31 -0
- package/dist/components/Element/Tags.js.map +1 -0
- package/dist/components/Element/constants.js +8 -0
- package/dist/components/Element/constants.js.map +1 -0
- package/dist/components/Form/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/components/Form/Checkbox/Checkbox.js +78 -0
- package/dist/components/Form/Checkbox/Checkbox.js.map +1 -0
- package/dist/components/Form/Checkbox/CheckboxAndSwitchGroup.d.ts.map +1 -1
- package/dist/components/Form/Checkbox/CheckboxAndSwitchGroup.js +177 -0
- package/dist/components/Form/Checkbox/CheckboxAndSwitchGroup.js.map +1 -0
- package/dist/components/Form/Checkbox/Switch.d.ts.map +1 -1
- package/dist/components/Form/Checkbox/Switch.js +78 -0
- package/dist/components/Form/Checkbox/Switch.js.map +1 -0
- package/dist/components/Form/FileUpload/FileUpload.d.ts.map +1 -1
- package/dist/components/Form/FileUpload/FileUpload.js +142 -0
- package/dist/components/Form/FileUpload/FileUpload.js.map +1 -0
- package/dist/components/Form/Form/Form.js +37 -0
- package/dist/components/Form/Form/Form.js.map +1 -0
- package/dist/components/Form/Form/FormGenerator.js +64 -0
- package/dist/components/Form/Form/FormGenerator.js.map +1 -0
- package/dist/components/Form/FormItem/FormItem.d.ts +16 -0
- package/dist/components/Form/FormItem/FormItem.d.ts.map +1 -1
- package/dist/components/Form/FormItem/FormItem.js +127 -0
- package/dist/components/Form/FormItem/FormItem.js.map +1 -0
- package/dist/components/Form/FormItemGroup/FormItemGroup.js +42 -0
- package/dist/components/Form/FormItemGroup/FormItemGroup.js.map +1 -0
- package/dist/components/Form/InputField/InputField.d.ts.map +1 -1
- package/dist/components/Form/InputField/InputField.js +156 -0
- package/dist/components/Form/InputField/InputField.js.map +1 -0
- package/dist/components/Form/InputLabel/InputLabel.js +30 -0
- package/dist/components/Form/InputLabel/InputLabel.js.map +1 -0
- package/dist/components/Form/ListBox/ListBox.d.ts.map +1 -1
- package/dist/components/Form/ListBox/ListBox.js +284 -0
- package/dist/components/Form/ListBox/ListBox.js.map +1 -0
- package/dist/components/Form/ListBox/constants.d.ts +1 -1
- package/dist/components/Form/ListBox/constants.d.ts.map +1 -1
- package/dist/components/Form/ListBox/listBoxUtils.js +49 -0
- package/dist/components/Form/ListBox/listBoxUtils.js.map +1 -0
- package/dist/components/Form/PinInputField/PinInputField.d.ts +6 -1
- package/dist/components/Form/PinInputField/PinInputField.d.ts.map +1 -1
- package/dist/components/Form/PinInputField/PinInputField.js +165 -0
- package/dist/components/Form/PinInputField/PinInputField.js.map +1 -0
- package/dist/components/Form/RadioButton/RadioButton.d.ts.map +1 -1
- package/dist/components/Form/RadioButton/RadioButton.js +82 -0
- package/dist/components/Form/RadioButton/RadioButton.js.map +1 -0
- package/dist/components/Form/RadioButton/RadioGroup.d.ts.map +1 -1
- package/dist/components/Form/RadioButton/RadioGroup.js +97 -0
- package/dist/components/Form/RadioButton/RadioGroup.js.map +1 -0
- package/dist/components/Form/RadioButton/RadioTabGroup.d.ts.map +1 -1
- package/dist/components/Form/RadioButton/RadioTabGroup.js +182 -0
- package/dist/components/Form/RadioButton/RadioTabGroup.js.map +1 -0
- package/dist/components/Form/Range/Range.js +376 -0
- package/dist/components/Form/Range/Range.js.map +1 -0
- package/dist/components/Form/Select/Select.d.ts.map +1 -1
- package/dist/components/Form/Select/Select.js +83 -0
- package/dist/components/Form/Select/Select.js.map +1 -0
- package/dist/components/Form/TextArea/TextArea.d.ts.map +1 -1
- package/dist/components/Form/TextArea/TextArea.js +111 -0
- package/dist/components/Form/TextArea/TextArea.js.map +1 -0
- package/dist/components/Meter/Meter.js +110 -0
- package/dist/components/Meter/Meter.js.map +1 -0
- package/dist/components/Modal/Modal.d.ts.map +1 -1
- package/dist/components/Modal/Modal.js +75 -0
- package/dist/components/Modal/Modal.js.map +1 -0
- package/dist/components/Notification/NotificationItem/NotificationItem.d.ts.map +1 -1
- package/dist/components/Notification/NotificationItem/NotificationItem.js +70 -0
- package/dist/components/Notification/NotificationItem/NotificationItem.js.map +1 -0
- package/dist/components/Notification/NotificationsProvider/NotificationsProvider.js +88 -0
- package/dist/components/Notification/NotificationsProvider/NotificationsProvider.js.map +1 -0
- package/dist/components/Notification/NotificationsWrapper/NotificationsWrapper.d.ts.map +1 -1
- package/dist/components/Notification/NotificationsWrapper/NotificationsWrapper.js +35 -0
- package/dist/components/Notification/NotificationsWrapper/NotificationsWrapper.js.map +1 -0
- package/dist/components/OptionCard/OptionCard.js +150 -0
- package/dist/components/OptionCard/OptionCard.js.map +1 -0
- package/dist/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/components/Pagination/Pagination.js +206 -0
- package/dist/components/Pagination/Pagination.js.map +1 -0
- package/dist/components/Pagination/usePagination.js +35 -0
- package/dist/components/Pagination/usePagination.js.map +1 -0
- package/dist/components/Portion/Portion.js +34 -0
- package/dist/components/Portion/Portion.js.map +1 -0
- package/dist/components/ProgressBar/ProgressBar.js +63 -0
- package/dist/components/ProgressBar/ProgressBar.js.map +1 -0
- package/dist/components/Row/Row.js +40 -0
- package/dist/components/Row/Row.js.map +1 -0
- package/dist/components/Sidebar/ContentWrapper/ContentWrapper.js +23 -0
- package/dist/components/Sidebar/ContentWrapper/ContentWrapper.js.map +1 -0
- package/dist/components/Sidebar/SidebarFooter/SidebarFooter.js +25 -0
- package/dist/components/Sidebar/SidebarFooter/SidebarFooter.js.map +1 -0
- package/dist/components/Sidebar/SidebarHeader/SidebarHeader.js +25 -0
- package/dist/components/Sidebar/SidebarHeader/SidebarHeader.js.map +1 -0
- package/dist/components/Sidebar/SidebarItem/SidebarItem.js +30 -0
- package/dist/components/Sidebar/SidebarItem/SidebarItem.js.map +1 -0
- package/dist/components/Sidebar/SidebarItemsGroup/SidebarItemsGroup.js +29 -0
- package/dist/components/Sidebar/SidebarItemsGroup/SidebarItemsGroup.js.map +1 -0
- package/dist/components/Sidebar/SidebarWrapper/SidebarWrapper.d.ts.map +1 -1
- package/dist/components/Sidebar/SidebarWrapper/SidebarWrapper.js +35 -0
- package/dist/components/Sidebar/SidebarWrapper/SidebarWrapper.js.map +1 -0
- package/dist/components/Skeleton/Skeleton.js +84 -0
- package/dist/components/Skeleton/Skeleton.js.map +1 -0
- package/dist/components/Spinner/Spinner.js +33 -0
- package/dist/components/Spinner/Spinner.js.map +1 -0
- package/dist/components/Table/Table.js +53 -0
- package/dist/components/Table/Table.js.map +1 -0
- package/dist/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/components/Tabs/Tabs.js +104 -0
- package/dist/components/Tabs/Tabs.js.map +1 -0
- package/dist/components/ThemeProvider/ThemeProvider.d.ts +6 -0
- package/dist/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/components/ThemeProvider/ThemeProvider.js +52 -0
- package/dist/components/ThemeProvider/ThemeProvider.js.map +1 -0
- package/dist/components/Toast/ToastItem/ToastItem.js +47 -0
- package/dist/components/Toast/ToastItem/ToastItem.js.map +1 -0
- package/dist/components/Toast/ToastsProvider/ToastsProvider.js +45 -0
- package/dist/components/Toast/ToastsProvider/ToastsProvider.js.map +1 -0
- package/dist/components/Toast/ToastsWrapper/ToastsWrapper.d.ts.map +1 -1
- package/dist/components/Toast/ToastsWrapper/ToastsWrapper.js +28 -0
- package/dist/components/Toast/ToastsWrapper/ToastsWrapper.js.map +1 -0
- package/dist/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/Tooltip/Tooltip.js +62 -0
- package/dist/components/Tooltip/Tooltip.js.map +1 -0
- package/dist/components/Typography/Heading.js +30 -0
- package/dist/components/Typography/Heading.js.map +1 -0
- package/dist/components/Typography/Text.js +15 -0
- package/dist/components/Typography/Text.js.map +1 -0
- package/dist/components/index.js +124 -75
- package/dist/components/index.js.map +1 -1
- package/dist/fictoan-schema.json +2070 -0
- package/dist/hooks/UseClickOutside.js +17 -0
- package/dist/hooks/UseClickOutside.js.map +1 -0
- package/dist/hooks/UseViewTransition.d.ts +2 -0
- package/dist/hooks/UseViewTransition.d.ts.map +1 -0
- package/dist/hooks/UseViewTransition.js +17 -0
- package/dist/hooks/UseViewTransition.js.map +1 -0
- package/dist/index.css +6 -10661
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +142 -151
- package/dist/index.js.map +1 -1
- package/dist/scripts/generateSchema.d.ts +2 -0
- package/dist/scripts/generateSchema.d.ts.map +1 -0
- package/dist/scripts/schema-meta.d.ts +12 -0
- package/dist/scripts/schema-meta.d.ts.map +1 -0
- package/dist/styles/colours.js +55 -0
- package/dist/styles/colours.js.map +1 -0
- package/dist/utils/classNames.js +6 -0
- package/dist/utils/classNames.js.map +1 -0
- package/dist/utils/propSeparation.js +77 -0
- package/dist/utils/propSeparation.js.map +1 -0
- package/package.json +12 -18
- package/dist/Accordion-CeGNgNW8.js +0 -4254
- package/dist/Accordion-CeGNgNW8.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PinInputField.js","sources":["../../../../src/components/Form/PinInputField/PinInputField.tsx"],"sourcesContent":["// FRAMEWORK ===========================================================================================================\nimport React, { createRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from \"react\";\n\n// FICTOAN =============================================================================================================\nimport { InputField } from \"../InputField/InputField\";\nimport { FormItem, deriveAriaIds } from \"../FormItem/FormItem\";\nimport { Div } from \"../../Element/Tags\";\n\n// STYLES ==============================================================================================================\nimport \"./pin-input-field.css\";\n\n// TYPES ===============================================================================================================\nimport { CommonAndHTMLProps, SpacingTypes } from \"../../Element/constants\";\n\ninterface PinInputFieldHandle extends HTMLDivElement {\n reset: () => void;\n}\n\n// prettier-ignore\ntype PinInputFieldCustomProps = {\n numberOfFields : number;\n onChange ? : (value: string) => void;\n type ? : \"alphanumeric\" | \"number\";\n mask ? : boolean;\n isOTP ? : boolean;\n autoFocus ? : boolean;\n pasteFromClipboard ? : \"enabled\" | \"disabled\";\n focusFirstInputOnReset ? : boolean;\n isFullWidth ? : boolean;\n ariaLabel ? : string;\n // FormItem integration\n label ? : string;\n helpText ? : string | React.ReactNode;\n errorText ? : string;\n required ? : boolean;\n size ? : Exclude<SpacingTypes, \"nano\" | \"huge\">;\n};\n\nexport type PinInputFieldElementType = HTMLDivElement & { reset: () => void };\nexport type PinInputFieldProps = Omit<CommonAndHTMLProps<PinInputFieldElementType>, keyof PinInputFieldCustomProps> &\n PinInputFieldCustomProps;\n\n// UTILITIES ///////////////////////////////////////////////////////////////////////////////////////////////////////////\nfunction validate(value: string, type: \"alphanumeric\" | \"number\") {\n const NUMERIC_REGEX = /^[0-9]+$/;\n const ALPHA_NUMERIC_REGEX = /^[a-zA-Z0-9]+$/i;\n const regex = type === \"alphanumeric\" ? ALPHA_NUMERIC_REGEX : NUMERIC_REGEX;\n return regex.test(value);\n}\n\n// COMPONENT ///////////////////////////////////////////////////////////////////////////////////////////////////////////\nexport const PinInputField = React.forwardRef(\n (\n {\n numberOfFields: length,\n onChange,\n type = \"number\",\n mask = false,\n isOTP = false,\n autoFocus = false,\n pasteFromClipboard = \"enabled\",\n focusFirstInputOnReset = true,\n isFullWidth,\n ariaLabel,\n // FormItem integration\n label,\n helpText,\n errorText,\n required,\n size,\n ...props\n }: PinInputFieldProps,\n ref: React.Ref<PinInputFieldElementType>\n ) => {\n // REFS =====================================================================================================\n const pinInputFieldRef = useRef<PinInputFieldElementType>(null);\n const [inputRefs, setInputRefs] = useState<React.RefObject<HTMLInputElement>[]>([]);\n\n // STATES ===================================================================================================\n const [values, setValues] = useState<string[]>([]);\n const [moveFocus, setMoveFocus] = useState<boolean>(true);\n const [focusedIndex, setFocusedIndex] = useState<number>(-1);\n\n // CONSTANTS ================================================================================================\n const reactId = React.useId();\n const inputGroupId = props.id || `pin-input-${reactId.replace(/:/g, \"\")}`;\n const inputDescription = ariaLabel || label || \"Enter verification code\";\n const { describedBy } = deriveAriaIds(inputGroupId, helpText, errorText);\n\n // HANDLERS =================================================================================================\n const focus = useCallback(\n (index: number) => {\n const ref = inputRefs[index];\n ref?.current?.focus();\n },\n [inputRefs]\n );\n\n const focusNext = useCallback(\n (index: number) => {\n if (!moveFocus) return;\n const next = index + 1 < length ? index + 1 : null;\n if (next) {\n focus(next);\n }\n },\n [focus, length, moveFocus]\n );\n\n const handleResetPinInput = useCallback(() => {\n setValues(Array(length).fill(\"\"));\n onChange?.(\"\"); // Clear the complete value\n if (focusFirstInputOnReset) {\n focus(0);\n setFocusedIndex(0);\n }\n }, [length, onChange, focus, focusFirstInputOnReset]);\n\n // VALUE HANDLING ==============================================================================================\n const setValue = useCallback(\n (value: string, index: number) => {\n const nextValues = [...values];\n nextValues[index] = value;\n setValues(nextValues);\n\n // Emit complete PIN value\n onChange?.(nextValues.join(\"\"));\n\n const isComplete =\n value !== \"\" &&\n nextValues.length === length &&\n nextValues.every((inputValue) => inputValue != null && inputValue !== \"\") &&\n index === length - 1;\n\n if (!isComplete) {\n setMoveFocus(true);\n focusNext(index);\n }\n },\n [focusNext, length, onChange, values]\n );\n\n // Updated input handler to work with both string values and events\n const handleInputChange = useCallback((inputValue: string | React.FormEvent<HTMLInputElement>, inputFieldIndex: number) => {\n // Extract value whether we get a string or an event\n const value = typeof inputValue === \"string\" ? inputValue : (inputValue.target as HTMLInputElement).value;\n const currentValue = values[inputFieldIndex];\n\n if (value === \"\") {\n setValue(\"\", inputFieldIndex);\n return;\n }\n\n // Rest of the logic remains the same\n if (value.length > 1 && inputFieldIndex < length - 1) {\n if (validate(value, type)) {\n let nextValue: string[] = [];\n const chars = value.split(\"\");\n\n if (currentValue === \"\") {\n nextValue = chars.filter((_, j) => inputFieldIndex + j < length);\n } else {\n const isAppending = inputRefs[inputFieldIndex].current?.selectionEnd === value.length;\n if (isAppending) {\n nextValue = chars.filter((_, j) => j > 0 && inputFieldIndex + j - 1 < length);\n } else {\n nextValue = chars.filter((_, j) => j < value.length - 1 && inputFieldIndex + j < length);\n }\n }\n\n const newValues = values.map((v, j) =>\n j >= inputFieldIndex && j < inputFieldIndex + nextValue.length\n ? nextValue[j - inputFieldIndex]\n : v\n );\n\n setValues(newValues);\n onChange?.(newValues.join(\"\"));\n\n const nextFocusIndex = Math.min(inputFieldIndex + nextValue.length, length - 1);\n focus(nextFocusIndex);\n }\n } else {\n let nextValue = value;\n if (currentValue?.length > 0) {\n nextValue = value.charAt(value.length - 1);\n }\n if (validate(nextValue, type)) {\n setValue(nextValue, inputFieldIndex);\n }\n }\n }, [length, onChange, setValue, type, values, focus, inputRefs]);\n\n const handleKeyDown = useCallback((event: React.KeyboardEvent<HTMLInputElement>, i: number) => {\n if (event.key === \"Backspace\") {\n if ((event.target as HTMLInputElement).value === \"\") {\n if (i > 0) {\n const newIndex = i - 1;\n setValue(\"\", newIndex);\n focus(newIndex);\n setMoveFocus(true);\n }\n } else {\n setMoveFocus(false);\n }\n } else if (event.key === \"Escape\") {\n inputRefs[i].current?.blur();\n handleBlur();\n } else if (event.key === \"ArrowRight\") {\n if (i < length - 1) {\n focus(i + 1);\n }\n } else if (event.key === \"ArrowLeft\") {\n if (i > 0) {\n focus(i - 1);\n }\n }\n }, [focus, setValue, inputRefs, length]);\n\n // EVENT HANDLERS ==============================================================================================\n // Updated focus handler to work with event type\n const handleFocus = useCallback((e: React.FocusEvent<HTMLInputElement> | undefined, i: number) => {\n setFocusedIndex(i);\n }, []);\n\n // When moving around the InputElements using tab key, browsers automatically select\n // the value (if it exists) in the InputElement - which we want to disable. Additionally,\n // when an existing value is selected/highlighted and pasted over, there is no way to\n // clearly distinguish between the other 2 scenarios of pasting by keeping the cursor before\n // and after the existing value. Specific example: If the existing value is 5, the event\n // when highlighting and pasting '567' is the same as placing the cursor before the existing\n // value and pasting '67'. By disabling this, we eliminate one of these cases.\n // Is this a hack? Yes. Is there a better way? IDK. Does it matter? Not unless there is a\n // valid reason for users to need selecting a single InputElement within a PinInput.\n const handleSelect = useCallback((e: React.SyntheticEvent<HTMLInputElement, Event>) => {\n const target = e.target as HTMLInputElement;\n setTimeout(() => {\n target.setSelectionRange(target.value.length, target.value.length);\n }, 0);\n }, []);\n\n const handleBlur = useCallback(() => {\n setFocusedIndex(-1);\n }, []);\n\n // EFFECTS =====================================================================================================\n useEffect(() => {\n setInputRefs((inputRefs) => {\n const refs = Array(length)\n .fill(0)\n .map((_, i) => {\n const ref = inputRefs[i] || createRef();\n if (autoFocus && i === 0) {\n ref.current?.focus();\n }\n return ref;\n });\n return refs;\n });\n }, [length, autoFocus]);\n\n useImperativeHandle(\n ref,\n () => ({\n ...(pinInputFieldRef.current as HTMLDivElement),\n reset: handleResetPinInput\n }) as PinInputFieldHandle,\n [handleResetPinInput]\n );\n\n // RENDER ==================================================================================================\n let classNames: string[] = [];\n\n if (isFullWidth) {\n classNames.push(\"full-width\");\n }\n\n return (\n <FormItem\n label={label}\n htmlFor={inputGroupId}\n helpText={helpText}\n errorText={errorText}\n required={required}\n size={size}\n >\n <Div\n data-pin-input-field\n ref={pinInputFieldRef}\n id={inputGroupId}\n classNames={isFullWidth ? [\"full-width\"] : []}\n role=\"group\"\n aria-label={label ? undefined : inputDescription}\n aria-invalid={Boolean(errorText) || undefined}\n aria-required={required}\n aria-describedby={describedBy}\n {...props}\n >\n {Array.from({ length }, (_, i) => (\n <InputField\n key={i}\n id={`${inputGroupId}-${i}`}\n ref={inputRefs[i]}\n type={mask ? \"password\" : type === \"number\" ? \"tel\" : \"text\"}\n inputMode={type === \"number\" ? \"numeric\" : \"text\"}\n onChange={(value: string | React.FormEvent<HTMLInputElement>) => handleInputChange(value, i)}\n onKeyDown={(e) => handleKeyDown(e, i)}\n onFocus={(e) => handleFocus(e as React.FocusEvent<HTMLInputElement>, i)}\n onSelect={handleSelect}\n onBlur={handleBlur}\n placeholder={focusedIndex !== i ? \"\\u2981\" : undefined}\n autoComplete={isOTP ? \"one-time-code\" : \"off\"}\n value={values[i] || \"\"}\n autoFocus={autoFocus && i === 0}\n onCopy={(e) => pasteFromClipboard === \"disabled\" && e.preventDefault()}\n onPaste={(e) => pasteFromClipboard === \"disabled\" && e.preventDefault()}\n aria-label={`Digit ${i + 1} of ${length}`}\n aria-required={required}\n />\n ))}\n </Div>\n </FormItem>\n );\n }\n);\nPinInputField.displayName = \"PinInputField\";\n"],"names":["validate","value","type","PinInputField","React","length","onChange","mask","isOTP","autoFocus","pasteFromClipboard","focusFirstInputOnReset","isFullWidth","ariaLabel","label","helpText","errorText","required","size","props","ref","pinInputFieldRef","useRef","inputRefs","setInputRefs","useState","values","setValues","moveFocus","setMoveFocus","focusedIndex","setFocusedIndex","reactId","inputGroupId","inputDescription","describedBy","deriveAriaIds","focus","useCallback","index","focusNext","next","handleResetPinInput","setValue","nextValues","inputValue","handleInputChange","inputFieldIndex","currentValue","nextValue","chars","_","j","_a","newValues","v","nextFocusIndex","handleKeyDown","event","i","newIndex","handleBlur","handleFocus","e","handleSelect","target","useEffect","createRef","useImperativeHandle","jsx","FormItem","Div","InputField"],"mappings":";;;;;;AA2CA,SAASA,EAASC,GAAeC,GAAiC;AAI9D,UADcA,MAAS,iBADK,oBADN,YAGT,KAAKD,CAAK;AAC3B;AAGO,MAAME,KAAgBC,EAAM;AAAA,EAC/B,CACI;AAAA,IACI,gBAAgBC;AAAA,IAChB,UAAAC;AAAA,IACA,MAAAJ,IAAO;AAAA,IACP,MAAAK,IAAO;AAAA,IACP,OAAAC,IAAQ;AAAA,IACR,WAAAC,IAAY;AAAA,IACZ,oBAAAC,IAAqB;AAAA,IACrB,wBAAAC,IAAyB;AAAA,IACzB,aAAAC;AAAA,IACA,WAAAC;AAAA;AAAA,IAEA,OAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAAC;AAAA,IACA,MAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAEPC,MACC;AAED,UAAMC,IAAmBC,GAAiC,IAAI,GACxD,CAACC,GAAWC,CAAY,IAAIC,EAA8C,CAAA,CAAE,GAG5E,CAACC,GAAQC,CAAS,IAAIF,EAAmB,CAAA,CAAE,GAC3C,CAACG,GAAWC,CAAY,IAAIJ,EAAkB,EAAI,GAClD,CAACK,GAAcC,CAAe,IAAIN,EAAiB,EAAE,GAGrDO,IAAU5B,EAAM,MAAA,GAChB6B,IAAed,EAAM,MAAM,aAAaa,EAAQ,QAAQ,MAAM,EAAE,CAAC,IACjEE,IAAmBrB,KAAaC,KAAS,2BACzC,EAAE,aAAAqB,EAAA,IAAgBC,GAAcH,GAAclB,GAAUC,CAA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WAAWlD,KAAakD,MAAM;AAAA,gBAC9B,QAAQ,CAACI,MAAMrD,MAAuB,cAAcqD,EAAE,eAAA;AAAA,gBACtD,SAAS,CAACA,MAAMrD,MAAuB,cAAcqD,EAAE,eAAA;AAAA,gBACvD,cAAY,SAASJ,IAAI,CAAC,OAAOtD,CAAM;AAAA,gBACvC,iBAAeY;AAAA,cAAA;AAAA,cAjBV0C;AAAA,YAAA,CAmBZ;AAAA,UAAA;AAAA,QAAA;AAAA,MACL;AAAA,IAAA;AAAA,EAGZ;AACJ;AACAxD,GAAc,cAAc;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioButton.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/RadioButton/RadioButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAQvC,OAAO,oBAAoB,CAAC;AAM5B,eAAO,MAAM,WAAW;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"RadioButton.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/RadioButton/RadioButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAQvC,OAAO,oBAAoB,CAAC;AAM5B,eAAO,MAAM,WAAW;;;;;;;;;;;wCA6EvB,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as d, jsxs as P } from "react/jsx-runtime";
|
|
3
|
+
import f, { useMemo as j } from "react";
|
|
4
|
+
import { deriveAriaIds as w, FormItem as k } from "../FormItem/FormItem.js";
|
|
5
|
+
import { separateWrapperProps as A } from "../../../utils/propSeparation.js";
|
|
6
|
+
/* empty css */
|
|
7
|
+
import { Element as e } from "../../Element/Element.js";
|
|
8
|
+
const C = f.forwardRef(
|
|
9
|
+
({
|
|
10
|
+
id: r,
|
|
11
|
+
name: s,
|
|
12
|
+
value: n,
|
|
13
|
+
label: l,
|
|
14
|
+
helpText: m,
|
|
15
|
+
errorText: t,
|
|
16
|
+
onChange: p,
|
|
17
|
+
checked: u,
|
|
18
|
+
disabled: c,
|
|
19
|
+
required: i,
|
|
20
|
+
labelFirst: a,
|
|
21
|
+
...v
|
|
22
|
+
}, h) => {
|
|
23
|
+
const I = j(() => s || r, [s, r]), y = (N) => {
|
|
24
|
+
N.target.checked && p && p(n);
|
|
25
|
+
}, { wrapperProps: B, inputProps: R } = A(v), b = f.useId(), o = r || `radio-${b.replace(/:/g, "")}`, { describedBy: g } = w(o, m, t);
|
|
26
|
+
return /* @__PURE__ */ d(
|
|
27
|
+
e,
|
|
28
|
+
{
|
|
29
|
+
as: "div",
|
|
30
|
+
"data-radio-button": !0,
|
|
31
|
+
ref: h,
|
|
32
|
+
"aria-disabled": c,
|
|
33
|
+
className: a ? "label-first" : void 0,
|
|
34
|
+
...B,
|
|
35
|
+
children: /* @__PURE__ */ P(
|
|
36
|
+
k,
|
|
37
|
+
{
|
|
38
|
+
label: l,
|
|
39
|
+
htmlFor: o,
|
|
40
|
+
helpText: m,
|
|
41
|
+
errorText: t,
|
|
42
|
+
required: i,
|
|
43
|
+
labelFirst: a,
|
|
44
|
+
children: [
|
|
45
|
+
/* @__PURE__ */ d(
|
|
46
|
+
e,
|
|
47
|
+
{
|
|
48
|
+
as: "input",
|
|
49
|
+
type: "radio",
|
|
50
|
+
id: o,
|
|
51
|
+
name: I,
|
|
52
|
+
value: n,
|
|
53
|
+
checked: u,
|
|
54
|
+
disabled: c,
|
|
55
|
+
required: i,
|
|
56
|
+
"aria-invalid": !!t || void 0,
|
|
57
|
+
"aria-required": i,
|
|
58
|
+
"aria-describedby": g,
|
|
59
|
+
onChange: y,
|
|
60
|
+
...R
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
/* @__PURE__ */ d(
|
|
64
|
+
e,
|
|
65
|
+
{
|
|
66
|
+
as: a ? "label" : "div",
|
|
67
|
+
htmlFor: a ? o : void 0,
|
|
68
|
+
"data-radio": !0
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
C.displayName = "RadioButton";
|
|
79
|
+
export {
|
|
80
|
+
C as RadioButton
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=RadioButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton.js","sources":["../../../../src/components/Form/RadioButton/RadioButton.tsx"],"sourcesContent":["// REACT CORE ==========================================================================================================\nimport React, { useMemo } from \"react\";\n\n// LOCAL COMPONENTS ====================================================================================================\nimport { Element } from \"$element\";\nimport { FormItem, deriveAriaIds } from \"../FormItem/FormItem\";\nimport { separateWrapperProps } from \"../../../utils/propSeparation\";\n\n// STYLES ==============================================================================================================\nimport \"./radio-button.css\";\n\n// OTHER ===============================================================================================================\nimport { RadioButtonProps, RadioButtonElementType } from \"./constants\";\n\n// COMPONENT ///////////////////////////////////////////////////////////////////////////////////////////////////////////\nexport const RadioButton = React.forwardRef(\n (\n {\n id,\n name,\n value,\n label,\n helpText,\n errorText,\n onChange,\n checked,\n disabled,\n required,\n labelFirst,\n ...props\n }: RadioButtonProps,\n ref: React.Ref<RadioButtonElementType>\n ) => {\n const derivedName = useMemo(() => name || id, [name, id]);\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (e.target.checked && onChange) {\n onChange(value);\n }\n };\n\n // Separate wrapper-level props (margin, padding, etc.) from input-specific props\n const { wrapperProps, inputProps } = separateWrapperProps(props);\n\n const reactId = React.useId();\n const finalId = id || `radio-${reactId.replace(/:/g, \"\")}`;\n const { describedBy } = deriveAriaIds(finalId, helpText, errorText);\n\n // The native <input type=\"radio\"> below already has role=\"radio\". The\n // wrapper div used to duplicate that role, which made AT announce two\n // radios per RadioButton — left as a plain wrapper now.\n return (\n <Element<RadioButtonElementType>\n as=\"div\"\n data-radio-button\n ref={ref}\n aria-disabled={disabled}\n className={labelFirst ? \"label-first\" : undefined}\n {...wrapperProps}\n >\n <FormItem\n label={label}\n htmlFor={finalId}\n helpText={helpText}\n errorText={errorText}\n required={required}\n labelFirst={labelFirst}\n >\n <Element\n as=\"input\"\n type=\"radio\"\n id={finalId}\n name={derivedName}\n value={value}\n checked={checked}\n disabled={disabled}\n required={required}\n aria-invalid={Boolean(errorText) || undefined}\n aria-required={required}\n aria-describedby={describedBy}\n onChange={handleChange}\n {...inputProps}\n />\n <Element\n as={labelFirst ? \"label\" : \"div\"}\n htmlFor={labelFirst ? finalId : undefined}\n data-radio\n />\n </FormItem>\n </Element>\n );\n }\n);\nRadioButton.displayName = \"RadioButton\";\n"],"names":["RadioButton","React","id","name","value","label","helpText","errorText","onChange","checked","disabled","required","labelFirst","props","ref","derivedName","useMemo","handleChange","e","wrapperProps","inputProps","separateWrapperProps","reactId","finalId","describedBy","deriveAriaIds","jsx","Element","jsxs","FormItem"],"mappings":";;;;;;AAeO,MAAMA,IAAcC,EAAM;AAAA,EAC7B,CACI;AAAA,IACI,IAAAC;AAAA,IACA,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,OAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAAC;AAAA,IACA,SAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,YAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAEPC,MACC;AACD,UAAMC,IAAcC,EAAQ,MAAMb,KAAQD,GAAI,CAACC,GAAMD,CAAE,CAAC,GAElDe,IAAe,CAACC,MAA2C;AAC7D,MAAIA,EAAE,OAAO,WAAWV,KACpBA,EAASJ,CAAK;AAAA,IAEtB,GAGM,EAAE,cAAAe,GAAc,YAAAC,MAAeC,EAAqBR,CAAK,GAEzDS,IAAUrB,EAAM,MAAA,GAChBsB,IAAUrB,KAAM,SAASoB,EAAQ,QAAQ,MAAM,EAAE,CAAC,IAClD,EAAE,aAAAE,EAAA,IAAgBC,EAAcF,GAASjB,GAAUC,CAAS;AAKlE,WACI,gBAAAmB;AAAA,MAACC;AAAA,MAAA;AAAA,QACG,IAAG;AAAA,QACH,qBAAiB;AAAA,QACjB,KAAAb;AAAA,QACA,iBAAeJ;AAAA,QACf,WAAWE,IAAa,gBAAgB;AAAA,QACvC,GAAGO;AAAA,QAEJ,UAAA,gBAAAS;AAAA,UAACC;AAAA,UAAA;AAAA,YACG,OAAAxB;AAAA,YACA,SAASkB;AAAA,YACT,UAAAjB;AAAA,YACA,WAAAC;AAAA,YACA,UAAAI;AAAA,YACA,YAAAC;AAAA,YAEA,UAAA;AAAA,cAAA,gBAAAc;AAAA,gBAACC;AAAA,gBAAA;AAAA,kBACG,IAAG;AAAA,kBACH,MAAK;AAAA,kBACL,IAAIJ;AAAA,kBACJ,MAAMR;AAAA,kBACN,OAAAX;AAAA,kBACA,SAAAK;AAAA,kBACA,UAAAC;AAAA,kBACA,UAAAC;AAAA,kBACA,gBAAc,EAAQJ,KAAc;AAAA,kBACpC,iBAAeI;AAAA,kBACf,oBAAkBa;AAAA,kBAClB,UAAUP;AAAA,kBACT,GAAGG;AAAA,gBAAA;AAAA,cAAA;AAAA,cAER,gBAAAM;AAAA,gBAACC;AAAA,gBAAA;AAAA,kBACG,IAAIf,IAAa,UAAU;AAAA,kBAC3B,SAASA,IAAaW,IAAU;AAAA,kBAChC,cAAU;AAAA,gBAAA;AAAA,cAAA;AAAA,YACd;AAAA,UAAA;AAAA,QAAA;AAAA,MACJ;AAAA,IAAA;AAAA,EAGZ;AACJ;AACAvB,EAAY,cAAc;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/RadioButton/RadioGroup.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAQvC,OAAO,mBAAmB,CAAC;AAM3B,eAAO,MAAM,UAAU;;;;
|
|
1
|
+
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/RadioButton/RadioGroup.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAQvC,OAAO,mBAAmB,CAAC;AAM3B,eAAO,MAAM,UAAU;;;;wCA6GtB,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as i, jsxs as L } from "react/jsx-runtime";
|
|
3
|
+
import b, { useMemo as M } from "react";
|
|
4
|
+
import { Div as I } from "../../Element/Tags.js";
|
|
5
|
+
import { deriveAriaIds as P, FormItem as V } from "../FormItem/FormItem.js";
|
|
6
|
+
/* empty css */
|
|
7
|
+
import { Element as x } from "../../Element/Element.js";
|
|
8
|
+
const z = b.forwardRef(
|
|
9
|
+
({
|
|
10
|
+
id: e,
|
|
11
|
+
name: u,
|
|
12
|
+
label: c,
|
|
13
|
+
helpText: n,
|
|
14
|
+
errorText: t,
|
|
15
|
+
options: y,
|
|
16
|
+
value: f,
|
|
17
|
+
defaultValue: $,
|
|
18
|
+
onChange: d,
|
|
19
|
+
align: h,
|
|
20
|
+
equaliseWidth: g,
|
|
21
|
+
equalizeWidth: N,
|
|
22
|
+
required: v,
|
|
23
|
+
disabled: R,
|
|
24
|
+
size: k,
|
|
25
|
+
columns: s,
|
|
26
|
+
labelFirst: l,
|
|
27
|
+
...w
|
|
28
|
+
}, G) => {
|
|
29
|
+
const j = M(() => u || e, [u, e]), B = (p) => {
|
|
30
|
+
d == null || d(p.target.value);
|
|
31
|
+
};
|
|
32
|
+
let o = [];
|
|
33
|
+
h && o.push(`align-${h}`), (g || N) && o.push("equalise-width"), s && o.push("with-columns"), l && o.push("label-first");
|
|
34
|
+
const F = b.useId(), r = e || `radio-group-${F.replace(/:/g, "")}`, { describedBy: q } = P(r, n, t);
|
|
35
|
+
return /* @__PURE__ */ i(
|
|
36
|
+
V,
|
|
37
|
+
{
|
|
38
|
+
label: c,
|
|
39
|
+
htmlFor: r,
|
|
40
|
+
helpText: n,
|
|
41
|
+
errorText: t,
|
|
42
|
+
required: v,
|
|
43
|
+
size: k,
|
|
44
|
+
children: /* @__PURE__ */ i(
|
|
45
|
+
x,
|
|
46
|
+
{
|
|
47
|
+
as: "div",
|
|
48
|
+
"data-radio-group": !0,
|
|
49
|
+
ref: G,
|
|
50
|
+
id: r,
|
|
51
|
+
classNames: o,
|
|
52
|
+
role: "radiogroup",
|
|
53
|
+
"aria-label": c,
|
|
54
|
+
"aria-invalid": !!t || void 0,
|
|
55
|
+
"aria-required": v,
|
|
56
|
+
"aria-describedby": q,
|
|
57
|
+
style: s ? { gridTemplateColumns: `repeat(${s}, 1fr)` } : void 0,
|
|
58
|
+
...w,
|
|
59
|
+
children: y.map((p, A) => {
|
|
60
|
+
const { id: C, value: m, label: D, ...E } = p, a = C || `${r}-option-${A}`;
|
|
61
|
+
return /* @__PURE__ */ L(
|
|
62
|
+
I,
|
|
63
|
+
{
|
|
64
|
+
"data-radio-button": !0,
|
|
65
|
+
className: l ? "label-first" : void 0,
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ i(
|
|
68
|
+
"input",
|
|
69
|
+
{
|
|
70
|
+
type: "radio",
|
|
71
|
+
id: a,
|
|
72
|
+
name: j,
|
|
73
|
+
value: m,
|
|
74
|
+
checked: f ? f === m : $ === m,
|
|
75
|
+
disabled: R,
|
|
76
|
+
onChange: B,
|
|
77
|
+
...E
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
/* @__PURE__ */ i("label", { htmlFor: a, children: D }),
|
|
81
|
+
l ? /* @__PURE__ */ i("label", { htmlFor: a, "data-radio": !0 }) : /* @__PURE__ */ i(I, { "data-radio": !0 })
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
a
|
|
85
|
+
);
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
z.displayName = "RadioGroup";
|
|
94
|
+
export {
|
|
95
|
+
z as RadioGroup
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=RadioGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioGroup.js","sources":["../../../../src/components/Form/RadioButton/RadioGroup.tsx"],"sourcesContent":["// REACT CORE ==========================================================================================================\nimport React, { useMemo } from \"react\";\n\n// LOCAL COMPONENTS ====================================================================================================\nimport { Div } from \"../../Element/Tags\";\nimport { Element } from \"$element\";\nimport { FormItem, deriveAriaIds } from \"../FormItem/FormItem\";\n\n// STYLES ==============================================================================================================\nimport \"./radio-group.css\";\n\n// TYPES ===============================================================================================================\nimport { RadioGroupProps } from \"./constants\";\n\n// COMPONENT ///////////////////////////////////////////////////////////////////////////////////////////////////////////\nexport const RadioGroup = React.forwardRef(\n (\n {\n id,\n name,\n label,\n helpText,\n errorText,\n options,\n value,\n defaultValue,\n onChange,\n align,\n equaliseWidth,\n equalizeWidth,\n required,\n disabled,\n size,\n columns,\n labelFirst,\n ...props\n }: RadioGroupProps,\n ref: React.Ref<HTMLDivElement>\n ) => {\n const derivedName = useMemo(() => name || id, [name, id]);\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(e.target.value);\n };\n\n let classNames: string[] = [];\n\n if (align) {\n classNames.push(`align-${align}`);\n }\n\n if (equaliseWidth || equalizeWidth) {\n classNames.push(`equalise-width`);\n }\n\n if (columns) {\n classNames.push(`with-columns`);\n }\n\n if (labelFirst) {\n classNames.push(`label-first`);\n }\n\n const reactId = React.useId();\n const finalGroupId = id || `radio-group-${reactId.replace(/:/g, \"\")}`;\n const { describedBy } = deriveAriaIds(finalGroupId, helpText, errorText);\n\n return (\n <FormItem\n label={label}\n htmlFor={finalGroupId}\n helpText={helpText}\n errorText={errorText}\n required={required}\n size={size}\n >\n <Element\n as=\"div\"\n data-radio-group\n ref={ref}\n id={finalGroupId}\n classNames={classNames}\n role=\"radiogroup\"\n aria-label={label}\n aria-invalid={Boolean(errorText) || undefined}\n aria-required={required}\n aria-describedby={describedBy}\n style={columns ? { gridTemplateColumns: `repeat(${columns}, 1fr)` } : undefined}\n {...props}\n >\n {options.map((option, index) => {\n const { id: optionId, value: optionValue, label: optionLabel, ...optionProps } = option;\n const finalId = optionId || `${finalGroupId}-option-${index}`;\n const isChecked = value ? value === optionValue : defaultValue === optionValue;\n\n return (\n <Div\n key={finalId}\n data-radio-button\n className={labelFirst ? \"label-first\" : undefined}\n >\n <input\n type=\"radio\"\n id={finalId}\n name={derivedName}\n value={optionValue}\n checked={isChecked}\n disabled={disabled}\n onChange={handleChange}\n {...optionProps}\n />\n <label htmlFor={finalId}>{optionLabel}</label>\n {labelFirst ? (\n <label htmlFor={finalId} data-radio />\n ) : (\n <Div data-radio />\n )}\n </Div>\n );\n })}\n </Element>\n </FormItem>\n );\n }\n);\nRadioGroup.displayName = \"RadioGroup\";\n"],"names":["RadioGroup","React","id","name","label","helpText","errorText","options","value","defaultValue","onChange","align","equaliseWidth","equalizeWidth","required","disabled","size","columns","labelFirst","props","ref","derivedName","useMemo","handleChange","e","classNames","reactId","finalGroupId","describedBy","deriveAriaIds","jsx","FormItem","Element","option","index","optionId","optionValue","optionLabel","optionProps","finalId","jsxs","Div"],"mappings":";;;;;;AAeO,MAAMA,IAAaC,EAAM;AAAA,EAC5B,CACI;AAAA,IACI,IAAAC;AAAA,IACA,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,OAAAC;AAAA,IACA,cAAAC;AAAA,IACA,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,eAAAC;AAAA,IACA,eAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,MAAAC;AAAA,IACA,SAAAC;AAAA,IACA,YAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAEPC,MACC;AACD,UAAMC,IAAcC,EAAQ,MAAMnB,KAAQD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IAAa,gBAAgB;AAAA,kBAExC,UAAA;AAAA,oBAAA,gBAAAY;AAAA,sBAAC;AAAA,sBAAA;AAAA,wBACG,MAAK;AAAA,wBACL,IAAIS;AAAA,wBACJ,MAAMlB;AAAA,wBACN,OAAOe;AAAA,wBACP,SAbM5B,IAAQA,MAAU4B,IAAc3B,MAAiB2B;AAAA,wBAcvD,UAAArB;AAAA,wBACA,UAAUQ;AAAA,wBACT,GAAGe;AAAA,sBAAA;AAAA,oBAAA;AAAA,oBAER,gBAAAR,EAAC,SAAA,EAAM,SAASS,GAAU,UAAAF,GAAY;AAAA,oBACrCnB,IACG,gBAAAY,EAAC,SAAA,EAAM,SAASS,GAAS,cAAU,GAAA,CAAC,IAEpC,gBAAAT,EAACW,GAAA,EAAI,cAAU,GAAA,CAAC;AAAA,kBAAA;AAAA,gBAAA;AAAA,gBAlBfF;AAAA,cAAA;AAAA,YAsBjB,CAAC;AAAA,UAAA;AAAA,QAAA;AAAA,MACL;AAAA,IAAA;AAAA,EAGZ;AACJ;AACAvC,EAAW,cAAc;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioTabGroup.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/RadioButton/RadioTabGroup.tsx"],"names":[],"mappings":"AACA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAUjF,OAAO,uBAAuB,CAAC;AAW/B,eAAO,MAAM,aAAa;;
|
|
1
|
+
{"version":3,"file":"RadioTabGroup.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/RadioButton/RadioTabGroup.tsx"],"names":[],"mappings":"AACA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAUjF,OAAO,uBAAuB,CAAC;AAW/B,eAAO,MAAM,aAAa;;wCA0OzB,CAAC"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as s, jsxs as d } from "react/jsx-runtime";
|
|
3
|
+
import y, { useMemo as Y, useRef as M, useState as p, useCallback as X, useEffect as q } from "react";
|
|
4
|
+
import { Div as c } from "../../Element/Tags.js";
|
|
5
|
+
import { deriveAriaIds as Z, FormItem as _ } from "../FormItem/FormItem.js";
|
|
6
|
+
import { separateWrapperProps as tt } from "../../../utils/propSeparation.js";
|
|
7
|
+
/* empty css */
|
|
8
|
+
import { Element as et } from "../../Element/Element.js";
|
|
9
|
+
const rt = y.forwardRef(
|
|
10
|
+
({
|
|
11
|
+
id: u,
|
|
12
|
+
name: S,
|
|
13
|
+
label: x,
|
|
14
|
+
helpText: N,
|
|
15
|
+
errorText: m,
|
|
16
|
+
options: f,
|
|
17
|
+
defaultValue: ot,
|
|
18
|
+
value: h,
|
|
19
|
+
required: P,
|
|
20
|
+
onChange: b,
|
|
21
|
+
size: v = "medium",
|
|
22
|
+
bgColour: st,
|
|
23
|
+
disabled: C,
|
|
24
|
+
...G
|
|
25
|
+
}, j) => {
|
|
26
|
+
const R = Y(() => S || u, [S, u]), i = M(null), [F, E] = p({
|
|
27
|
+
width: 0,
|
|
28
|
+
transform: "translateX(0)"
|
|
29
|
+
}), [$, T] = p(!1), [a, D] = p(0), [w, L] = p(0), g = M([]), W = X(() => {
|
|
30
|
+
if (!i.current) return;
|
|
31
|
+
const t = i.current, e = t.closest("[data-input-wrapper]");
|
|
32
|
+
if (t && e) {
|
|
33
|
+
const o = t.scrollWidth, n = e.clientWidth, r = o > n;
|
|
34
|
+
T(r), L(r ? o - n : 0);
|
|
35
|
+
}
|
|
36
|
+
}, []);
|
|
37
|
+
q(() => {
|
|
38
|
+
const t = i.current;
|
|
39
|
+
if (!t) return;
|
|
40
|
+
W();
|
|
41
|
+
const e = new ResizeObserver(() => {
|
|
42
|
+
W();
|
|
43
|
+
});
|
|
44
|
+
return e.observe(t), t.closest("[data-input-wrapper]") && e.observe(t.closest("[data-input-wrapper]")), () => e.disconnect();
|
|
45
|
+
}, [W]), q(() => {
|
|
46
|
+
const t = f.findIndex((e) => e.value === h);
|
|
47
|
+
if (t >= 0) {
|
|
48
|
+
const e = () => {
|
|
49
|
+
const o = g.current[t];
|
|
50
|
+
if (o) {
|
|
51
|
+
const n = o.offsetWidth;
|
|
52
|
+
let r = "translateX(0)";
|
|
53
|
+
t > 0 && (r = `translateX(${g.current.slice(0, t).reduce((U, I) => U + ((I == null ? void 0 : I.offsetWidth) || 0), 0)}px)`), E({ width: n, transform: r });
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
if (document.fonts && document.fonts.ready)
|
|
57
|
+
document.fonts.ready.then(() => {
|
|
58
|
+
requestAnimationFrame(() => {
|
|
59
|
+
requestAnimationFrame(e);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
else {
|
|
63
|
+
const o = setTimeout(e, 100);
|
|
64
|
+
return () => clearTimeout(o);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}, [h, f]);
|
|
68
|
+
const O = (t) => {
|
|
69
|
+
b == null || b(t.target.value);
|
|
70
|
+
}, { wrapperProps: V, inputProps: z } = tt(G), A = X((t) => {
|
|
71
|
+
const e = i.current;
|
|
72
|
+
if (!e) return;
|
|
73
|
+
const n = e.clientWidth * 0.8;
|
|
74
|
+
let r = t === "right" ? Math.min(a + n, w) : Math.max(a - n, 0);
|
|
75
|
+
D(r), requestAnimationFrame(() => {
|
|
76
|
+
e.style.transform = `translateX(-${r}px)`;
|
|
77
|
+
});
|
|
78
|
+
}, [a, w]), H = a > 0, J = a < w, k = [];
|
|
79
|
+
v && k.push(`size-${v}`);
|
|
80
|
+
const K = y.useId(), l = u || `radio-tab-group-${K.replace(/:/g, "")}`, { describedBy: Q } = Z(l, N, m);
|
|
81
|
+
return /* @__PURE__ */ s(
|
|
82
|
+
_,
|
|
83
|
+
{
|
|
84
|
+
label: x,
|
|
85
|
+
htmlFor: l,
|
|
86
|
+
helpText: N,
|
|
87
|
+
errorText: m,
|
|
88
|
+
required: P,
|
|
89
|
+
size: v,
|
|
90
|
+
...V,
|
|
91
|
+
children: /* @__PURE__ */ d(
|
|
92
|
+
et,
|
|
93
|
+
{
|
|
94
|
+
as: "div",
|
|
95
|
+
"data-radio-tab-group": !0,
|
|
96
|
+
ref: j,
|
|
97
|
+
id: l,
|
|
98
|
+
classNames: k,
|
|
99
|
+
name: R,
|
|
100
|
+
role: "radiogroup",
|
|
101
|
+
"aria-label": x,
|
|
102
|
+
"aria-invalid": !!m || void 0,
|
|
103
|
+
"aria-required": P,
|
|
104
|
+
"aria-describedby": Q,
|
|
105
|
+
...z,
|
|
106
|
+
children: [
|
|
107
|
+
$ && H && /* @__PURE__ */ s(
|
|
108
|
+
c,
|
|
109
|
+
{
|
|
110
|
+
className: "scroll-button left",
|
|
111
|
+
onClick: () => A("left"),
|
|
112
|
+
children: /* @__PURE__ */ s("svg", { viewBox: "0 0 24 24", children: /* @__PURE__ */ s("polyline", { points: "15 18 9 12 15 6" }) })
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
/* @__PURE__ */ d(c, { className: "rtg-options-container", children: [
|
|
116
|
+
/* @__PURE__ */ d(
|
|
117
|
+
c,
|
|
118
|
+
{
|
|
119
|
+
className: "rtg-options-wrapper",
|
|
120
|
+
ref: i,
|
|
121
|
+
children: [
|
|
122
|
+
/* @__PURE__ */ s(
|
|
123
|
+
c,
|
|
124
|
+
{
|
|
125
|
+
className: "indicator",
|
|
126
|
+
style: {
|
|
127
|
+
width: `${F.width}px`,
|
|
128
|
+
transform: F.transform
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
),
|
|
132
|
+
f.map((t, e) => {
|
|
133
|
+
const { id: o, ...n } = t, r = o || `${l}-option-${e}`;
|
|
134
|
+
return /* @__PURE__ */ d(y.Fragment, { children: [
|
|
135
|
+
/* @__PURE__ */ s(
|
|
136
|
+
"input",
|
|
137
|
+
{
|
|
138
|
+
type: "radio",
|
|
139
|
+
...n,
|
|
140
|
+
id: r,
|
|
141
|
+
name: R,
|
|
142
|
+
checked: h === t.value,
|
|
143
|
+
disabled: C || t.disabled,
|
|
144
|
+
onChange: O
|
|
145
|
+
}
|
|
146
|
+
),
|
|
147
|
+
/* @__PURE__ */ s(
|
|
148
|
+
"label",
|
|
149
|
+
{
|
|
150
|
+
ref: (B) => {
|
|
151
|
+
g.current[e] = B;
|
|
152
|
+
},
|
|
153
|
+
htmlFor: r,
|
|
154
|
+
children: t.label
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
] }, r);
|
|
158
|
+
})
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
$ && J && /* @__PURE__ */ s(
|
|
163
|
+
c,
|
|
164
|
+
{
|
|
165
|
+
className: "scroll-button right",
|
|
166
|
+
onClick: () => A("right"),
|
|
167
|
+
children: /* @__PURE__ */ s("svg", { viewBox: "0 0 24 24", children: /* @__PURE__ */ s("polyline", { points: "9 6 15 12 9 18" }) })
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
] })
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
rt.displayName = "RadioTabGroup";
|
|
179
|
+
export {
|
|
180
|
+
rt as RadioTabGroup
|
|
181
|
+
};
|
|
182
|
+
//# sourceMappingURL=RadioTabGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioTabGroup.js","sources":["../../../../src/components/Form/RadioButton/RadioTabGroup.tsx"],"sourcesContent":["// REACT CORE ==========================================================================================================\nimport React, { useMemo, useRef, useEffect, useState, useCallback } from \"react\";\n\n// LOCAL COMPONENTS ====================================================================================================\nimport { Div } from \"$tags\";\nimport { Element } from \"$element\";\nimport { FormItem, deriveAriaIds } from \"../FormItem/FormItem\";\nimport { SpacingTypes } from \"../../Element/constants\";\nimport { separateWrapperProps } from \"../../../utils/propSeparation\";\n\n// STYLES ==============================================================================================================\nimport \"./radio-tab-group.css\";\n\n// OTHER ===============================================================================================================\nimport { RadioTabGroupProps, RadioButtonElementType } from \"./constants\";\n\ninterface IndicatorPosition {\n width: number;\n transform: string;\n}\n\n// COMPONENT ///////////////////////////////////////////////////////////////////////////////////////////////////////////\nexport const RadioTabGroup = React.forwardRef<HTMLDivElement, RadioTabGroupProps>(\n (\n {\n id,\n name,\n label,\n helpText,\n errorText,\n options,\n defaultValue,\n value,\n required,\n onChange,\n size = \"medium\",\n bgColour,\n disabled,\n ...props\n },\n ref\n ) => {\n const derivedName = useMemo(() => name || id, [name, id]);\n const optionsWrapperRef = useRef<HTMLDivElement>(null);\n\n const [indicatorPos, setIndicatorPos] = useState<IndicatorPosition>({\n width: 0,\n transform: \"translateX(0)\",\n });\n const [needsScroll, setNeedsScroll] = useState(false);\n const [scrollPosition, setScrollPosition] = useState(0);\n const [maxScroll, setMaxScroll] = useState(0);\n\n const labelsRef = useRef<(HTMLLabelElement | null)[]>([]);\n\n const measureWidths = useCallback(() => {\n if (!optionsWrapperRef.current) return;\n\n const wrapper = optionsWrapperRef.current;\n const inputWrapper = wrapper.closest(\"[data-input-wrapper]\");\n\n if (wrapper && inputWrapper) {\n const totalContentWidth = wrapper.scrollWidth;\n const availableWidth = inputWrapper.clientWidth;\n const needsToScroll = totalContentWidth > availableWidth;\n\n setNeedsScroll(needsToScroll);\n setMaxScroll(needsToScroll ? totalContentWidth - availableWidth : 0);\n }\n }, []);\n\n useEffect(() => {\n const wrapper = optionsWrapperRef.current;\n if (!wrapper) return;\n\n // Initial measurement\n measureWidths();\n\n // Set up observer for size changes\n const observer = new ResizeObserver(() => {\n measureWidths();\n });\n\n observer.observe(wrapper);\n if (wrapper.closest(\"[data-input-wrapper]\")) {\n observer.observe(wrapper.closest(\"[data-input-wrapper]\") as Element);\n }\n\n return () => observer.disconnect();\n }, [measureWidths]);\n\n // Update indicator position based on selected radio\n useEffect(() => {\n const selectedIndex = options.findIndex(option => option.value === value);\n if (selectedIndex >= 0) {\n const updateIndicator = () => {\n const label = labelsRef.current[selectedIndex];\n if (label) {\n const width = label.offsetWidth;\n let transform = \"translateX(0)\";\n\n if (selectedIndex > 0) {\n const offset = labelsRef.current\n .slice(0, selectedIndex)\n .reduce((acc, label) => acc + (label?.offsetWidth || 0), 0);\n transform = `translateX(${offset}px)`;\n }\n\n setIndicatorPos({ width, transform });\n }\n };\n\n // Wait for fonts to load before measuring to get correct widths\n if (document.fonts && document.fonts.ready) {\n document.fonts.ready.then(() => {\n requestAnimationFrame(() => {\n requestAnimationFrame(updateIndicator);\n });\n });\n } else {\n const timeoutId = setTimeout(updateIndicator, 100);\n return () => clearTimeout(timeoutId);\n }\n }\n }, [value, options]);\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(e.target.value);\n };\n\n // Separate wrapper-level props (margin, padding, etc.) from component-specific props\n const { wrapperProps, inputProps } = separateWrapperProps(props);\n\n const handleScroll = useCallback((direction: \"left\" | \"right\") => {\n const wrapper = optionsWrapperRef.current;\n if (!wrapper) return;\n\n const visibleWidth = wrapper.clientWidth;\n const scrollAmount = visibleWidth * 0.8;\n\n let newPosition = direction === \"right\"\n ? Math.min(scrollPosition + scrollAmount, maxScroll)\n : Math.max(scrollPosition - scrollAmount, 0);\n\n setScrollPosition(newPosition);\n\n requestAnimationFrame(() => {\n wrapper.style.transform = `translateX(-${newPosition}px)`;\n });\n }, [scrollPosition, maxScroll]);\n\n const canScrollLeft = scrollPosition > 0;\n const canScrollRight = scrollPosition < maxScroll;\n\n const classNames: string[] = [];\n if (size) {\n classNames.push(`size-${size}`);\n }\n\n const reactId = React.useId();\n const finalGroupId = id || `radio-tab-group-${reactId.replace(/:/g, \"\")}`;\n const { describedBy } = deriveAriaIds(finalGroupId, helpText, errorText);\n\n return (\n <FormItem\n label={label}\n htmlFor={finalGroupId}\n helpText={helpText}\n errorText={errorText}\n required={required}\n size={size}\n {...wrapperProps}\n >\n <Element\n as=\"div\"\n data-radio-tab-group\n ref={ref}\n id={finalGroupId}\n classNames={classNames}\n name={derivedName}\n role=\"radiogroup\"\n aria-label={label}\n aria-invalid={Boolean(errorText) || undefined}\n aria-required={required}\n aria-describedby={describedBy}\n {...inputProps}\n >\n {/* LEFT SCROLL BUTTON */}\n {needsScroll && canScrollLeft && (\n <Div\n className=\"scroll-button left\"\n onClick={() => handleScroll(\"left\")}\n >\n <svg viewBox=\"0 0 24 24\">\n <polyline points=\"15 18 9 12 15 6\" />\n </svg>\n </Div>\n )}\n\n {/* RADIO OPTIONS */}\n <Div className=\"rtg-options-container\">\n <Div\n className=\"rtg-options-wrapper\"\n ref={optionsWrapperRef}\n >\n {/* INDICATOR */}\n <Div\n className=\"indicator\"\n style={{\n width: `${indicatorPos.width}px`,\n transform: indicatorPos.transform,\n }}\n />\n\n {options.map((option, index) => {\n const { id: optionId, ...optionProps } = option;\n const finalId = optionId || `${finalGroupId}-option-${index}`;\n\n return (\n <React.Fragment key={finalId}>\n <input\n type=\"radio\"\n {...optionProps}\n id={finalId}\n name={derivedName}\n checked={value === option.value}\n disabled={disabled || option.disabled}\n onChange={handleChange}\n />\n <label\n ref={el => { labelsRef.current[index] = el; }}\n htmlFor={finalId}\n >\n {option.label}\n </label>\n </React.Fragment>\n );\n })}\n </Div>\n\n {/* RIGHT SCROLL BUTTON */}\n {needsScroll && canScrollRight && (\n <Div\n className=\"scroll-button right\"\n onClick={() => handleScroll(\"right\")}\n >\n <svg viewBox=\"0 0 24 24\">\n <polyline points=\"9 6 15 12 9 18\" />\n </svg>\n </Div>\n )}\n </Div>\n </Element>\n </FormItem>\n );\n }\n);\nRadioTabGroup.displayName = \"RadioTabGroup\";\n"],"names":["RadioTabGroup","React","id","name","label","helpText","errorText","options","defaultValue","value","required","onChange","size","bgColour","disabled","props","ref","derivedName","useMemo","optionsWrapperRef","useRef","indicatorPos","setIndicatorPos","useState","needsScroll","setNeedsScroll","scrollPosition","setScrollPosition","maxScroll","setMaxScroll","labelsRef","measureWidths","useCallback","wrapper","inputWrapper","totalContentWidth","availableWidth","needsToScroll","useEffect","observer","selectedIndex","option","updateIndicator","width","transform","acc","timeoutId","handleChange","e","wrapperProps","inputProps","separateWrapperProps","handleScroll","direction","scrollAmount","newPosition","canScrollLeft","canScrollRight","classNames","reactId","finalGroupId","describedBy","deriveAriaIds","jsx","FormItem","jsxs","Element","Div","index","optionId","optionProps","finalId","el"],"mappings":";;;;;;;AAsBO,MAAMA,KAAgBC,EAAM;AAAA,EAC/B,CACI;AAAA,IACI,IAAAC;AAAA,IACA,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,cAAAC;AAAA,IACA,OAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAEPC,MACC;AACD,UAAMC,IAAcC,EAAQ,MAAMf,KAAQD,GAAI,CAACC,GAAMD,CAAE,CAAC,GAClDiB,IAAoBC,EAAuB,IAAI,GAE/C,CAACC,GAAcC,CAAe,IAAIC,EAA4B;AAAA,MAChE,OAAO;AAAA,MACP,WAAW;AAAA,IAAA,CACd,GACK,CAACC,GAAaC,CAAc,IAAIF,EAAS,EAAK,GAC9C,CAACG,GAAgBC,CAAiB,IAAIJ,EAAS,CAAC,GAChD,CAACK,GAAWC,CAAY,IAAIN,EAAS,CAAC,GAEtCO,IAAYV,EAAoC,EAAE,GAElDW,IAAgBC,EAAY,MAAM;AACpC,UAAI,CAACb,EAAkB,QAAS;AAEhC,YAAMc,IAAUd,EAAkB,SAC5Be,IAAeD,EAAQ,QAAQ,sBAAsB;AAE3D,UAAIA,KAAWC,GAAc;AACzB,cAAMC,IAAoBF,EAAQ,aAC5BG,IAAiBF,EAAa,aAC9BG,IAAgBF,IAAoBC;AAE1C,QAAAX,EAAeY,CAAa,GAC5BR,EAAaQ,IAAgBF,IAAoBC,IAAiB,CAAC;AAAA,MACvE;AAAA,IACJ,GAAG,CAAA,CAAE;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