@os-design/core 1.0.185 → 1.0.186

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Container","styled","omitEmotionProps","sizeStyles","Label","label","p","theme","sizes","small","clr","colorText","Optional","span","formItemColorOptional","Help","div","formItemColorHelp","Error","formItemColorError","FormItem","forwardRef","ref","help","error","optional","loading","id","children","rest","useContext","FormConfigContext","optionalText","containerId","useMemo","Math","random","toString","slice","fieldId","helpId","input","c","React","isValidElement","cloneElement","undefined","inputColorBorder","firstTypeIs","useCallback","component","firstChildHasType","skeleton","Checkbox","firstChild","Children","toArray","props","RadioGroup","Switch","TextArea","displayName"],"sources":["../../../src/FormItem/index.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport { sizeStyles, WithSize } from '@os-design/styles';\nimport { clr, ThemeOverrider } from '@os-design/theming';\nimport { omitEmotionProps } from '@os-design/utils';\nimport React, { forwardRef, useCallback, useContext, useMemo } from 'react';\nimport Checkbox from '../Checkbox';\nimport CheckboxSkeleton from '../CheckboxSkeleton';\nimport FormConfigContext from '../Form/FormConfigContext';\nimport InputSkeleton from '../InputSkeleton';\nimport RadioGroup from '../RadioGroup';\nimport RadioGroupSkeleton from '../RadioGroupSkeleton';\nimport Switch from '../Switch';\nimport SwitchSkeleton from '../SwitchSkeleton';\nimport TextArea from '../TextArea';\nimport TextAreaSkeleton from '../TextAreaSkeleton';\nimport firstChildHasType from './utils/firstChildHasType';\n\ntype JsxDivProps = Omit<JSX.IntrinsicElements['div'], 'ref'>;\nexport interface FormItemProps extends JsxDivProps, WithSize {\n /**\n * Label of the field.\n * @default undefined\n */\n label?: string;\n /**\n * The help message located at the bottom of the field.\n * @default undefined\n */\n help?: string;\n /**\n * The error message located at the bottom of the field.\n * If specified, the field has a red border.\n * @default undefined\n */\n error?: string;\n /**\n * Whether the field is optional.\n * @default false\n */\n optional?: boolean;\n /**\n * Whether the skeleton is displayed.\n * @default false\n */\n loading?: boolean;\n}\n\nconst Container = styled('div', omitEmotionProps('size'))<WithSize>`\n ${sizeStyles};\n`;\n\nconst Label = styled.label`\n display: inline-flex;\n align-items: center;\n margin-bottom: 0.4em;\n font-size: ${(p) => p.theme.sizes.small}em;\n color: ${(p) => clr(p.theme.colorText)};\n`;\n\nconst Optional = styled.span`\n color: ${(p) => clr(p.theme.formItemColorOptional)};\n margin-left: 0.3em;\n`;\n\nconst Help = styled.div`\n margin-top: 0.1em;\n font-size: ${(p) => p.theme.sizes.small}em;\n color: ${(p) => clr(p.theme.formItemColorHelp)};\n`;\n\nconst Error = styled(Help)`\n color: ${(p) => clr(p.theme.formItemColorError)};\n`;\n\n/**\n * The wrapper of the field.\n */\nconst FormItem = forwardRef<HTMLDivElement, FormItemProps>(\n (\n {\n label,\n help,\n error,\n optional = false,\n loading = false,\n id,\n children,\n ...rest\n },\n ref\n ) => {\n const { optionalText } = useContext(FormConfigContext);\n\n const containerId = useMemo(\n () => id || Math.random().toString(36).slice(2, 11),\n [id]\n );\n const fieldId = useMemo(() => `field-${containerId}`, [containerId]);\n const helpId = useMemo(() => `help-${containerId}`, [containerId]);\n\n const input = useMemo(() => {\n const c = React.isValidElement(children)\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\n React.cloneElement<any>(children, {\n id: fieldId,\n 'aria-invalid': !!error,\n 'aria-describedby': help ? helpId : undefined,\n })\n : children;\n\n if (!error) return c;\n\n return (\n <ThemeOverrider\n overrides={(theme) => ({\n inputColorBorder: theme.formItemColorError,\n })}\n >\n {c}\n </ThemeOverrider>\n );\n }, [children, error, fieldId, help, helpId]);\n\n const firstTypeIs = useCallback(\n (component: React.FC) => firstChildHasType(children, component),\n [children]\n );\n\n const skeleton = useMemo(() => {\n if (firstTypeIs(Checkbox)) {\n const firstChild = React.Children.toArray(children)[0];\n return (\n <CheckboxSkeleton>\n {React.isValidElement(firstChild) && firstChild.props.children}\n </CheckboxSkeleton>\n );\n }\n if (firstTypeIs(RadioGroup)) return <RadioGroupSkeleton />;\n if (firstTypeIs(Switch)) return <SwitchSkeleton />;\n if (firstTypeIs(TextArea)) return <TextAreaSkeleton />;\n return <InputSkeleton />;\n }, [children, firstTypeIs]);\n\n return (\n <Container role='group' id={id} {...rest} ref={ref}>\n {label && (\n <Label htmlFor={fieldId}>\n {label}\n {optional && <Optional>({optionalText})</Optional>}\n </Label>\n )}\n {loading ? skeleton : input}\n {error ? (\n <Error aria-live='polite' id={helpId}>\n {error}\n </Error>\n ) : (\n help && <Help id={helpId}>{help}</Help>\n )}\n </Container>\n );\n }\n);\n\nFormItem.displayName = 'FormItem';\n\nexport default FormItem;\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAA0D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgC1D,IAAMA,SAAS,GAAG,IAAAC,kBAAM,EAAC,KAAK,EAAE,IAAAC,uBAAgB,EAAC,MAAM,CAAC,CAAC,iFACrDC,kBAAU,CACb;AAED,IAAMC,KAAK,GAAGH,kBAAM,CAACI,KAAK,0LAIX,UAACC,CAAC;EAAA,OAAKA,CAAC,CAACC,KAAK,CAACC,KAAK,CAACC,KAAK;AAAA,GAC9B,UAACH,CAAC;EAAA,OAAK,IAAAI,YAAG,EAACJ,CAAC,CAACC,KAAK,CAACI,SAAS,CAAC;AAAA,EACvC;AAED,IAAMC,QAAQ,GAAGX,kBAAM,CAACY,IAAI,iHACjB,UAACP,CAAC;EAAA,OAAK,IAAAI,YAAG,EAACJ,CAAC,CAACC,KAAK,CAACO,qBAAqB,CAAC;AAAA,EAEnD;AAED,IAAMC,IAAI,GAAGd,kBAAM,CAACe,GAAG,sIAER,UAACV,CAAC;EAAA,OAAKA,CAAC,CAACC,KAAK,CAACC,KAAK,CAACC,KAAK;AAAA,GAC9B,UAACH,CAAC;EAAA,OAAK,IAAAI,YAAG,E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CAAC;EAE3B,oBACE,gCAAC,SAAS;IAAC,IAAI,EAAC,OAAO;IAAC,EAAE,EAAErB;EAAG,GAAKE,IAAI;IAAE,GAAG,EAAEP;EAAI,IAChDjB,KAAK,iBACJ,gCAAC,KAAK;IAAC,OAAO,EAAEkC;EAAQ,GACrBlC,KAAK,EACLoB,QAAQ,iBAAI,gCAAC,QAAQ,aAAGO,YAAY,MAAa,CAErD,EACAN,OAAO,GAAG0B,QAAQ,GAAGX,KAAK,EAC1BjB,KAAK,gBACJ,gCAAC,KAAK;IAAC,aAAU,QAAQ;IAAC,EAAE,EAAEgB;EAAO,GAClChB,KAAK,CACA,GAERD,IAAI,iBAAI,gCAAC,IAAI;IAAC,EAAE,EAAEiB;EAAO,GAAEjB,IAAI,CAChC,CACS;AAEhB,CAAC,CACF;AAEDH,QAAQ,CAACyC,WAAW,GAAG,UAAU;AAAC,eAEnBzC,QAAQ;AAAA"}
1
+ {"version":3,"file":"index.js","names":["Container","styled","omitEmotionProps","sizeStyles","Label","label","p","theme","sizes","small","clr","colorText","Optional","span","formItemColorOptional","Help","div","formItemColorHelp","Error","formItemColorError","FormItem","forwardRef","ref","help","error","optional","loading","id","children","rest","useContext","FormConfigContext","optionalText","containerId","useMemo","Math","random","toString","slice","fieldId","helpId","input","c","React","isValidElement","cloneElement","undefined","inputColorBorder","firstTypeIs","useCallback","component","firstChildHasType","skeleton","Checkbox","firstChild","Children","toArray","props","RadioGroup","Switch","TextArea","displayName"],"sources":["../../../src/FormItem/index.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport { sizeStyles, WithSize } from '@os-design/styles';\nimport { clr, ThemeOverrider } from '@os-design/theming';\nimport { omitEmotionProps } from '@os-design/utils';\nimport React, { forwardRef, useCallback, useContext, useMemo } from 'react';\nimport Checkbox from '../Checkbox';\nimport CheckboxSkeleton from '../CheckboxSkeleton';\nimport FormConfigContext from '../Form/FormConfigContext';\nimport InputSkeleton from '../InputSkeleton';\nimport RadioGroup from '../RadioGroup';\nimport RadioGroupSkeleton from '../RadioGroupSkeleton';\nimport Switch from '../Switch';\nimport SwitchSkeleton from '../SwitchSkeleton';\nimport TextArea from '../TextArea';\nimport TextAreaSkeleton from '../TextAreaSkeleton';\nimport firstChildHasType from './utils/firstChildHasType';\n\ntype JsxDivProps = Omit<JSX.IntrinsicElements['div'], 'ref'>;\nexport interface FormItemProps extends JsxDivProps, WithSize {\n /**\n * Label of the field.\n * @default undefined\n */\n label?: string;\n /**\n * The help message located at the bottom of the field.\n * @default undefined\n */\n help?: string;\n /**\n * The error message located at the bottom of the field.\n * If specified, the field has a red border.\n * @default undefined\n */\n error?: string | null;\n /**\n * Whether the field is optional.\n * @default false\n */\n optional?: boolean;\n /**\n * Whether the skeleton is displayed.\n * @default false\n */\n loading?: boolean;\n}\n\nconst Container = styled('div', omitEmotionProps('size'))<WithSize>`\n ${sizeStyles};\n`;\n\nconst Label = styled.label`\n display: inline-flex;\n align-items: center;\n margin-bottom: 0.4em;\n font-size: ${(p) => p.theme.sizes.small}em;\n color: ${(p) => clr(p.theme.colorText)};\n`;\n\nconst Optional = styled.span`\n color: ${(p) => clr(p.theme.formItemColorOptional)};\n margin-left: 0.3em;\n`;\n\nconst Help = styled.div`\n margin-top: 0.1em;\n font-size: ${(p) => p.theme.sizes.small}em;\n color: ${(p) => clr(p.theme.formItemColorHelp)};\n`;\n\nconst Error = styled(Help)`\n color: ${(p) => clr(p.theme.formItemColorError)};\n`;\n\n/**\n * The wrapper of the field.\n */\nconst FormItem = forwardRef<HTMLDivElement, FormItemProps>(\n (\n {\n label,\n help,\n error,\n optional = false,\n loading = false,\n id,\n children,\n ...rest\n },\n ref\n ) => {\n const { optionalText } = useContext(FormConfigContext);\n\n const containerId = useMemo(\n () => id || Math.random().toString(36).slice(2, 11),\n [id]\n );\n const fieldId = useMemo(() => `field-${containerId}`, [containerId]);\n const helpId = useMemo(() => `help-${containerId}`, [containerId]);\n\n const input = useMemo(() => {\n const c = React.isValidElement(children)\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\n React.cloneElement<any>(children, {\n id: fieldId,\n 'aria-invalid': !!error,\n 'aria-describedby': help ? helpId : undefined,\n })\n : children;\n\n if (!error) return c;\n\n return (\n <ThemeOverrider\n overrides={(theme) => ({\n inputColorBorder: theme.formItemColorError,\n })}\n >\n {c}\n </ThemeOverrider>\n );\n }, [children, error, fieldId, help, helpId]);\n\n const firstTypeIs = useCallback(\n (component: React.FC) => firstChildHasType(children, component),\n [children]\n );\n\n const skeleton = useMemo(() => {\n if (firstTypeIs(Checkbox)) {\n const firstChild = React.Children.toArray(children)[0];\n return (\n <CheckboxSkeleton>\n {React.isValidElement(firstChild) && firstChild.props.children}\n </CheckboxSkeleton>\n );\n }\n if (firstTypeIs(RadioGroup)) return <RadioGroupSkeleton />;\n if (firstTypeIs(Switch)) return <SwitchSkeleton />;\n if (firstTypeIs(TextArea)) return <TextAreaSkeleton />;\n return <InputSkeleton />;\n }, [children, firstTypeIs]);\n\n return (\n <Container role='group' id={id} {...rest} ref={ref}>\n {label && (\n <Label htmlFor={fieldId}>\n {label}\n {optional && <Optional>({optionalText})</Optional>}\n </Label>\n )}\n {loading ? skeleton : input}\n {error ? (\n <Error aria-live='polite' id={helpId}>\n {error}\n </Error>\n ) : (\n help && <Help id={helpId}>{help}</Help>\n )}\n </Container>\n );\n }\n);\n\nFormItem.displayName = 'FormItem';\n\nexport default FormItem;\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAA0D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgC1D,IAAMA,SAAS,GAAG,IAAAC,kBAAM,EAAC,KAAK,EAAE,IAAAC,uBAAgB,EAAC,MAAM,CAAC,CAAC,iFACrDC,kBAAU,CACb;AAED,IAAMC,KAAK,GAAGH,kBAAM,CAACI,KAAK,0LAIX,UAACC,CAAC;EAAA,OAAKA,CAAC,CAACC,K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CAAC,CAAC;MACtD,oBACE,gCAAC,4BAAgB,QACd,aAAAe,iBAAK,CAACC,cAAc,CAACU,UAAU,CAAC,IAAIA,UAAU,CAACG,KAAK,CAAC7B,QAAQ,CAC7C;IAEvB;IACA,IAAIoB,WAAW,CAACU,sBAAU,CAAC,EAAE,oBAAO,gCAAC,8BAAkB,OAAG;IAC1D,IAAIV,WAAW,CAACW,kBAAM,CAAC,EAAE,oBAAO,gCAAC,0BAAc,OAAG;IAClD,IAAIX,WAAW,CAACY,oBAAQ,CAAC,EAAE,oBAAO,gCAAC,4BAAgB,OAAG;IACtD,oBAAO,gCAAC,yBAAa,OAAG;EAC1B,CAAC,EAAE,CAAChC,QAAQ,EAAEoB,WAAW,CAAC,CAAC;EAE3B,oBACE,gCAAC,SAAS;IAAC,IAAI,EAAC,OAAO;IAAC,EAAE,EAAErB;EAAG,GAAKE,IAAI;IAAE,GAAG,EAAEP;EAAI,IAChDjB,KAAK,iBACJ,gCAAC,KAAK;IAAC,OAAO,EAAEkC;EAAQ,GACrBlC,KAAK,EACLoB,QAAQ,iBAAI,gCAAC,QAAQ,aAAGO,YAAY,MAAa,CAErD,EACAN,OAAO,GAAG0B,QAAQ,GAAGX,KAAK,EAC1BjB,KAAK,gBACJ,gCAAC,KAAK;IAAC,aAAU,QAAQ;IAAC,EAAE,EAAEgB;EAAO,GAClChB,KAAK,CACA,GAERD,IAAI,iBAAI,gCAAC,IAAI;IAAC,EAAE,EAAEiB;EAAO,GAAEjB,IAAI,CAChC,CACS;AAEhB,CAAC,CACF;AAEDH,QAAQ,CAACyC,WAAW,GAAG,UAAU;AAAC,eAEnBzC,QAAQ;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["styled","sizeStyles","clr","ThemeOverrider","omitEmotionProps","React","forwardRef","useCallback","useContext","useMemo","Checkbox","CheckboxSkeleton","FormConfigContext","InputSkeleton","RadioGroup","RadioGroupSkeleton","Switch","SwitchSkeleton","TextArea","TextAreaSkeleton","firstChildHasType","Container","Label","label","p","theme","sizes","small","colorText","Optional","span","formItemColorOptional","Help","div","formItemColorHelp","Error","formItemColorError","FormItem","help","error","optional","loading","id","children","rest","ref","optionalText","containerId","Math","random","toString","slice","fieldId","helpId","input","c","isValidElement","cloneElement","undefined","inputColorBorder","firstTypeIs","component","skeleton","firstChild","Children","toArray","props","displayName"],"sources":["../../../src/FormItem/index.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport { sizeStyles, WithSize } from '@os-design/styles';\nimport { clr, ThemeOverrider } from '@os-design/theming';\nimport { omitEmotionProps } from '@os-design/utils';\nimport React, { forwardRef, useCallback, useContext, useMemo } from 'react';\nimport Checkbox from '../Checkbox';\nimport CheckboxSkeleton from '../CheckboxSkeleton';\nimport FormConfigContext from '../Form/FormConfigContext';\nimport InputSkeleton from '../InputSkeleton';\nimport RadioGroup from '../RadioGroup';\nimport RadioGroupSkeleton from '../RadioGroupSkeleton';\nimport Switch from '../Switch';\nimport SwitchSkeleton from '../SwitchSkeleton';\nimport TextArea from '../TextArea';\nimport TextAreaSkeleton from '../TextAreaSkeleton';\nimport firstChildHasType from './utils/firstChildHasType';\n\ntype JsxDivProps = Omit<JSX.IntrinsicElements['div'], 'ref'>;\nexport interface FormItemProps extends JsxDivProps, WithSize {\n /**\n * Label of the field.\n * @default undefined\n */\n label?: string;\n /**\n * The help message located at the bottom of the field.\n * @default undefined\n */\n help?: string;\n /**\n * The error message located at the bottom of the field.\n * If specified, the field has a red border.\n * @default undefined\n */\n error?: string;\n /**\n * Whether the field is optional.\n * @default false\n */\n optional?: boolean;\n /**\n * Whether the skeleton is displayed.\n * @default false\n */\n loading?: boolean;\n}\n\nconst Container = styled('div', omitEmotionProps('size'))<WithSize>`\n ${sizeStyles};\n`;\n\nconst Label = styled.label`\n display: inline-flex;\n align-items: center;\n margin-bottom: 0.4em;\n font-size: ${(p) => p.theme.sizes.small}em;\n color: ${(p) => clr(p.theme.colorText)};\n`;\n\nconst Optional = styled.span`\n color: ${(p) => clr(p.theme.formItemColorOptional)};\n margin-left: 0.3em;\n`;\n\nconst Help = styled.div`\n margin-top: 0.1em;\n font-size: ${(p) => p.theme.sizes.small}em;\n color: ${(p) => clr(p.theme.formItemColorHelp)};\n`;\n\nconst Error = styled(Help)`\n color: ${(p) => clr(p.theme.formItemColorError)};\n`;\n\n/**\n * The wrapper of the field.\n */\nconst FormItem = forwardRef<HTMLDivElement, FormItemProps>(\n (\n {\n label,\n help,\n error,\n optional = false,\n loading = false,\n id,\n children,\n ...rest\n },\n ref\n ) => {\n const { optionalText } = useContext(FormConfigContext);\n\n const containerId = useMemo(\n () => id || Math.random().toString(36).slice(2, 11),\n [id]\n );\n const fieldId = useMemo(() => `field-${containerId}`, [containerId]);\n const helpId = useMemo(() => `help-${containerId}`, [containerId]);\n\n const input = useMemo(() => {\n const c = React.isValidElement(children)\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\n React.cloneElement<any>(children, {\n id: fieldId,\n 'aria-invalid': !!error,\n 'aria-describedby': help ? helpId : undefined,\n })\n : children;\n\n if (!error) return c;\n\n return (\n <ThemeOverrider\n overrides={(theme) => ({\n inputColorBorder: theme.formItemColorError,\n })}\n >\n {c}\n </ThemeOverrider>\n );\n }, [children, error, fieldId, help, helpId]);\n\n const firstTypeIs = useCallback(\n (component: React.FC) => firstChildHasType(children, component),\n [children]\n );\n\n const skeleton = useMemo(() => {\n if (firstTypeIs(Checkbox)) {\n const firstChild = React.Children.toArray(children)[0];\n return (\n <CheckboxSkeleton>\n {React.isValidElement(firstChild) && firstChild.props.children}\n </CheckboxSkeleton>\n );\n }\n if (firstTypeIs(RadioGroup)) return <RadioGroupSkeleton />;\n if (firstTypeIs(Switch)) return <SwitchSkeleton />;\n if (firstTypeIs(TextArea)) return <TextAreaSkeleton />;\n return <InputSkeleton />;\n }, [children, firstTypeIs]);\n\n return (\n <Container role='group' id={id} {...rest} ref={ref}>\n {label && (\n <Label htmlFor={fieldId}>\n {label}\n {optional && <Optional>({optionalText})</Optional>}\n </Label>\n )}\n {loading ? skeleton : input}\n {error ? (\n <Error aria-live='polite' id={helpId}>\n {error}\n </Error>\n ) : (\n help && <Help id={helpId}>{help}</Help>\n )}\n </Container>\n );\n }\n);\n\nFormItem.displayName = 'FormItem';\n\nexport default FormItem;\n"],"mappings":";AAAA,OAAOA,MAAM,MAAM,iBAAiB;AACpC,SAASC,UAAU,QAAkB,mBAAmB;AACxD,SAASC,GAAG,EAAEC,cAAc,QAAQ,oBAAoB;AACxD,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,OAAOC,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC3E,OAAOC,QAAQ,MAAM,aAAa;AAClC,OAAOC,gBAAgB,MAAM,qBAAqB;AAClD,OAAOC,iBAAiB,MAAM,2BAA2B;AACzD,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,OAAOC,UAAU,MAAM,eAAe;AACtC,OAAOC,kBAAkB,MAAM,uBAAuB;AACtD,OAAOC,MAAM,MAAM,WAAW;AAC9B,OAAOC,cAAc,MAAM,mBAAmB;AAC9C,OAAOC,QAAQ,MAAM,aAAa;AAClC,OAAOC,gBAAgB,MAAM,qBAAqB;AAClD,OAAOC,iBAAiB,MAAM,2BAA2B;AAgCzD,MAAMC,SAAS,GAAGrB,MAAM,CAAC,KAAK,EAAEI,gBAAgB,CAAC,MAAM,CAAC,CAAY;AACpE,IAAIH,UAAW;AACf,CAAC;AAED,MAAMqB,KAAK,GAAGtB,MAAM,CAACuB,KAAM;AAC3B;AACA;AACA;AACA,eAAgBC,CAAC,IAAKA,CAAC,CAACC,KAAK,CAACC,KAAK,CAACC,KAAM;AAC1C,WAAYH,CAAC,IAAKtB,GAAG,CAACsB,CAAC,CAACC,KAAK,CAACG,SAAS,CAAE;AACzC,CAAC;AAED,MAAMC,QAAQ,GAAG7B,MAAM,CAAC8B,IAAK;AAC7B,WAAYN,CAAC,IAAKtB,GAAG,CAACsB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E,oBAAC,SAAS;IAAC,IAAI,EAAC,OAAO;IAAC,EAAE,EAAElB;EAAG,GAAKE,IAAI;IAAE,GAAG,EAAEC;EAAI,IAChDtB,KAAK,iBACJ,oBAAC,KAAK;IAAC,OAAO,EAAE6B;EAAQ,GACrB7B,KAAK,EACLiB,QAAQ,iBAAI,oBAAC,QAAQ,aAAGM,YAAY,MAAa,CAErD,EACAL,OAAO,GAAGqB,QAAQ,GAAGR,KAAK,EAC1Bf,KAAK,gBACJ,oBAAC,KAAK;IAAC,aAAU,QAAQ;IAAC,EAAE,EAAEc;EAAO,GAClCd,KAAK,CACA,GAERD,IAAI,iBAAI,oBAAC,IAAI;IAAC,EAAE,EAAEe;EAAO,GAAEf,IAAI,CAChC,CACS;AAEhB,CAAC,CACF;AAEDD,QAAQ,CAAC8B,WAAW,GAAG,UAAU;AAEjC,eAAe9B,QAAQ"}
1
+ {"version":3,"file":"index.js","names":["styled","sizeStyles","clr","ThemeOverrider","omitEmotionProps","React","forwardRef","useCallback","useContext","useMemo","Checkbox","CheckboxSkeleton","FormConfigContext","InputSkeleton","RadioGroup","RadioGroupSkeleton","Switch","SwitchSkeleton","TextArea","TextAreaSkeleton","firstChildHasType","Container","Label","label","p","theme","sizes","small","colorText","Optional","span","formItemColorOptional","Help","div","formItemColorHelp","Error","formItemColorError","FormItem","help","error","optional","loading","id","children","rest","ref","optionalText","containerId","Math","random","toString","slice","fieldId","helpId","input","c","isValidElement","cloneElement","undefined","inputColorBorder","firstTypeIs","component","skeleton","firstChild","Children","toArray","props","displayName"],"sources":["../../../src/FormItem/index.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport { sizeStyles, WithSize } from '@os-design/styles';\nimport { clr, ThemeOverrider } from '@os-design/theming';\nimport { omitEmotionProps } from '@os-design/utils';\nimport React, { forwardRef, useCallback, useContext, useMemo } from 'react';\nimport Checkbox from '../Checkbox';\nimport CheckboxSkeleton from '../CheckboxSkeleton';\nimport FormConfigContext from '../Form/FormConfigContext';\nimport InputSkeleton from '../InputSkeleton';\nimport RadioGroup from '../RadioGroup';\nimport RadioGroupSkeleton from '../RadioGroupSkeleton';\nimport Switch from '../Switch';\nimport SwitchSkeleton from '../SwitchSkeleton';\nimport TextArea from '../TextArea';\nimport TextAreaSkeleton from '../TextAreaSkeleton';\nimport firstChildHasType from './utils/firstChildHasType';\n\ntype JsxDivProps = Omit<JSX.IntrinsicElements['div'], 'ref'>;\nexport interface FormItemProps extends JsxDivProps, WithSize {\n /**\n * Label of the field.\n * @default undefined\n */\n label?: string;\n /**\n * The help message located at the bottom of the field.\n * @default undefined\n */\n help?: string;\n /**\n * The error message located at the bottom of the field.\n * If specified, the field has a red border.\n * @default undefined\n */\n error?: string | null;\n /**\n * Whether the field is optional.\n * @default false\n */\n optional?: boolean;\n /**\n * Whether the skeleton is displayed.\n * @default false\n */\n loading?: boolean;\n}\n\nconst Container = styled('div', omitEmotionProps('size'))<WithSize>`\n ${sizeStyles};\n`;\n\nconst Label = styled.label`\n display: inline-flex;\n align-items: center;\n margin-bottom: 0.4em;\n font-size: ${(p) => p.theme.sizes.small}em;\n color: ${(p) => clr(p.theme.colorText)};\n`;\n\nconst Optional = styled.span`\n color: ${(p) => clr(p.theme.formItemColorOptional)};\n margin-left: 0.3em;\n`;\n\nconst Help = styled.div`\n margin-top: 0.1em;\n font-size: ${(p) => p.theme.sizes.small}em;\n color: ${(p) => clr(p.theme.formItemColorHelp)};\n`;\n\nconst Error = styled(Help)`\n color: ${(p) => clr(p.theme.formItemColorError)};\n`;\n\n/**\n * The wrapper of the field.\n */\nconst FormItem = forwardRef<HTMLDivElement, FormItemProps>(\n (\n {\n label,\n help,\n error,\n optional = false,\n loading = false,\n id,\n children,\n ...rest\n },\n ref\n ) => {\n const { optionalText } = useContext(FormConfigContext);\n\n const containerId = useMemo(\n () => id || Math.random().toString(36).slice(2, 11),\n [id]\n );\n const fieldId = useMemo(() => `field-${containerId}`, [containerId]);\n const helpId = useMemo(() => `help-${containerId}`, [containerId]);\n\n const input = useMemo(() => {\n const c = React.isValidElement(children)\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\n React.cloneElement<any>(children, {\n id: fieldId,\n 'aria-invalid': !!error,\n 'aria-describedby': help ? helpId : undefined,\n })\n : children;\n\n if (!error) return c;\n\n return (\n <ThemeOverrider\n overrides={(theme) => ({\n inputColorBorder: theme.formItemColorError,\n })}\n >\n {c}\n </ThemeOverrider>\n );\n }, [children, error, fieldId, help, helpId]);\n\n const firstTypeIs = useCallback(\n (component: React.FC) => firstChildHasType(children, component),\n [children]\n );\n\n const skeleton = useMemo(() => {\n if (firstTypeIs(Checkbox)) {\n const firstChild = React.Children.toArray(children)[0];\n return (\n <CheckboxSkeleton>\n {React.isValidElement(firstChild) && firstChild.props.children}\n </CheckboxSkeleton>\n );\n }\n if (firstTypeIs(RadioGroup)) return <RadioGroupSkeleton />;\n if (firstTypeIs(Switch)) return <SwitchSkeleton />;\n if (firstTypeIs(TextArea)) return <TextAreaSkeleton />;\n return <InputSkeleton />;\n }, [children, firstTypeIs]);\n\n return (\n <Container role='group' id={id} {...rest} ref={ref}>\n {label && (\n <Label htmlFor={fieldId}>\n {label}\n {optional && <Optional>({optionalText})</Optional>}\n </Label>\n )}\n {loading ? skeleton : input}\n {error ? (\n <Error aria-live='polite' id={helpId}>\n {error}\n </Error>\n ) : (\n help && <Help id={helpId}>{help}</Help>\n )}\n </Container>\n );\n }\n);\n\nFormItem.displayName = 'FormItem';\n\nexport default FormItem;\n"],"mappings":";AAAA,OAAOA,MAAM,MAAM,iBAAiB;AACpC,SAASC,UAAU,QAAkB,mBAAmB;AACxD,SAASC,GAAG,EAAEC,cAAc,QAAQ,oBAAoB;AACxD,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,OAAOC,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC3E,OAAOC,QAAQ,MAAM,aAAa;AAClC,OAAOC,gBAAgB,MAAM,qBAAq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AAQ,CAAC8B,WAAW,GAAG,UAAU;AAEjC,eAAe9B,QAAQ"}
@@ -4,7 +4,7 @@ type JsxDivProps = Omit<JSX.IntrinsicElements['div'], 'ref'>;
4
4
  export interface FormItemProps extends JsxDivProps, WithSize {
5
5
  label?: string;
6
6
  help?: string;
7
- error?: string;
7
+ error?: string | null;
8
8
  optional?: boolean;
9
9
  loading?: boolean;
10
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/FormItem/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,KAAuD,MAAM,OAAO,CAAC;AAa5E,KAAK,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;AAC7D,MAAM,WAAW,aAAc,SAAQ,WAAW,EAAE,QAAQ;IAK1D,KAAK,CAAC,EAAE,MAAM,CAAC;IAKf,IAAI,CAAC,EAAE,MAAM,CAAC;IAMd,KAAK,CAAC,EAAE,MAAM,CAAC;IAKf,QAAQ,CAAC,EAAE,OAAO,CAAC;IAKnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAgCD,QAAA,MAAM,QAAQ,sFAqFb,CAAC;AAIF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/FormItem/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,KAAuD,MAAM,OAAO,CAAC;AAa5E,KAAK,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;AAC7D,MAAM,WAAW,aAAc,SAAQ,WAAW,EAAE,QAAQ;IAK1D,KAAK,CAAC,EAAE,MAAM,CAAC;IAKf,IAAI,CAAC,EAAE,MAAM,CAAC;IAMd,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAKtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAKnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAgCD,QAAA,MAAM,QAAQ,sFAqFb,CAAC;AAIF,eAAe,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@os-design/core",
3
- "version": "1.0.185",
3
+ "version": "1.0.186",
4
4
  "license": "UNLICENSED",
5
5
  "repository": "git@gitlab.com:os-team/libs/os-design.git",
6
6
  "main": "dist/cjs/index.js",
@@ -58,5 +58,5 @@
58
58
  "react": ">=18",
59
59
  "react-dom": ">=18"
60
60
  },
61
- "gitHead": "7859a613f18e75724fea40b609aae6a1ff2b3873"
61
+ "gitHead": "2dbd5dc78c987a313373c4f7e5e72061ab73a514"
62
62
  }