@consumidor-positivo/aurora 0.0.152 → 0.0.153
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.
|
@@ -37,7 +37,13 @@ import './styles.css';const CheckboxField = ({
|
|
|
37
37
|
}
|
|
38
38
|
),
|
|
39
39
|
/* @__PURE__ */ jsx("span", { className: "au-checkbox__check", children: /* @__PURE__ */ jsx(IconCheck, { rawColor: COLOR_NEUTRAL_00 }) }),
|
|
40
|
-
/* @__PURE__ */ jsx(
|
|
40
|
+
/* @__PURE__ */ jsx(
|
|
41
|
+
"span",
|
|
42
|
+
{
|
|
43
|
+
className: "au-checkbox__label",
|
|
44
|
+
dangerouslySetInnerHTML: { __html: label || "" }
|
|
45
|
+
}
|
|
46
|
+
)
|
|
41
47
|
] }),
|
|
42
48
|
/* @__PURE__ */ jsx(Field.ErrorMessage, { hasError: !!error, message: errorMessage })
|
|
43
49
|
] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../../../lib/components/form/Checkbox/Field/index.tsx","../../../lib/components/form/Checkbox/Group/hook.tsx","../../../lib/components/form/Checkbox/Group/index.tsx","../../../lib/components/form/Checkbox/index.tsx"],"sourcesContent":["import { useState } from 'react'\nimport classNames from 'classnames'\nimport { IconCheck } from '@components/icons'\nimport { COLOR_NEUTRAL_00 } from '@core/tokens'\nimport Field from '../../Field'\n\nimport { CheckboxFieldProps } from '../types'\nimport './styles.scss'\n\nexport const CheckboxField = ({\n label,\n error,\n errorMessage,\n disabled,\n id,\n style,\n ...props\n}: CheckboxFieldProps) => {\n const checkboxClasses = classNames('au-checkbox', {\n 'au-checkbox--error': !!error,\n 'au-checkbox--disabled': !!disabled,\n })\n\n const getSafeId = (id: CheckboxFieldProps['id']) => {\n return id ? id : `au-checkbox-${Math.random()}`\n }\n const [safeId] = useState(getSafeId(id))\n\n return (\n <div className={checkboxClasses} style={style}>\n <label htmlFor={safeId} className=\"au-checkbox__holder\">\n <input\n className=\"au-checkbox__input\"\n type=\"checkbox\"\n id={safeId}\n disabled={disabled}\n {...props}\n />\n <span className=\"au-checkbox__check\">\n <IconCheck rawColor={COLOR_NEUTRAL_00} />\n </span>\n <span
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../../lib/components/form/Checkbox/Field/index.tsx","../../../lib/components/form/Checkbox/Group/hook.tsx","../../../lib/components/form/Checkbox/Group/index.tsx","../../../lib/components/form/Checkbox/index.tsx"],"sourcesContent":["import { useState } from 'react'\nimport classNames from 'classnames'\nimport { IconCheck } from '@components/icons'\nimport { COLOR_NEUTRAL_00 } from '@core/tokens'\nimport Field from '../../Field'\n\nimport { CheckboxFieldProps } from '../types'\nimport './styles.scss'\n\nexport const CheckboxField = ({\n label,\n error,\n errorMessage,\n disabled,\n id,\n style,\n ...props\n}: CheckboxFieldProps) => {\n const checkboxClasses = classNames('au-checkbox', {\n 'au-checkbox--error': !!error,\n 'au-checkbox--disabled': !!disabled,\n })\n\n const getSafeId = (id: CheckboxFieldProps['id']) => {\n return id ? id : `au-checkbox-${Math.random()}`\n }\n const [safeId] = useState(getSafeId(id))\n\n return (\n <div className={checkboxClasses} style={style}>\n <label htmlFor={safeId} className=\"au-checkbox__holder\">\n <input\n className=\"au-checkbox__input\"\n type=\"checkbox\"\n id={safeId}\n disabled={disabled}\n {...props}\n />\n <span className=\"au-checkbox__check\">\n <IconCheck rawColor={COLOR_NEUTRAL_00} />\n </span>\n <span\n className=\"au-checkbox__label\"\n dangerouslySetInnerHTML={{ __html: label || '' }}\n />\n </label>\n <Field.ErrorMessage hasError={!!error} message={errorMessage} />\n </div>\n )\n}\n","import { useEffect, useState } from 'react'\nimport { CheckboxFieldProps } from '../types'\n\ntype UseCheckboxGroupProps = {\n name?: string\n onChange?: React.ChangeEventHandler<HTMLInputElement>\n}\n\nexport const useCheckboxGroup = ({ onChange, name }: UseCheckboxGroupProps) => {\n const getSafeName = (name?: string): string => {\n return name ? name : `au-checkbox-group-${Math.random()}`\n }\n const [safeName] = useState(getSafeName(name))\n\n const [selectedOptions, setSelectedOptions] = useState([{}])\n\n function handleSelectOption(\n checked: boolean,\n option: CheckboxFieldProps,\n index: number,\n ) {\n setSelectedOptions({\n ...selectedOptions,\n [index]: checked ? option : false,\n })\n }\n\n useEffect(() => {\n const returnResponse = Object.values(selectedOptions).filter(\n (item) => !!item,\n )\n\n if (onChange) {\n const event = {\n target: {\n checked: returnResponse,\n },\n } as unknown as React.ChangeEvent<HTMLInputElement>\n\n onChange(event)\n }\n }, [selectedOptions])\n\n return {\n handleSelectOption,\n safeName,\n }\n}\n","import React from 'react'\nimport classNames from 'classnames'\nimport './styles.scss'\nimport Field from '@components/form/Field'\nimport { Conditional } from '@components/misc'\nimport { Text } from '@components/Text'\nimport { CheckboxField } from '../Field'\nimport { CheckboxFieldProps, CheckboxGroupProps } from '../types'\nimport { useCheckboxGroup } from './hook'\n\nexport const CheckboxGroup = ({\n name,\n defaultValue,\n orientation = 'vertical',\n label,\n error,\n errorMessage,\n required = false,\n children,\n onChange,\n onFocus,\n}: CheckboxGroupProps) => {\n const groupClass = classNames('au-checkbox-group', {\n 'au-checkbox-group--horizontal': orientation === 'horizontal',\n })\n\n const { handleSelectOption, safeName } = useCheckboxGroup({onChange, name})\n\n const childrenWithProps = React.Children.map(children, (child, index) => {\n if (React.isValidElement(child)) {\n const childProps = child.props as CheckboxFieldProps\n\n return (\n <CheckboxField\n name={safeName}\n error={error}\n defaultChecked={defaultValue === childProps.value}\n onChange={(e) =>\n handleSelectOption(e.target.checked, childProps, index)\n }\n onFocus={onFocus}\n {...child.props}\n />\n )\n }\n return child\n })\n\n return (\n <div className={groupClass}>\n <Conditional\n condition={!!label}\n renderIf={\n <Text variant=\"body-small\" weight=\"semibold\" color=\"secondary\">\n {label}{' '}\n {!!required && (\n <span className=\"au-checkbox-group__label--required\">*</span>\n )}\n </Text>\n }\n />\n <div className=\"au-checkbox-group__fields\">{childrenWithProps}</div>\n <Field.ErrorMessage hasError={!!error} message={errorMessage} />\n </div>\n )\n}\n","import { CheckboxField } from './Field'\nimport { CheckboxGroup } from './Group'\nimport { CheckboxFieldProps, CheckboxGroupProps } from './types'\n\ntype Components = {\n Field: React.FC<CheckboxFieldProps>\n Group: React.FC<CheckboxGroupProps>\n}\n\nconst components: Components = {\n Field: CheckboxField,\n Group: CheckboxGroup,\n}\n\nObject.keys(components).forEach((key) => {\n const component = components[key as keyof Components]\n component.displayName = `Checkbox.${key}`\n})\n\nexport { components as Checkbox }\n"],"names":["id","name","React"],"mappings":";;;;;;;;;AASO,MAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAA0B;AAClB,QAAA,kBAAkB,WAAW,eAAe;AAAA,IAChD,sBAAsB,CAAC,CAAC;AAAA,IACxB,yBAAyB,CAAC,CAAC;AAAA,EAAA,CAC5B;AAEK,QAAA,YAAY,CAACA,QAAiC;AAClD,WAAOA,MAAKA,MAAK,eAAe,KAAK,OAAQ,CAAA;AAAA,EAAA;AAE/C,QAAM,CAAC,MAAM,IAAI,SAAS,UAAU,EAAE,CAAC;AAEvC,SACG,qBAAA,OAAA,EAAI,WAAW,iBAAiB,OAC/B,UAAA;AAAA,IAAA,qBAAC,SAAM,EAAA,SAAS,QAAQ,WAAU,uBAChC,UAAA;AAAA,MAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAU;AAAA,UACV,MAAK;AAAA,UACL,IAAI;AAAA,UACJ;AAAA,UACC,GAAG;AAAA,QAAA;AAAA,MACN;AAAA,MACA,oBAAC,UAAK,WAAU,sBACd,8BAAC,WAAU,EAAA,UAAU,kBAAkB,EACzC,CAAA;AAAA,MACA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAU;AAAA,UACV,yBAAyB,EAAE,QAAQ,SAAS,GAAG;AAAA,QAAA;AAAA,MACjD;AAAA,IAAA,GACF;AAAA,IACA,oB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