@lumx/react 2.2.13 → 2.2.14
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/esm/_internal/Checkbox2.js +3 -1
- package/esm/_internal/Checkbox2.js.map +1 -1
- package/esm/_internal/RadioGroup.js +3 -1
- package/esm/_internal/RadioGroup.js.map +1 -1
- package/package.json +4 -4
- package/src/components/checkbox/Checkbox.tsx +4 -0
- package/src/components/radio-button/RadioButton.tsx +4 -0
- package/src/stories/generated/Toolbar/Demos.stories.tsx +1 -0
- package/types.d.ts +4 -0
|
@@ -41,6 +41,7 @@ var Checkbox = forwardRef(function (props, ref) {
|
|
|
41
41
|
disabled = props.disabled,
|
|
42
42
|
helper = props.helper,
|
|
43
43
|
id = props.id,
|
|
44
|
+
inputRef = props.inputRef,
|
|
44
45
|
_props$isChecked = props.isChecked,
|
|
45
46
|
isChecked = _props$isChecked === void 0 ? checked : _props$isChecked,
|
|
46
47
|
_props$isDisabled = props.isDisabled,
|
|
@@ -52,7 +53,7 @@ var Checkbox = forwardRef(function (props, ref) {
|
|
|
52
53
|
value = props.value,
|
|
53
54
|
_props$inputProps = props.inputProps,
|
|
54
55
|
inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
|
|
55
|
-
forwardedProps = _objectWithoutProperties(props, ["checked", "className", "disabled", "helper", "id", "isChecked", "isDisabled", "label", "name", "onChange", "theme", "value", "inputProps"]);
|
|
56
|
+
forwardedProps = _objectWithoutProperties(props, ["checked", "className", "disabled", "helper", "id", "inputRef", "isChecked", "isDisabled", "label", "name", "onChange", "theme", "value", "inputProps"]);
|
|
56
57
|
|
|
57
58
|
var inputId = useMemo(function () {
|
|
58
59
|
return id || "".concat(CLASSNAME.toLowerCase(), "-").concat(uid());
|
|
@@ -77,6 +78,7 @@ var Checkbox = forwardRef(function (props, ref) {
|
|
|
77
78
|
}), React.createElement("div", {
|
|
78
79
|
className: "".concat(CLASSNAME, "__input-wrapper")
|
|
79
80
|
}, React.createElement("input", _extends({
|
|
81
|
+
ref: inputRef,
|
|
80
82
|
type: "checkbox",
|
|
81
83
|
id: inputId,
|
|
82
84
|
className: "".concat(CLASSNAME, "__input-native"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox2.js","sources":["../../../src/components/checkbox/Checkbox.tsx"],"sourcesContent":["import React, { useMemo, forwardRef, ReactNode, SyntheticEvent, InputHTMLAttributes } from 'react';\n\nimport classNames from 'classnames';\nimport { uid } from 'uid';\n\nimport { mdiCheck } from '@lumx/icons';\n\nimport { Icon, InputHelper, InputLabel, Theme } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface CheckboxProps extends GenericProps {\n /** Helper text. */\n helper?: string;\n /** Native input id property. */\n id?: string;\n /** Whether it is checked or not. */\n isChecked?: boolean;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Label text. */\n label?: ReactNode;\n /** Native input name property. */\n name?: string;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Native input value property. */\n value?: string;\n /** On change callback. */\n onChange?(isChecked: boolean, value?: string, name?: string, event?: SyntheticEvent): void;\n /** optional props for input */\n inputProps?: InputHTMLAttributes<HTMLInputElement>;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Checkbox';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<CheckboxProps> = {\n theme: Theme.light,\n};\n\n/**\n * Checkbox component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Checkbox: Comp<CheckboxProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n checked,\n className,\n disabled,\n helper,\n id,\n isChecked = checked,\n isDisabled = disabled,\n label,\n name,\n onChange,\n theme,\n value,\n inputProps = {},\n ...forwardedProps\n } = props;\n const inputId = useMemo(() => id || `${CLASSNAME.toLowerCase()}-${uid()}`, [id]);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (onChange) {\n onChange(!isChecked, value, name, event);\n }\n };\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n isChecked,\n isDisabled,\n isUnchecked: !isChecked,\n prefix: CLASSNAME,\n theme,\n }),\n )}\n >\n <div className={`${CLASSNAME}__input-wrapper`}>\n <input\n type=\"checkbox\"\n id={inputId}\n className={`${CLASSNAME}__input-native`}\n tabIndex={isDisabled ? -1 : 0}\n name={name}\n value={value}\n checked={isChecked}\n onChange={handleChange}\n {...inputProps}\n />\n\n <div className={`${CLASSNAME}__input-placeholder`}>\n <div className={`${CLASSNAME}__input-background`} />\n\n <div className={`${CLASSNAME}__input-indicator`}>\n <Icon icon={mdiCheck} />\n </div>\n </div>\n </div>\n\n <div className={`${CLASSNAME}__content`}>\n {label && (\n <InputLabel htmlFor={inputId} className={`${CLASSNAME}__label`} theme={theme}>\n {label}\n </InputLabel>\n )}\n {helper && (\n <InputHelper className={`${CLASSNAME}__helper`} theme={theme}>\n {helper}\n </InputHelper>\n )}\n </div>\n </div>\n );\n});\nCheckbox.displayName = COMPONENT_NAME;\nCheckbox.className = CLASSNAME;\nCheckbox.defaultProps = DEFAULT_PROPS;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","theme","Theme","light","Checkbox","forwardRef","props","ref","checked","className","disabled","helper","id","isChecked","isDisabled","label","name","onChange","value","inputProps","forwardedProps","inputId","useMemo","toLowerCase","uid","handleChange","event","classNames","handleBasicClasses","isUnchecked","prefix","mdiCheck","displayName","defaultProps"],"mappings":";;;;;;;;;AAUA;;;;
|
|
1
|
+
{"version":3,"file":"Checkbox2.js","sources":["../../../src/components/checkbox/Checkbox.tsx"],"sourcesContent":["import React, { useMemo, forwardRef, ReactNode, SyntheticEvent, InputHTMLAttributes } from 'react';\n\nimport classNames from 'classnames';\nimport { uid } from 'uid';\n\nimport { mdiCheck } from '@lumx/icons';\n\nimport { Icon, InputHelper, InputLabel, Theme } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface CheckboxProps extends GenericProps {\n /** Helper text. */\n helper?: string;\n /** Native input id property. */\n id?: string;\n /** Native input ref. */\n inputRef?: React.Ref<HTMLInputElement>;\n /** Whether it is checked or not. */\n isChecked?: boolean;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Label text. */\n label?: ReactNode;\n /** Native input name property. */\n name?: string;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Native input value property. */\n value?: string;\n /** On change callback. */\n onChange?(isChecked: boolean, value?: string, name?: string, event?: SyntheticEvent): void;\n /** optional props for input */\n inputProps?: InputHTMLAttributes<HTMLInputElement>;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Checkbox';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<CheckboxProps> = {\n theme: Theme.light,\n};\n\n/**\n * Checkbox component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Checkbox: Comp<CheckboxProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n checked,\n className,\n disabled,\n helper,\n id,\n inputRef,\n isChecked = checked,\n isDisabled = disabled,\n label,\n name,\n onChange,\n theme,\n value,\n inputProps = {},\n ...forwardedProps\n } = props;\n const inputId = useMemo(() => id || `${CLASSNAME.toLowerCase()}-${uid()}`, [id]);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (onChange) {\n onChange(!isChecked, value, name, event);\n }\n };\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n isChecked,\n isDisabled,\n isUnchecked: !isChecked,\n prefix: CLASSNAME,\n theme,\n }),\n )}\n >\n <div className={`${CLASSNAME}__input-wrapper`}>\n <input\n ref={inputRef}\n type=\"checkbox\"\n id={inputId}\n className={`${CLASSNAME}__input-native`}\n tabIndex={isDisabled ? -1 : 0}\n name={name}\n value={value}\n checked={isChecked}\n onChange={handleChange}\n {...inputProps}\n />\n\n <div className={`${CLASSNAME}__input-placeholder`}>\n <div className={`${CLASSNAME}__input-background`} />\n\n <div className={`${CLASSNAME}__input-indicator`}>\n <Icon icon={mdiCheck} />\n </div>\n </div>\n </div>\n\n <div className={`${CLASSNAME}__content`}>\n {label && (\n <InputLabel htmlFor={inputId} className={`${CLASSNAME}__label`} theme={theme}>\n {label}\n </InputLabel>\n )}\n {helper && (\n <InputHelper className={`${CLASSNAME}__helper`} theme={theme}>\n {helper}\n </InputHelper>\n )}\n </div>\n </div>\n );\n});\nCheckbox.displayName = COMPONENT_NAME;\nCheckbox.className = CLASSNAME;\nCheckbox.defaultProps = DEFAULT_PROPS;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","theme","Theme","light","Checkbox","forwardRef","props","ref","checked","className","disabled","helper","id","inputRef","isChecked","isDisabled","label","name","onChange","value","inputProps","forwardedProps","inputId","useMemo","toLowerCase","uid","handleChange","event","classNames","handleBasicClasses","isUnchecked","prefix","mdiCheck","displayName","defaultProps"],"mappings":";;;;;;;;;AAUA;;;;AA4BA;;;AAGA,IAAMA,cAAc,GAAG,UAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;AAGA,IAAMG,aAAqC,GAAG;AAC1CC,EAAAA,KAAK,EAAEC,KAAK,CAACC;AAD6B,CAA9C;AAIA;;;;;;;;IAOaC,QAA6C,GAAGC,UAAU,CAAC,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAAA,MAEhFC,OAFgF,GAiBhFF,KAjBgF,CAEhFE,OAFgF;AAAA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AuBpC,cAAvB;AACAO,QAAQ,CAACK,SAAT,GAAqBX,SAArB;AACAM,QAAQ,CAAC8B,YAAT,GAAwBlC,aAAxB;;;;"}
|
|
@@ -40,6 +40,7 @@ var RadioButton = forwardRef(function (props, ref) {
|
|
|
40
40
|
disabled = props.disabled,
|
|
41
41
|
helper = props.helper,
|
|
42
42
|
id = props.id,
|
|
43
|
+
inputRef = props.inputRef,
|
|
43
44
|
_props$isChecked = props.isChecked,
|
|
44
45
|
isChecked = _props$isChecked === void 0 ? checked : _props$isChecked,
|
|
45
46
|
_props$isDisabled = props.isDisabled,
|
|
@@ -49,7 +50,7 @@ var RadioButton = forwardRef(function (props, ref) {
|
|
|
49
50
|
onChange = props.onChange,
|
|
50
51
|
theme = props.theme,
|
|
51
52
|
value = props.value,
|
|
52
|
-
forwardedProps = _objectWithoutProperties(props, ["checked", "className", "disabled", "helper", "id", "isChecked", "isDisabled", "label", "name", "onChange", "theme", "value"]);
|
|
53
|
+
forwardedProps = _objectWithoutProperties(props, ["checked", "className", "disabled", "helper", "id", "inputRef", "isChecked", "isDisabled", "label", "name", "onChange", "theme", "value"]);
|
|
53
54
|
|
|
54
55
|
var radioButtonId = useMemo(function () {
|
|
55
56
|
return id || "".concat(CLASSNAME.toLowerCase(), "-").concat(uid());
|
|
@@ -74,6 +75,7 @@ var RadioButton = forwardRef(function (props, ref) {
|
|
|
74
75
|
}), React.createElement("div", {
|
|
75
76
|
className: "".concat(CLASSNAME, "__input-wrapper")
|
|
76
77
|
}, React.createElement("input", {
|
|
78
|
+
ref: inputRef,
|
|
77
79
|
className: "".concat(CLASSNAME, "__input-native"),
|
|
78
80
|
disabled: isDisabled,
|
|
79
81
|
id: radioButtonId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","sources":["../../../src/components/radio-button/RadioButton.tsx","../../../src/components/radio-button/RadioGroup.tsx"],"sourcesContent":["import React, { useMemo, forwardRef, ReactNode, SyntheticEvent } from 'react';\n\nimport classNames from 'classnames';\nimport { uid } from 'uid';\n\nimport { InputHelper, InputLabel, Theme } from '@lumx/react';\n\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface RadioButtonProps extends GenericProps {\n /** Helper text. */\n helper?: string;\n /** Native input id property. */\n id?: string;\n /** Whether it is checked or not. */\n isChecked?: boolean;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Label content. */\n label?: ReactNode;\n /** Native input name property. */\n name?: string;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Native input value property. */\n value?: string;\n /** On change callback. */\n onChange?(value?: string, name?: string, event?: SyntheticEvent): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'RadioButton';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<RadioButtonProps> = {\n theme: Theme.light,\n};\n\n/**\n * RadioButton component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const RadioButton: Comp<RadioButtonProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n checked,\n className,\n disabled,\n helper,\n id,\n isChecked = checked,\n isDisabled = disabled,\n label,\n name,\n onChange,\n theme,\n value,\n ...forwardedProps\n } = props;\n const radioButtonId = useMemo(() => id || `${CLASSNAME.toLowerCase()}-${uid()}`, [id]);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (onChange) {\n onChange(value, name, event);\n }\n };\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n isChecked,\n isDisabled,\n isUnchecked: !isChecked,\n prefix: CLASSNAME,\n theme,\n }),\n )}\n >\n <div className={`${CLASSNAME}__input-wrapper`}>\n <input\n className={`${CLASSNAME}__input-native`}\n disabled={isDisabled}\n id={radioButtonId}\n tabIndex={isDisabled ? -1 : 0}\n type=\"radio\"\n name={name}\n value={value}\n checked={isChecked}\n onChange={handleChange}\n />\n\n <div className={`${CLASSNAME}__input-placeholder`}>\n <div className={`${CLASSNAME}__input-background`} />\n <div className={`${CLASSNAME}__input-indicator`} />\n </div>\n </div>\n\n <div className={`${CLASSNAME}__content`}>\n {label && (\n <InputLabel htmlFor={radioButtonId} theme={theme} className={`${CLASSNAME}__label`}>\n {label}\n </InputLabel>\n )}\n {helper && (\n <InputHelper theme={theme} className={`${CLASSNAME}__helper`}>\n {helper}\n </InputHelper>\n )}\n </div>\n </div>\n );\n});\nRadioButton.displayName = COMPONENT_NAME;\nRadioButton.className = CLASSNAME;\nRadioButton.defaultProps = DEFAULT_PROPS;\n","import React, { forwardRef, ReactNode } from 'react';\n\nimport classNames from 'classnames';\n\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface RadioGroupProps extends GenericProps {\n /** RadioButton elements */\n children: ReactNode;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'RadioGroup';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * RadioGroup component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const RadioGroup: Comp<RadioGroupProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, ...forwardedProps } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n prefix: CLASSNAME,\n }),\n )}\n >\n {children}\n </div>\n );\n});\nRadioGroup.displayName = COMPONENT_NAME;\nRadioGroup.className = CLASSNAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","theme","Theme","light","RadioButton","forwardRef","props","ref","checked","className","disabled","helper","id","isChecked","isDisabled","label","name","onChange","value","forwardedProps","radioButtonId","useMemo","toLowerCase","uid","handleChange","event","classNames","handleBasicClasses","isUnchecked","prefix","displayName","defaultProps","RadioGroup","children"],"mappings":";;;;;;;;AASA;;;;
|
|
1
|
+
{"version":3,"file":"RadioGroup.js","sources":["../../../src/components/radio-button/RadioButton.tsx","../../../src/components/radio-button/RadioGroup.tsx"],"sourcesContent":["import React, { useMemo, forwardRef, ReactNode, SyntheticEvent } from 'react';\n\nimport classNames from 'classnames';\nimport { uid } from 'uid';\n\nimport { InputHelper, InputLabel, Theme } from '@lumx/react';\n\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface RadioButtonProps extends GenericProps {\n /** Helper text. */\n helper?: string;\n /** Native input id property. */\n id?: string;\n /** Native input ref. */\n inputRef?: React.Ref<HTMLInputElement>;\n /** Whether it is checked or not. */\n isChecked?: boolean;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Label content. */\n label?: ReactNode;\n /** Native input name property. */\n name?: string;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Native input value property. */\n value?: string;\n /** On change callback. */\n onChange?(value?: string, name?: string, event?: SyntheticEvent): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'RadioButton';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<RadioButtonProps> = {\n theme: Theme.light,\n};\n\n/**\n * RadioButton component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const RadioButton: Comp<RadioButtonProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n checked,\n className,\n disabled,\n helper,\n id,\n inputRef,\n isChecked = checked,\n isDisabled = disabled,\n label,\n name,\n onChange,\n theme,\n value,\n ...forwardedProps\n } = props;\n const radioButtonId = useMemo(() => id || `${CLASSNAME.toLowerCase()}-${uid()}`, [id]);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (onChange) {\n onChange(value, name, event);\n }\n };\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n isChecked,\n isDisabled,\n isUnchecked: !isChecked,\n prefix: CLASSNAME,\n theme,\n }),\n )}\n >\n <div className={`${CLASSNAME}__input-wrapper`}>\n <input\n ref={inputRef}\n className={`${CLASSNAME}__input-native`}\n disabled={isDisabled}\n id={radioButtonId}\n tabIndex={isDisabled ? -1 : 0}\n type=\"radio\"\n name={name}\n value={value}\n checked={isChecked}\n onChange={handleChange}\n />\n\n <div className={`${CLASSNAME}__input-placeholder`}>\n <div className={`${CLASSNAME}__input-background`} />\n <div className={`${CLASSNAME}__input-indicator`} />\n </div>\n </div>\n\n <div className={`${CLASSNAME}__content`}>\n {label && (\n <InputLabel htmlFor={radioButtonId} theme={theme} className={`${CLASSNAME}__label`}>\n {label}\n </InputLabel>\n )}\n {helper && (\n <InputHelper theme={theme} className={`${CLASSNAME}__helper`}>\n {helper}\n </InputHelper>\n )}\n </div>\n </div>\n );\n});\nRadioButton.displayName = COMPONENT_NAME;\nRadioButton.className = CLASSNAME;\nRadioButton.defaultProps = DEFAULT_PROPS;\n","import React, { forwardRef, ReactNode } from 'react';\n\nimport classNames from 'classnames';\n\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface RadioGroupProps extends GenericProps {\n /** RadioButton elements */\n children: ReactNode;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'RadioGroup';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * RadioGroup component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const RadioGroup: Comp<RadioGroupProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, ...forwardedProps } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n prefix: CLASSNAME,\n }),\n )}\n >\n {children}\n </div>\n );\n});\nRadioGroup.displayName = COMPONENT_NAME;\nRadioGroup.className = CLASSNAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","theme","Theme","light","RadioButton","forwardRef","props","ref","checked","className","disabled","helper","id","inputRef","isChecked","isDisabled","label","name","onChange","value","forwardedProps","radioButtonId","useMemo","toLowerCase","uid","handleChange","event","classNames","handleBasicClasses","isUnchecked","prefix","displayName","defaultProps","RadioGroup","children"],"mappings":";;;;;;;;AASA;;;;AA0BA;;;AAGA,IAAMA,cAAc,GAAG,aAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;AAGA,IAAMG,aAAwC,GAAG;AAC7CC,EAAAA,KAAK,EAAEC,KAAK,CAACC;AADgC,CAAjD;AAIA;;;;;;;;IAOaC,WAAmD,GAAGC,UAAU,CAAC,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAAA,MAEtFC,OAFsF,GAgBtFF,KAhBsF,CAEtFE,OAFsF;AAAA,MAGtFC,SAHsF,GAgBtFH,KAhBsF,CAGtFG,SAHsF;AAAA,MAItFC,QAJsF,GAgBtFJ,KAhBsF,CAItFI,QAJsF;AAAA,MAKtFC,MALsF,GAgBtFL,KAhBsF,CAKtFK,MALsF;AAAA,MAMtFC,EANsF,GAgBtFN,KAhBsF,CAMtFM,EANsF;AAAA,MAOtFC,QAPsF,GAgBtFP,KAhBsF,CAOtFO,QAPsF;AAAA,yBAgBtFP,KAhBsF,CAQtFQ,SARsF;AAAA,MAQtFA,SARsF,iCAQ1EN,OAR0E;AAAA,0BAgBtFF,KAhBsF,CAStFS,UATsF;AAAA,MAStFA,UATsF,kCASzEL,QATyE;AAAA,MAUtFM,KAVsF,GAgBtFV,KAhBsF,CAUtFU,KAVsF;AAAA,MAWtFC,IAXsF,GAgBtFX,KAhBsF,CAWtFW,IAXsF;AAAA,M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BAAzB;AACAoC,UAAU,CAACxB,SAAX,GAAuBX,WAAvB;;;;"}
|
package/package.json
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@juggle/resize-observer": "^3.2.0",
|
|
10
|
-
"@lumx/core": "^2.2.
|
|
11
|
-
"@lumx/icons": "^2.2.
|
|
10
|
+
"@lumx/core": "^2.2.14",
|
|
11
|
+
"@lumx/icons": "^2.2.14",
|
|
12
12
|
"@popperjs/core": "^2.5.4",
|
|
13
13
|
"body-scroll-lock": "^3.1.5",
|
|
14
14
|
"classnames": "^2.2.6",
|
|
@@ -120,6 +120,6 @@
|
|
|
120
120
|
"build:storybook": "cd storybook && ./build"
|
|
121
121
|
},
|
|
122
122
|
"sideEffects": false,
|
|
123
|
-
"version": "2.2.
|
|
124
|
-
"gitHead": "
|
|
123
|
+
"version": "2.2.14",
|
|
124
|
+
"gitHead": "f91f87393935f907dffee38cff5f44721c2343d7"
|
|
125
125
|
}
|
|
@@ -16,6 +16,8 @@ export interface CheckboxProps extends GenericProps {
|
|
|
16
16
|
helper?: string;
|
|
17
17
|
/** Native input id property. */
|
|
18
18
|
id?: string;
|
|
19
|
+
/** Native input ref. */
|
|
20
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
19
21
|
/** Whether it is checked or not. */
|
|
20
22
|
isChecked?: boolean;
|
|
21
23
|
/** Whether the component is disabled or not. */
|
|
@@ -65,6 +67,7 @@ export const Checkbox: Comp<CheckboxProps, HTMLDivElement> = forwardRef((props,
|
|
|
65
67
|
disabled,
|
|
66
68
|
helper,
|
|
67
69
|
id,
|
|
70
|
+
inputRef,
|
|
68
71
|
isChecked = checked,
|
|
69
72
|
isDisabled = disabled,
|
|
70
73
|
label,
|
|
@@ -100,6 +103,7 @@ export const Checkbox: Comp<CheckboxProps, HTMLDivElement> = forwardRef((props,
|
|
|
100
103
|
>
|
|
101
104
|
<div className={`${CLASSNAME}__input-wrapper`}>
|
|
102
105
|
<input
|
|
106
|
+
ref={inputRef}
|
|
103
107
|
type="checkbox"
|
|
104
108
|
id={inputId}
|
|
105
109
|
className={`${CLASSNAME}__input-native`}
|
|
@@ -15,6 +15,8 @@ export interface RadioButtonProps extends GenericProps {
|
|
|
15
15
|
helper?: string;
|
|
16
16
|
/** Native input id property. */
|
|
17
17
|
id?: string;
|
|
18
|
+
/** Native input ref. */
|
|
19
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
18
20
|
/** Whether it is checked or not. */
|
|
19
21
|
isChecked?: boolean;
|
|
20
22
|
/** Whether the component is disabled or not. */
|
|
@@ -62,6 +64,7 @@ export const RadioButton: Comp<RadioButtonProps, HTMLDivElement> = forwardRef((p
|
|
|
62
64
|
disabled,
|
|
63
65
|
helper,
|
|
64
66
|
id,
|
|
67
|
+
inputRef,
|
|
65
68
|
isChecked = checked,
|
|
66
69
|
isDisabled = disabled,
|
|
67
70
|
label,
|
|
@@ -96,6 +99,7 @@ export const RadioButton: Comp<RadioButtonProps, HTMLDivElement> = forwardRef((p
|
|
|
96
99
|
>
|
|
97
100
|
<div className={`${CLASSNAME}__input-wrapper`}>
|
|
98
101
|
<input
|
|
102
|
+
ref={inputRef}
|
|
99
103
|
className={`${CLASSNAME}__input-native`}
|
|
100
104
|
disabled={isDisabled}
|
|
101
105
|
id={radioButtonId}
|
|
@@ -6,4 +6,5 @@ export default { title: 'LumX components/toolbar/Toolbar Demos' };
|
|
|
6
6
|
export { App as Back } from './back';
|
|
7
7
|
export { App as Default } from './default';
|
|
8
8
|
export { App as Dialog } from './dialog';
|
|
9
|
+
export { App as FileWidget } from './file-widget';
|
|
9
10
|
export { App as MediaPicker } from './media-picker';
|
package/types.d.ts
CHANGED
|
@@ -585,6 +585,8 @@ export interface CheckboxProps extends GenericProps {
|
|
|
585
585
|
helper?: string;
|
|
586
586
|
/** Native input id property. */
|
|
587
587
|
id?: string;
|
|
588
|
+
/** Native input ref. */
|
|
589
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
588
590
|
/** Whether it is checked or not. */
|
|
589
591
|
isChecked?: boolean;
|
|
590
592
|
/** Whether the component is disabled or not. */
|
|
@@ -1796,6 +1798,8 @@ export interface RadioButtonProps extends GenericProps {
|
|
|
1796
1798
|
helper?: string;
|
|
1797
1799
|
/** Native input id property. */
|
|
1798
1800
|
id?: string;
|
|
1801
|
+
/** Native input ref. */
|
|
1802
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
1799
1803
|
/** Whether it is checked or not. */
|
|
1800
1804
|
isChecked?: boolean;
|
|
1801
1805
|
/** Whether the component is disabled or not. */
|