no-frills-ui 0.0.14-rc.0 → 0.0.14-rc.2

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.
Files changed (60) hide show
  1. package/README.md +1 -0
  2. package/dist/index.js +389 -195
  3. package/dist/index.js.map +1 -1
  4. package/lib-esm/components/Accordion/Accordion.js +10 -1
  5. package/lib-esm/components/Accordion/Accordion.js.map +1 -1
  6. package/lib-esm/components/Accordion/AccordionStep.js +9 -9
  7. package/lib-esm/components/Accordion/AccordionStep.js.map +1 -1
  8. package/lib-esm/components/Card/Card.js +2 -2
  9. package/lib-esm/components/Card/Card.js.map +1 -1
  10. package/lib-esm/components/Chip/Chip.js +2 -2
  11. package/lib-esm/components/ChipInput/ChipInput.d.ts +1 -1
  12. package/lib-esm/components/ChipInput/ChipInput.js +14 -6
  13. package/lib-esm/components/ChipInput/ChipInput.js.map +1 -1
  14. package/lib-esm/components/DragAndDrop/DragAndDrop.js +2 -2
  15. package/lib-esm/components/DragAndDrop/DragItem.js +2 -2
  16. package/lib-esm/components/Drawer/Drawer.d.ts +1 -1
  17. package/lib-esm/components/Drawer/Drawer.js +2 -3
  18. package/lib-esm/components/Drawer/Drawer.js.map +1 -1
  19. package/lib-esm/components/Groups/Group.js +3 -3
  20. package/lib-esm/components/Groups/Group.js.map +1 -1
  21. package/lib-esm/components/Input/Checkbox.d.ts +2 -0
  22. package/lib-esm/components/Input/Checkbox.js +54 -23
  23. package/lib-esm/components/Input/Checkbox.js.map +1 -1
  24. package/lib-esm/components/Input/Dropdown.d.ts +2 -0
  25. package/lib-esm/components/Input/Dropdown.js +123 -59
  26. package/lib-esm/components/Input/Dropdown.js.map +1 -1
  27. package/lib-esm/components/Input/Input.js +17 -8
  28. package/lib-esm/components/Input/Input.js.map +1 -1
  29. package/lib-esm/components/Input/Radio.d.ts +2 -0
  30. package/lib-esm/components/Input/Radio.js +22 -10
  31. package/lib-esm/components/Input/Radio.js.map +1 -1
  32. package/lib-esm/components/Input/RadioButton.d.ts +2 -0
  33. package/lib-esm/components/Input/RadioButton.js +21 -9
  34. package/lib-esm/components/Input/RadioButton.js.map +1 -1
  35. package/lib-esm/components/Input/Select.js +21 -11
  36. package/lib-esm/components/Input/Select.js.map +1 -1
  37. package/lib-esm/components/Input/TextArea.js +17 -8
  38. package/lib-esm/components/Input/TextArea.js.map +1 -1
  39. package/lib-esm/components/Input/Toggle.d.ts +2 -0
  40. package/lib-esm/components/Input/Toggle.js +45 -15
  41. package/lib-esm/components/Input/Toggle.js.map +1 -1
  42. package/lib-esm/components/Input/index.d.ts +1 -0
  43. package/lib-esm/components/Menu/MenuItem.d.ts +1 -1
  44. package/lib-esm/components/Menu/MenuItem.js +1 -1
  45. package/lib-esm/components/Menu/MenuItem.js.map +1 -1
  46. package/lib-esm/components/Modal/Modal.d.ts +1 -1
  47. package/lib-esm/components/Modal/Modal.js +1 -2
  48. package/lib-esm/components/Modal/Modal.js.map +1 -1
  49. package/lib-esm/components/Popover/Popover.d.ts +1 -1
  50. package/lib-esm/components/Popover/Popover.js +3 -3
  51. package/lib-esm/components/Popover/Popover.js.map +1 -1
  52. package/lib-esm/components/Stepper/Stepper.js +14 -5
  53. package/lib-esm/components/Stepper/Stepper.js.map +1 -1
  54. package/lib-esm/index.js +1 -1
  55. package/lib-esm/shared/LayerManager.js +3 -15
  56. package/lib-esm/shared/LayerManager.js.map +1 -1
  57. package/lib-esm/shared/styles.d.ts +5 -1
  58. package/lib-esm/shared/styles.js +11 -7
  59. package/lib-esm/shared/styles.js.map +1 -1
  60. package/package.json +2 -2
@@ -1,32 +1,44 @@
1
1
  import { jsxs, jsx } from '@emotion/react/jsx-runtime';
2
- import React from 'react';
2
+ import React, { useRef, useId, useImperativeHandle, useEffect } from 'react';
3
3
  import styled from '@emotion/styled';
4
4
  import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
5
5
 
6
6
  const Label$1 = /*#__PURE__*/ styled("label", {
7
- target: "e12cx2u30",
7
+ target: "edovkv60",
8
8
  label: "Label"
9
- })("display:inline-flex;align-items:center;margin:5px 0;cursor:pointer;position:relative;");
9
+ })("display:inline-flex;align-items:center;margin:5px 10px 5px 0;cursor:pointer;position:relative;");
10
10
  const StyledRadio = /*#__PURE__*/ styled("span", {
11
- target: "e12cx2u31",
11
+ target: "edovkv61",
12
12
  label: "StyledRadio"
13
13
  })("width:16px;height:16px;margin-right:5px;border:1px solid ", getThemeValue(THEME_NAME.BORDER_COLOR), ";border-radius:50%;display:block;transition:background-color 0.3s ease;position:relative;flex-shrink:0;&::after{content:'';width:100%;height:100%;border-radius:50%;position:absolute;top:0;left:0;box-shadow:inset 0 0 0 3px ", getThemeValue(THEME_NAME.BACKGROUND), ";opacity:0;transition:opacity 0.2s ease;}");
14
14
  const HiddenInput = /*#__PURE__*/ styled("input", {
15
- target: "e12cx2u32",
15
+ target: "edovkv62",
16
16
  label: "HiddenInput"
17
17
  })("opacity:0;width:0;height:0;position:absolute;margin:0;&:checked + ", StyledRadio, "{border-color:", getThemeValue(THEME_NAME.PRIMARY), ";background-color:", getThemeValue(THEME_NAME.PRIMARY), ";}&:checked + ", StyledRadio, "::after{opacity:1;}&:enabled:focus + ", StyledRadio, "{border-color:", getThemeValue(THEME_NAME.PRIMARY), ";box-shadow:0 0 0 3px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}&:enabled:checked:focus + ", StyledRadio, "{border-color:", getThemeValue(THEME_NAME.PRIMARY), ";box-shadow:0 0 0 3px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}&:enabled:hover + ", StyledRadio, "{border-color:", getThemeValue(THEME_NAME.PRIMARY), ";}&:enabled:hover ~ span{color:", getThemeValue(THEME_NAME.PRIMARY), ";}&:disabled + ", StyledRadio, "{border-color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";background-color:", getThemeValue(THEME_NAME.LIGHT_GREY), ";cursor:not-allowed;}&:disabled:checked + ", StyledRadio, "{border-color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";background-color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";}&:disabled ~ span{color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";cursor:not-allowed;}");
18
18
  /**
19
19
  * Radio Component
20
20
  * @param props - Component props
21
- * @param ref - Ref forwarded to the underlying HTMLInputElement
22
- */ function RadioComponent(props, ref) {
23
- const { label, ...rest } = props;
21
+ * @param forwardedRef - Ref forwarded to the underlying HTMLInputElement
22
+ */ function RadioComponent(props, forwardedRef) {
23
+ const { label, errorText, ...rest } = props;
24
+ const internalRef = useRef(null);
25
+ const errorId = useId();
26
+ useImperativeHandle(forwardedRef, ()=>internalRef.current);
27
+ useEffect(()=>{
28
+ if (internalRef.current) {
29
+ internalRef.current.setCustomValidity(errorText || '');
30
+ }
31
+ }, [
32
+ errorText
33
+ ]);
24
34
  return /*#__PURE__*/ jsxs(Label$1, {
25
35
  children: [
26
36
  /*#__PURE__*/ jsx(HiddenInput, {
27
37
  ...rest,
28
- ref: ref,
29
- type: "radio"
38
+ ref: internalRef,
39
+ type: "radio",
40
+ "aria-invalid": !!errorText,
41
+ "aria-describedby": errorText ? errorId : undefined
30
42
  }),
31
43
  /*#__PURE__*/ jsx(StyledRadio, {}),
32
44
  /*#__PURE__*/ jsx("span", {
@@ -1 +1 @@
1
- {"version":3,"file":"Radio.js","sources":["../../../src/components/Input/Radio.tsx"],"sourcesContent":["import React from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\nconst Label = styled.label`\n display: inline-flex;\n align-items: center;\n margin: 5px 0;\n cursor: pointer;\n position: relative;\n`;\n\nconst StyledRadio = styled.span`\n width: 16px;\n height: 16px;\n margin-right: 5px;\n border: 1px solid ${getThemeValue(THEME_NAME.BORDER_COLOR)};\n border-radius: 50%;\n display: block;\n transition: background-color 0.3s ease;\n position: relative;\n flex-shrink: 0;\n\n &::after {\n content: '';\n width: 100%;\n height: 100%;\n border-radius: 50%;\n position: absolute;\n top: 0;\n left: 0;\n box-shadow: inset 0 0 0 3px ${getThemeValue(THEME_NAME.BACKGROUND)};\n opacity: 0;\n transition: opacity 0.2s ease;\n }\n`;\n\nconst HiddenInput = styled.input`\n opacity: 0;\n width: 0;\n height: 0;\n position: absolute;\n margin: 0;\n\n /* checked */\n &:checked + ${StyledRadio} {\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n background-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n &:checked + ${StyledRadio}::after {\n opacity: 1;\n }\n\n /* focus */\n &:enabled:focus + ${StyledRadio} {\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n box-shadow: 0 0 0 3px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n &:enabled:checked:focus + ${StyledRadio} {\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n box-shadow: 0 0 0 3px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n /* hover */\n &:enabled:hover + ${StyledRadio} {\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n &:enabled:hover ~ span {\n color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /* disabled */\n &:disabled + ${StyledRadio} {\n border-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n background-color: ${getThemeValue(THEME_NAME.LIGHT_GREY)};\n cursor: not-allowed;\n }\n\n &:disabled:checked + ${StyledRadio} {\n border-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n background-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n }\n\n &:disabled ~ span {\n color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n cursor: not-allowed;\n }\n`;\n\ntype RadioProps = {\n /** Label for the field */\n label?: string;\n} & React.InputHTMLAttributes<HTMLInputElement>;\n\n/**\n * Radio Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLInputElement\n */\nfunction RadioComponent(props: RadioProps, ref: React.Ref<HTMLInputElement>) {\n const { label, ...rest } = props;\n\n return (\n <Label>\n <HiddenInput {...rest} ref={ref} type=\"radio\" />\n <StyledRadio />\n <span>{label}</span>\n </Label>\n );\n}\n\nconst Radio = React.forwardRef<HTMLInputElement, RadioProps>(RadioComponent);\nexport default Radio;\n"],"names":["Label","styled","StyledRadio","getThemeValue","THEME_NAME","BORDER_COLOR","BACKGROUND","HiddenInput","PRIMARY","PRIMARY_LIGHT","DISABLED_BORDER","LIGHT_GREY","RadioComponent","props","ref","label","rest","_jsxs","_jsx","type","span","Radio","React","forwardRef"],"mappings":";;;;;AAIA,MAAMA,OAAAA,iBAAQC,MAAAA,CAAAA,OAAAA,EAAAA;;;;AAQd,MAAMC,WAAAA,iBAAcD,MAAAA,CAAAA,MAAAA,EAAAA;;;AAIIE,CAAAA,CAAAA,CAAAA,2DAAAA,EAAAA,aAAAA,CAAcC,UAAAA,CAAWC,YAAY,CAAA,EAAA,gOAAA,EAevBF,aAAAA,CAAcC,WAAWE,UAAU,CAAA,EAAA,2CAAA,CAAA;AAMzE,MAAMC,WAAAA,iBAAcN,MAAAA,CAAAA,OAAAA,EAAAA;;;yEAQFC,WAAAA,EAAAA,gBAAAA,EACMC,aAAAA,CAAcC,UAAAA,CAAWI,OAAO,CAAA,EAAA,oBAAA,EAC5BL,aAAAA,CAAcC,UAAAA,CAAWI,OAAO,CAAA,EAAA,gBAAA,EAG1CN,WAAAA,EAAAA,uCAAAA,EAKMA,WAAAA,EAAAA,gBAAAA,EACAC,aAAAA,CAAcC,UAAAA,CAAWI,OAAO,6BACxBL,aAAAA,CAAcC,UAAAA,CAAWK,aAAa,CAAA,EAAA,8BAAA,EAGtCP,WAAAA,EAAAA,gBAAAA,EACRC,aAAAA,CAAcC,UAAAA,CAAWI,OAAO,CAAA,EAAA,wBAAA,EACxBL,aAAAA,CAAcC,UAAAA,CAAWK,aAAa,CAAA,EAAA,sBAAA,EAI9CP,WAAAA,EAAAA,gBAAAA,EACAC,cAAcC,UAAAA,CAAWI,OAAO,CAAA,EAAA,iCAAA,EAIvCL,aAAAA,CAAcC,UAAAA,CAAWI,OAAO,CAAA,EAAA,iBAAA,EAI9BN,WAAAA,EAAAA,gBAAAA,EACKC,aAAAA,CAAcC,UAAAA,CAAWM,eAAe,CAAA,EAAA,oBAAA,EACpCP,aAAAA,CAAcC,UAAAA,CAAWO,UAAU,CAAA,EAAA,4CAAA,EAIpCT,WAAAA,EAAAA,gBAAAA,EACHC,aAAAA,CAAcC,UAAAA,CAAWM,eAAe,CAAA,EAAA,oBAAA,EACpCP,aAAAA,CAAcC,UAAAA,CAAWM,eAAe,CAAA,EAAA,4BAAA,EAInDP,aAAAA,CAAcC,UAAAA,CAAWM,eAAe,CAAA,EAAA,uBAAA,CAAA;AAUzD;;;;AAIC,IACD,SAASE,cAAAA,CAAeC,KAAiB,EAAEC,GAAgC,EAAA;AACvE,IAAA,MAAM,EAAEC,KAAK,EAAE,GAAGC,MAAM,GAAGH,KAAAA;AAE3B,IAAA,qBACII,IAAA,CAACjB,OAAAA,EAAAA;;0BACGkB,GAAA,CAACX,WAAAA,EAAAA;AAAa,gBAAA,GAAGS,IAAI;gBAAEF,GAAAA,EAAKA,GAAAA;gBAAKK,IAAAA,EAAK;;0BACtCD,GAAA,CAAChB,WAAAA,EAAAA,EAAAA,CAAAA;0BACDgB,GAAA,CAACE,MAAAA,EAAAA;AAAML,gBAAAA,QAAAA,EAAAA;;;;AAGnB;AAEA,MAAMM,KAAAA,iBAAQC,KAAAA,CAAMC,UAAU,CAA+BX,cAAAA;;;;"}
1
+ {"version":3,"file":"Radio.js","sources":["../../../src/components/Input/Radio.tsx"],"sourcesContent":["import React, { useEffect, useId, useRef, useImperativeHandle } from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\nconst Label = styled.label`\n display: inline-flex;\n align-items: center;\n margin: 5px 10px 5px 0;\n cursor: pointer;\n position: relative;\n`;\n\nconst StyledRadio = styled.span`\n width: 16px;\n height: 16px;\n margin-right: 5px;\n border: 1px solid ${getThemeValue(THEME_NAME.BORDER_COLOR)};\n border-radius: 50%;\n display: block;\n transition: background-color 0.3s ease;\n position: relative;\n flex-shrink: 0;\n\n &::after {\n content: '';\n width: 100%;\n height: 100%;\n border-radius: 50%;\n position: absolute;\n top: 0;\n left: 0;\n box-shadow: inset 0 0 0 3px ${getThemeValue(THEME_NAME.BACKGROUND)};\n opacity: 0;\n transition: opacity 0.2s ease;\n }\n`;\n\nconst HiddenInput = styled.input`\n opacity: 0;\n width: 0;\n height: 0;\n position: absolute;\n margin: 0;\n\n /* checked */\n &:checked + ${StyledRadio} {\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n background-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n &:checked + ${StyledRadio}::after {\n opacity: 1;\n }\n\n /* focus */\n &:enabled:focus + ${StyledRadio} {\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n box-shadow: 0 0 0 3px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n &:enabled:checked:focus + ${StyledRadio} {\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n box-shadow: 0 0 0 3px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n /* hover */\n &:enabled:hover + ${StyledRadio} {\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n &:enabled:hover ~ span {\n color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /* disabled */\n &:disabled + ${StyledRadio} {\n border-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n background-color: ${getThemeValue(THEME_NAME.LIGHT_GREY)};\n cursor: not-allowed;\n }\n\n &:disabled:checked + ${StyledRadio} {\n border-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n background-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n }\n\n &:disabled ~ span {\n color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n cursor: not-allowed;\n }\n`;\n\ntype RadioProps = {\n /** Label for the field */\n label?: string;\n /** Error text to be shown below the field */\n errorText?: string;\n} & React.InputHTMLAttributes<HTMLInputElement>;\n\n/**\n * Radio Component\n * @param props - Component props\n * @param forwardedRef - Ref forwarded to the underlying HTMLInputElement\n */\nfunction RadioComponent(props: RadioProps, forwardedRef: React.Ref<HTMLInputElement>) {\n const { label, errorText, ...rest } = props;\n const internalRef = useRef<HTMLInputElement>(null);\n const errorId = useId();\n\n useImperativeHandle(forwardedRef, () => internalRef.current as HTMLInputElement);\n\n useEffect(() => {\n if (internalRef.current) {\n internalRef.current.setCustomValidity(errorText || '');\n }\n }, [errorText]);\n\n return (\n <Label>\n <HiddenInput\n {...rest}\n ref={internalRef}\n type=\"radio\"\n aria-invalid={!!errorText}\n aria-describedby={errorText ? errorId : undefined}\n />\n <StyledRadio />\n <span>{label}</span>\n </Label>\n );\n}\n\nconst Radio = React.forwardRef<HTMLInputElement, RadioProps>(RadioComponent);\nexport default Radio;\n"],"names":["Label","styled","StyledRadio","getThemeValue","THEME_NAME","BORDER_COLOR","BACKGROUND","HiddenInput","PRIMARY","PRIMARY_LIGHT","DISABLED_BORDER","LIGHT_GREY","RadioComponent","props","forwardedRef","label","errorText","rest","internalRef","useRef","errorId","useId","useImperativeHandle","current","useEffect","setCustomValidity","_jsxs","_jsx","ref","type","aria-invalid","aria-describedby","undefined","span","Radio","React","forwardRef"],"mappings":";;;;;AAIA,MAAMA,OAAAA,iBAAQC,MAAAA,CAAAA,OAAAA,EAAAA;;;;AAQd,MAAMC,WAAAA,iBAAcD,MAAAA,CAAAA,MAAAA,EAAAA;;;AAIIE,CAAAA,CAAAA,CAAAA,2DAAAA,EAAAA,aAAAA,CAAcC,UAAAA,CAAWC,YAAY,CAAA,EAAA,gOAAA,EAevBF,aAAAA,CAAcC,WAAWE,UAAU,CAAA,EAAA,2CAAA,CAAA;AAMzE,MAAMC,WAAAA,iBAAcN,MAAAA,CAAAA,OAAAA,EAAAA;;;yEAQFC,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A;IAEhBC,mBAAAA,CAAoBR,YAAAA,EAAc,IAAMI,WAAAA,CAAYK,OAAO,CAAA;IAE3DC,SAAAA,CAAU,IAAA;QACN,IAAIN,WAAAA,CAAYK,OAAO,EAAE;AACrBL,YAAAA,WAAAA,CAAYK,OAAO,CAACE,iBAAiB,CAACT,SAAAA,IAAa,EAAA,CAAA;AACvD,QAAA;IACJ,CAAA,EAAG;AAACA,QAAAA;AAAU,KAAA,CAAA;AAEd,IAAA,qBACIU,IAAA,CAAC1B,OAAAA,EAAAA;;0BACG2B,GAAA,CAACpB,WAAAA,EAAAA;AACI,gBAAA,GAAGU,IAAI;gBACRW,GAAAA,EAAKV,WAAAA;gBACLW,IAAAA,EAAK,OAAA;AACLC,gBAAAA,cAAAA,EAAc,CAAC,CAACd,SAAAA;AAChBe,gBAAAA,kBAAAA,EAAkBf,YAAYI,OAAAA,GAAUY;;0BAE5CL,GAAA,CAACzB,WAAAA,EAAAA,EAAAA,CAAAA;0BACDyB,GAAA,CAACM,MAAAA,EAAAA;AAAMlB,gBAAAA,QAAAA,EAAAA;;;;AAGnB;AAEA,MAAMmB,KAAAA,iBAAQC,KAAAA,CAAMC,UAAU,CAA+BxB,cAAAA;;;;"}
@@ -6,5 +6,7 @@ export declare const RadioGroup: import("@emotion/styled").StyledComponent<{
6
6
  declare const RadioButton: React.ForwardRefExoticComponent<{
7
7
  /** Label for the field */
8
8
  label?: string;
9
+ /** Error text to be shown below the field */
10
+ errorText?: string;
9
11
  } & React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
10
12
  export default RadioButton;
@@ -1,32 +1,44 @@
1
1
  import { jsxs, jsx } from '@emotion/react/jsx-runtime';
2
- import React from 'react';
2
+ import React, { useRef, useId, useImperativeHandle, useEffect } from 'react';
3
3
  import styled from '@emotion/styled';
4
4
  import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
5
5
 
6
6
  const Input = /*#__PURE__*/ styled("input", {
7
- target: "e1yp0s5y0",
7
+ target: "e76n0060",
8
8
  label: "Input"
9
9
  })("appearance:none;margin:0;width:0;& + span{color:", getThemeValue(THEME_NAME.PRIMARY), ";padding:6px 12px;border:none;border:1px solid ", getThemeValue(THEME_NAME.PRIMARY), ";cursor:pointer;margin-right:-1px;line-height:18px;}&:enabled:focus + span{box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}&:enabled:hover + span{background-color:", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";color:", getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT), ";}&:enabled:checked + span{background-color:", getThemeValue(THEME_NAME.PRIMARY), ";color:", getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT), ";}&:disabled + span{background-color:", getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR), ";color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";}&:disabled:checked + span{background-color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";color:", getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT), ";}");
10
10
  const Label = /*#__PURE__*/ styled("label", {
11
- target: "e1yp0s5y1",
11
+ target: "e76n0061",
12
12
  label: "Label"
13
13
  })("display:inline-flex;&:focus-within{z-index:1;}");
14
14
  const RadioGroup = /*#__PURE__*/ styled("div", {
15
- target: "e1yp0s5y2",
15
+ target: "e76n0062",
16
16
  label: "RadioGroup"
17
- })("display:inline-flex;align-items:center;border-radius:3px;margin:5px 0;& ", Label, ":first-child > span{border-radius:3px 0 0 3px;}& ", Label, ":last-child > span{border-radius:0 3px 3px 0;}");
17
+ })("display:inline-flex;align-items:center;border-radius:3px;margin:5px 0;& > ", Label, ":first-of-type > span{border-radius:3px 0 0 3px;}& > ", Label, ":last-of-type > span{border-radius:0 3px 3px 0;}");
18
18
  /**
19
19
  * RadioButton Component
20
20
  * @param props - Component props
21
- * @param ref - Ref forwarded to the underlying HTMLInputElement
22
- */ function RadioButtonComponent(props, ref) {
23
- const { label, ...rest } = props;
21
+ * @param forwardedRef - Ref forwarded to the underlying HTMLInputElement
22
+ */ function RadioButtonComponent(props, forwardedRef) {
23
+ const { label, errorText, ...rest } = props;
24
+ const internalRef = useRef(null);
25
+ const errorId = useId();
26
+ useImperativeHandle(forwardedRef, ()=>internalRef.current);
27
+ useEffect(()=>{
28
+ if (internalRef.current) {
29
+ internalRef.current.setCustomValidity(errorText || '');
30
+ }
31
+ }, [
32
+ errorText
33
+ ]);
24
34
  return /*#__PURE__*/ jsxs(Label, {
25
35
  children: [
26
36
  /*#__PURE__*/ jsx(Input, {
27
37
  ...rest,
28
38
  type: "radio",
29
- ref: ref
39
+ ref: internalRef,
40
+ "aria-invalid": !!errorText,
41
+ "aria-describedby": errorText ? errorId : undefined
30
42
  }),
31
43
  /*#__PURE__*/ jsx("span", {
32
44
  children: label
@@ -1 +1 @@
1
- {"version":3,"file":"RadioButton.js","sources":["../../../src/components/Input/RadioButton.tsx"],"sourcesContent":["import React from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\nconst Input = styled.input`\n appearance: none;\n margin: 0;\n width: 0;\n\n & + span {\n color: ${getThemeValue(THEME_NAME.PRIMARY)};\n padding: 6px 12px;\n border: none;\n border: 1px solid ${getThemeValue(THEME_NAME.PRIMARY)};\n cursor: pointer;\n margin-right: -1px;\n line-height: 18px;\n }\n\n &:enabled:focus + span {\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n &:enabled:hover + span {\n background-color: ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n color: ${getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT)};\n }\n\n &:enabled:checked + span {\n background-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n color: ${getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT)};\n }\n\n &:disabled + span {\n background-color: ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};\n color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n }\n\n &:disabled:checked + span {\n background-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n color: ${getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT)};\n }\n`;\n\nconst Label = styled.label`\n display: inline-flex;\n\n &:focus-within {\n z-index: 1;\n }\n`;\n\nexport const RadioGroup = styled.div`\n display: inline-flex;\n align-items: center;\n border-radius: 3px;\n margin: 5px 0;\n\n & ${Label}:first-child > span {\n border-radius: 3px 0 0 3px;\n }\n\n & ${Label}:last-child > span {\n border-radius: 0 3px 3px 0;\n }\n`;\n\ntype RadioButtonProps = {\n /** Label for the field */\n label?: string;\n} & React.InputHTMLAttributes<HTMLInputElement>;\n\n/**\n * RadioButton Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLInputElement\n */\nfunction RadioButtonComponent(props: RadioButtonProps, ref: React.Ref<HTMLInputElement>) {\n const { label, ...rest } = props;\n return (\n <Label>\n <Input {...rest} type=\"radio\" ref={ref} />\n <span>{label}</span>\n </Label>\n );\n}\n\nconst RadioButton = React.forwardRef(RadioButtonComponent);\nexport default RadioButton;\n"],"names":["Input","styled","getThemeValue","THEME_NAME","PRIMARY","PRIMARY_LIGHT","TEXT_COLOR_LIGHT","BORDER_LIGHT_COLOR","DISABLED_BORDER","Label","RadioGroup","RadioButtonComponent","props","ref","label","rest","_jsxs","_jsx","type","span","RadioButton","React","forwardRef"],"mappings":";;;;;AAIA,MAAMA,KAAAA,iBAAQC,MAAAA,CAAAA,OAAAA,EAAAA;;;AAMGC,CAAAA,CAAAA,CAAAA,kDAAAA,EAAAA,aAAAA,CAAcC,WAAWC,OAAO,CAAA,EAAA,iDAAA,EAGrBF,cAAcC,UAAAA,CAAWC,OAAO,uGAO5BF,aAAAA,CAAcC,UAAAA,CAAWE,aAAa,CAAA,EAAA,4CAAA,EAI1CH,cAAcC,UAAAA,CAAWE,aAAa,cACjDH,aAAAA,CAAcC,UAAAA,CAAWG,gBAAgB,CAAA,EAAA,8CAAA,EAI9BJ,aAAAA,CAAcC,UAAAA,CAAWC,OAAO,cAC3CF,aAAAA,CAAcC,UAAAA,CAAWG,gBAAgB,CAAA,EAAA,uCAAA,EAI9BJ,aAAAA,CAAcC,WAAWI,kBAAkB,CAAA,EAAA,SAAA,EACtDL,cAAcC,UAAAA,CAAWK,eAAe,oDAI7BN,aAAAA,CAAcC,UAAAA,CAAWK,eAAe,CAAA,EAAA,SAAA,EACnDN,aAAAA,CAAcC,WAAWG,gBAAgB,CAAA,EAAA,IAAA,CAAA;AAI1D,MAAMG,KAAAA,iBAAQR,MAAAA,CAAAA,OAAAA,EAAAA;;;;MAQDS,UAAAA,iBAAaT,MAAAA,CAAAA,KAAAA,EAAAA;;;AAMlBQ,CAAAA,CAAAA,CAAAA,0EAAAA,EAAAA,KAAAA,EAAAA,mDAAAA,EAIAA,KAAAA,EAAAA,gDAAAA;AAUR;;;;AAIC,IACD,SAASE,oBAAAA,CAAqBC,KAAuB,EAAEC,GAAgC,EAAA;AACnF,IAAA,MAAM,EAAEC,KAAK,EAAE,GAAGC,MAAM,GAAGH,KAAAA;AAC3B,IAAA,qBACII,IAAA,CAACP,KAAAA,EAAAA;;0BACGQ,GAAA,CAACjB,KAAAA,EAAAA;AAAO,gBAAA,GAAGe,IAAI;gBAAEG,IAAAA,EAAK,OAAA;gBAAQL,GAAAA,EAAKA;;0BACnCI,GAAA,CAACE,MAAAA,EAAAA;AAAML,gBAAAA,QAAAA,EAAAA;;;;AAGnB;AAEA,MAAMM,WAAAA,iBAAcC,KAAAA,CAAMC,UAAU,CAACX,oBAAAA;;;;"}
1
+ {"version":3,"file":"RadioButton.js","sources":["../../../src/components/Input/RadioButton.tsx"],"sourcesContent":["import React, { useEffect, useId, useRef, useImperativeHandle } from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\nconst Input = styled.input`\n appearance: none;\n margin: 0;\n width: 0;\n\n & + span {\n color: ${getThemeValue(THEME_NAME.PRIMARY)};\n padding: 6px 12px;\n border: none;\n border: 1px solid ${getThemeValue(THEME_NAME.PRIMARY)};\n cursor: pointer;\n margin-right: -1px;\n line-height: 18px;\n }\n\n &:enabled:focus + span {\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n &:enabled:hover + span {\n background-color: ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n color: ${getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT)};\n }\n\n &:enabled:checked + span {\n background-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n color: ${getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT)};\n }\n\n &:disabled + span {\n background-color: ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};\n color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n }\n\n &:disabled:checked + span {\n background-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n color: ${getThemeValue(THEME_NAME.TEXT_COLOR_LIGHT)};\n }\n`;\n\nconst Label = styled.label`\n display: inline-flex;\n\n &:focus-within {\n z-index: 1;\n }\n`;\n\nexport const RadioGroup = styled.div`\n display: inline-flex;\n align-items: center;\n border-radius: 3px;\n margin: 5px 0;\n\n & > ${Label}:first-of-type > span {\n border-radius: 3px 0 0 3px;\n }\n\n & > ${Label}:last-of-type > span {\n border-radius: 0 3px 3px 0;\n }\n`;\n\ntype RadioButtonProps = {\n /** Label for the field */\n label?: string;\n /** Error text to be shown below the field */\n errorText?: string;\n} & React.InputHTMLAttributes<HTMLInputElement>;\n\n/**\n * RadioButton Component\n * @param props - Component props\n * @param forwardedRef - Ref forwarded to the underlying HTMLInputElement\n */\nfunction RadioButtonComponent(props: RadioButtonProps, forwardedRef: React.Ref<HTMLInputElement>) {\n const { label, errorText, ...rest } = props;\n const internalRef = useRef<HTMLInputElement>(null);\n const errorId = useId();\n\n useImperativeHandle(forwardedRef, () => internalRef.current as HTMLInputElement);\n\n useEffect(() => {\n if (internalRef.current) {\n internalRef.current.setCustomValidity(errorText || '');\n }\n }, [errorText]);\n\n return (\n <Label>\n <Input\n {...rest}\n type=\"radio\"\n ref={internalRef}\n aria-invalid={!!errorText}\n aria-describedby={errorText ? errorId : undefined}\n />\n <span>{label}</span>\n </Label>\n );\n}\n\nconst RadioButton = React.forwardRef(RadioButtonComponent);\nexport default RadioButton;\n"],"names":["Input","styled","getThemeValue","THEME_NAME","PRIMARY","PRIMARY_LIGHT","TEXT_COLOR_LIGHT","BORDER_LIGHT_COLOR","DISABLED_BORDER","Label","RadioGroup","RadioButtonComponent","props","forwardedRef","label","errorText","rest","internalRef","useRef","errorId","useId","useImperativeHandle","current","useEffect","setCustomValidity","_jsxs","_jsx","type","ref","aria-invalid","aria-describedby","undefined","span","RadioButton","React","forwardRef"],"mappings":";;;;;AAIA,MAAMA,KAAAA,iBAAQC,MAAAA,CAAAA,OAAAA,EAAAA;;;AAMGC,CAAAA,CAAAA,CAAAA,kDAAAA,EAAAA,aAAAA,CAAcC,WAAWC,OAAO,CAAA,EAAA,iDAAA,EAGrBF,cAAcC,UAAAA,CAAWC,OAAO,uGAO5BF,aAAAA,CAAcC,UAAAA,CAAWE,aAAa,CAAA,EAAA,4CAAA,EAI1CH,cAAcC,UAAAA,CAAWE,aAAa,cACjDH,aAAAA,CAAcC,UAAAA,CAAWG,gBAAgB,CAAA,EAAA,8CAAA,EAI9BJ,aAAAA,CAAcC,UAAAA,CAAWC,OAAO,cAC3CF,aAAAA,CAAcC,UAAAA,CAAWG,gBAAgB,CAAA,EAAA,uCAAA,EAI9BJ,aAAAA,CAAcC,WAAWI,kBAAkB,CAAA,EAAA,SAAA,EACtDL,cAAcC,UAAAA,CAAWK,eAAe,oDAI7BN,aAAAA,CAAcC,UAAAA,CAAWK,eAAe,CAAA,EAAA,SAAA,EACnDN,aAAAA,CAAcC,WAAWG,gBAAgB,CAAA,EAAA,IAAA,CAAA;AAI1D,MAAMG,KAAAA,iBAAQR,MAAAA,CAAAA,OAAAA,EAAAA;;;;MAQDS,UAAAA,iBAAaT,MAAAA,CAAAA,KAAAA,EAAAA;;;AAMhBQ,CAAAA,CAAAA,CAAAA,4EAAAA,EAAAA,KAAAA,EAAAA,uDAAAA,EAIAA,KAAAA,EAAAA,kDAAAA;AAYV;;;;AAIC,IACD,SAASE,oBAAAA,CAAqBC,KAAuB,EAAEC,YAAyC,EAAA;AAC5F,IAAA,MAAM,EAAEC,KAAK,EAAEC,SAAS,EAAE,GAAGC,MAAM,GAAGJ,KAAAA;AACtC,IAAA,MAAMK,cAAcC,MAAAA,CAAyB,IAAA,CAAA;AAC7C,IAAA,MAAMC,OAAAA,GAAUC,KAAAA,EAAAA;IAEhBC,mBAAAA,CAAoBR,YAAAA,EAAc,IAAMI,WAAAA,CAAYK,OAAO,CAAA;IAE3DC,SAAAA,CAAU,IAAA;QACN,IAAIN,WAAAA,CAAYK,OAAO,EAAE;AACrBL,YAAAA,WAAAA,CAAYK,OAAO,CAACE,iBAAiB,CAACT,SAAAA,IAAa,EAAA,CAAA;AACvD,QAAA;IACJ,CAAA,EAAG;AAACA,QAAAA;AAAU,KAAA,CAAA;AAEd,IAAA,qBACIU,IAAA,CAAChB,KAAAA,EAAAA;;0BACGiB,GAAA,CAAC1B,KAAAA,EAAAA;AACI,gBAAA,GAAGgB,IAAI;gBACRW,IAAAA,EAAK,OAAA;gBACLC,GAAAA,EAAKX,WAAAA;AACLY,gBAAAA,cAAAA,EAAc,CAAC,CAACd,SAAAA;AAChBe,gBAAAA,kBAAAA,EAAkBf,YAAYI,OAAAA,GAAUY;;0BAE5CL,GAAA,CAACM,MAAAA,EAAAA;AAAMlB,gBAAAA,QAAAA,EAAAA;;;;AAGnB;AAEA,MAAMmB,WAAAA,iBAAcC,KAAAA,CAAMC,UAAU,CAACxB,oBAAAA;;;;"}
@@ -1,15 +1,15 @@
1
1
  import { jsxs, jsx } from '@emotion/react/jsx-runtime';
2
- import React, { useState, useId, useRef, useEffect } from 'react';
2
+ import React, { useState, useId, useRef, useImperativeHandle, useEffect } from 'react';
3
3
  import styled from '@emotion/styled';
4
4
  import ExpandMore from '../../icons/ExpandMore.js';
5
5
  import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
6
6
 
7
7
  const Label$3 = /*#__PURE__*/ styled("label", {
8
- target: "e13b7jm0",
8
+ target: "e1trg58l0",
9
9
  label: "Label"
10
10
  })("display:inline-flex;flex-direction:column;position:relative;margin:10px 5px;pointer-events:none;max-width:268px;& svg{fill:currentColor;}");
11
11
  const SelectField = /*#__PURE__*/ styled("select", {
12
- target: "e13b7jm1",
12
+ target: "e1trg58l1",
13
13
  label: "SelectField"
14
14
  })("border:none;color:inherit;padding:0 8px;line-height:30px;min-height:32px;width:268px;border-radius:3px;border:1px solid ", getThemeValue(THEME_NAME.BORDER_COLOR), ";display:inline-block;background-color:", getThemeValue(THEME_NAME.BACKGROUND), ";pointer-events:auto;appearance:none;&:focus,&:active{border-color:", getThemeValue(THEME_NAME.PRIMARY), ";box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}&:focus ~ span,&:active ~ span{color:", getThemeValue(THEME_NAME.PRIMARY), ";}&:disabled{border-color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";background-color:", getThemeValue(THEME_NAME.DISABLED_BACKGROUND), ";}&:disabled ~ span{color:", getThemeValue(THEME_NAME.DISABLED), ";}&:focus:invalid{border-color:", getThemeValue(THEME_NAME.ERROR), ";box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.ERROR_LIGHT), ";}", (props)=>props.touched ? `
15
15
  &:invalid {
@@ -33,31 +33,41 @@ const SelectField = /*#__PURE__*/ styled("select", {
33
33
  line-height: 14px;
34
34
  }
35
35
  ` : '', " &:focus + span,&:placeholder-shown + span{top:-8px;background:", getThemeValue(THEME_NAME.BACKGROUND), ";font-size:12px;line-height:14px;}");
36
- const ErrorContainer$1 = /*#__PURE__*/ styled("div", {
37
- target: "e13b7jm2",
36
+ const ErrorContainer$3 = /*#__PURE__*/ styled("div", {
37
+ target: "e1trg58l2",
38
38
  label: "ErrorContainer"
39
39
  })("color:", getThemeValue(THEME_NAME.ERROR), ";padding-top:3px;font-size:12px;line-height:14px;margin-left:3px;");
40
40
  const ArrowContainer$1 = /*#__PURE__*/ styled("span", {
41
- target: "e13b7jm3",
41
+ target: "e1trg58l3",
42
42
  label: "ArrowContainer"
43
43
  })("position:absolute;right:8px;top:8px;");
44
44
  /**
45
45
  * Select Component
46
46
  * @param props - Component props
47
47
  * @param ref - Ref forwarded to the underlying HTMLSelectElement
48
- */ function SelectComponent(props, ref) {
48
+ */ function SelectComponent(props, forwardedRef) {
49
49
  const [touched, setTouched] = useState(false);
50
50
  const [value, setValue] = useState(props.value || '');
51
51
  const errorId = useId();
52
52
  const prevValueRef = useRef(undefined);
53
+ const internalRef = useRef(null);
54
+ useImperativeHandle(forwardedRef, ()=>internalRef.current);
55
+ // Sync prop value with state
53
56
  useEffect(()=>{
54
- if (props.value !== undefined && props.value !== prevValueRef.current) {
55
- setValue(props.value);
57
+ if (props.value !== prevValueRef.current) {
58
+ setValue(props.value || '');
56
59
  prevValueRef.current = props.value;
57
60
  }
58
61
  }, [
59
62
  props.value
60
63
  ]);
64
+ useEffect(()=>{
65
+ if (internalRef.current) {
66
+ internalRef.current.setCustomValidity(props.errorText || '');
67
+ }
68
+ }, [
69
+ props.errorText
70
+ ]);
61
71
  const handleFocus = (e)=>{
62
72
  setTouched(true);
63
73
  if (props.onFocus) {
@@ -76,7 +86,7 @@ const ArrowContainer$1 = /*#__PURE__*/ styled("span", {
76
86
  children: [
77
87
  /*#__PURE__*/ jsxs(SelectField, {
78
88
  ...props,
79
- ref: ref,
89
+ ref: internalRef,
80
90
  multiple: false,
81
91
  value: value,
82
92
  onChange: onChangeHandler,
@@ -97,7 +107,7 @@ const ArrowContainer$1 = /*#__PURE__*/ styled("span", {
97
107
  "aria-hidden": "true",
98
108
  children: /*#__PURE__*/ jsx(ExpandMore, {})
99
109
  }),
100
- props.errorText && /*#__PURE__*/ jsx(ErrorContainer$1, {
110
+ props.errorText && /*#__PURE__*/ jsx(ErrorContainer$3, {
101
111
  id: errorId,
102
112
  children: props.errorText
103
113
  })
@@ -1 +1 @@
1
- {"version":3,"file":"Select.js","sources":["../../../src/components/Input/Select.tsx"],"sourcesContent":["import React, { useState, useEffect, useId, useRef } from 'react';\nimport styled from '@emotion/styled';\nimport ExpandMore from '../../icons/ExpandMore';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\ntype SelectProps = {\n /** Label for the field */\n label?: string;\n /** Error text to be shown below the field */\n errorText?: string;\n} & React.InputHTMLAttributes<HTMLSelectElement>;\n\ntype SelectInternalProps = SelectProps & {\n touched: boolean;\n};\n\nconst Label = styled.label`\n display: inline-flex;\n flex-direction: column;\n position: relative;\n margin: 10px 5px;\n pointer-events: none;\n max-width: 268px;\n\n & svg {\n fill: currentColor;\n }\n`;\n\nconst SelectField = styled.select<SelectInternalProps>`\n border: none;\n color: inherit;\n padding: 0 8px;\n line-height: 30px;\n min-height: 32px;\n width: 268px;\n border-radius: 3px;\n border: 1px solid ${getThemeValue(THEME_NAME.BORDER_COLOR)};\n display: inline-block;\n background-color: ${getThemeValue(THEME_NAME.BACKGROUND)};\n pointer-events: auto;\n appearance: none;\n\n /** Focused */\n &:focus,\n &:active {\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n &:focus ~ span,\n &:active ~ span {\n color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /** Disabled */\n &:disabled {\n border-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n background-color: ${getThemeValue(THEME_NAME.DISABLED_BACKGROUND)};\n }\n\n &:disabled ~ span {\n color: ${getThemeValue(THEME_NAME.DISABLED)};\n }\n\n /** Invalid */\n &:focus:invalid {\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.ERROR_LIGHT)};\n }\n\n ${(props) =>\n props.touched\n ? `\n &:invalid {\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n\n &:invalid ~ span {\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n `\n : ''}\n\n /** Error */\n ${(props) =>\n props.errorText\n ? `\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n\n & ~ span {\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n `\n : ''}\n\n /** Required */\n &:required + span:after {\n content: '*';\n margin-left: 2px;\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n\n /** Label Animation */\n & + span {\n position: absolute;\n padding: 0 5px;\n top: 0px;\n left: 4px;\n font-size: 14px;\n line-height: 32px;\n transition: all 300ms ease;\n }\n\n ${(props) =>\n props.value !== ''\n ? `\n & + span {\n top: -8px;\n background: ${getThemeValue(THEME_NAME.BACKGROUND)};\n font-size: 12px;\n line-height: 14px;\n }\n `\n : ''}\n\n &:focus + span, &:placeholder-shown + span {\n top: -8px;\n background: ${getThemeValue(THEME_NAME.BACKGROUND)};\n font-size: 12px;\n line-height: 14px;\n }\n`;\n\nconst ErrorContainer = styled.div`\n color: ${getThemeValue(THEME_NAME.ERROR)};\n padding-top: 3px;\n font-size: 12px;\n line-height: 14px;\n margin-left: 3px;\n`;\n\nconst ArrowContainer = styled.span`\n position: absolute;\n right: 8px;\n top: 8px;\n`;\n\n/**\n * Select Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLSelectElement\n */\nfunction SelectComponent(props: SelectProps, ref: React.Ref<HTMLSelectElement>) {\n const [touched, setTouched] = useState(false);\n const [value, setValue] = useState(props.value || '');\n const errorId = useId();\n const prevValueRef = useRef<string>(undefined);\n\n useEffect(() => {\n if (props.value !== undefined && props.value !== prevValueRef.current) {\n setValue(props.value);\n prevValueRef.current = props.value as string;\n }\n }, [props.value]);\n\n const handleFocus = (e: React.FocusEvent<HTMLSelectElement>) => {\n setTouched(true);\n if (props.onFocus) {\n props.onFocus(e);\n }\n };\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLSelectElement>) => {\n if (props.onChange) {\n setValue(e.target.value);\n props.onChange(e);\n } else {\n setValue(e.target.value);\n }\n };\n\n return (\n <Label>\n <SelectField\n {...props}\n ref={ref}\n multiple={false}\n value={value}\n onChange={onChangeHandler}\n onFocus={handleFocus}\n touched={touched}\n aria-invalid={!!props.errorText}\n aria-required={props.required}\n aria-describedby={props.errorText ? errorId : undefined}\n >\n <option />\n {props.children}\n </SelectField>\n <span>{props.label}</span>\n <ArrowContainer aria-hidden=\"true\">\n <ExpandMore />\n </ArrowContainer>\n {props.errorText && <ErrorContainer id={errorId}>{props.errorText}</ErrorContainer>}\n </Label>\n );\n}\n\nconst Select = React.forwardRef(SelectComponent);\nexport default Select;\n"],"names":["Label","styled","SelectField","getThemeValue","THEME_NAME","BORDER_COLOR","BACKGROUND","PRIMARY","PRIMARY_LIGHT","DISABLED_BORDER","DISABLED_BACKGROUND","DISABLED","ERROR","ERROR_LIGHT","props","touched","errorText","value","ErrorContainer","ArrowContainer","SelectComponent","ref","setTouched","useState","setValue","errorId","useId","prevValueRef","useRef","undefined","useEffect","current","handleFocus","e","onFocus","onChangeHandler","onChange","target","_jsxs","multiple","aria-invalid","aria-required","required","aria-describedby","_jsx","option","children","span","label","aria-hidden","ExpandMore","id","Select","React","forwardRef"],"mappings":";;;;;;AAgBA,MAAMA,OAAAA,iBAAQC,MAAAA,CAAAA,OAAAA,EAAAA;;;;AAad,MAAMC,WAAAA,iBAAcD,MAAAA,CAAAA,QAAAA,EAAAA;;;+HAQIE,aAAAA,CAAcC,UAAAA,CAAWC,YAAY,CAAA,EAAA,yCAAA,EAErCF,aAAAA,CAAcC,WAAWE,UAAU,CAAA,EAAA,qEAAA,EAOnCH,cAAcC,UAAAA,CAAWG,OAAO,6BACxBJ,aAAAA,CAAcC,UAAAA,CAAWI,aAAa,CAAA,EAAA,yCAAA,EAKrDL,aAAAA,CAAcC,WAAW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ACIqB,IAAA,CAACtC,OAAAA,EAAAA;;0BACGsC,IAAA,CAACpC,WAAAA,EAAAA;AACI,gBAAA,GAAGY,KAAK;gBACTO,GAAAA,EAAKA,GAAAA;gBACLkB,QAAAA,EAAU,KAAA;gBACVtB,KAAAA,EAAOA,KAAAA;gBACPmB,QAAAA,EAAUD,eAAAA;gBACVD,OAAAA,EAASF,WAAAA;gBACTjB,OAAAA,EAASA,OAAAA;gBACTyB,cAAAA,EAAc,CAAC,CAAC1B,KAAAA,CAAME,SAAS;AAC/ByB,gBAAAA,eAAAA,EAAe3B,MAAM4B,QAAQ;gBAC7BC,kBAAAA,EAAkB7B,KAAAA,CAAME,SAAS,GAAGS,OAAAA,GAAUI,SAAAA;;kCAE9Ce,GAAA,CAACC,QAAAA,EAAAA,EAAAA,CAAAA;AACA/B,oBAAAA,KAAAA,CAAMgC;;;0BAEXF,GAAA,CAACG,MAAAA,EAAAA;AAAMjC,gBAAAA,QAAAA,EAAAA,KAAAA,CAAMkC;;0BACbJ,GAAA,CAACzB,gBAAAA,EAAAA;gBAAe8B,aAAAA,EAAY,MAAA;AACxB,gBAAA,QAAA,gBAAAL,GAAA,CAACM,UAAAA,EAAAA,EAAAA;;YAEJpC,KAAAA,CAAME,SAAS,kBAAI4B,GAAA,CAAC1B,gBAAAA,EAAAA;gBAAeiC,EAAAA,EAAI1B,OAAAA;AAAUX,gBAAAA,QAAAA,EAAAA,KAAAA,CAAME;;;;AAGpE;AAEA,MAAMoC,MAAAA,iBAASC,KAAAA,CAAMC,UAAU,CAAClC,eAAAA;;;;"}
1
+ {"version":3,"file":"Select.js","sources":["../../../src/components/Input/Select.tsx"],"sourcesContent":["import React, { useState, useEffect, useId, useRef, useImperativeHandle } from 'react';\nimport styled from '@emotion/styled';\nimport ExpandMore from '../../icons/ExpandMore';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\ntype SelectProps = {\n /** Label for the field */\n label?: string;\n /** Error text to be shown below the field */\n errorText?: string;\n} & React.InputHTMLAttributes<HTMLSelectElement>;\n\ntype SelectInternalProps = SelectProps & {\n touched: boolean;\n};\n\nconst Label = styled.label`\n display: inline-flex;\n flex-direction: column;\n position: relative;\n margin: 10px 5px;\n pointer-events: none;\n max-width: 268px;\n\n & svg {\n fill: currentColor;\n }\n`;\n\nconst SelectField = styled.select<SelectInternalProps>`\n border: none;\n color: inherit;\n padding: 0 8px;\n line-height: 30px;\n min-height: 32px;\n width: 268px;\n border-radius: 3px;\n border: 1px solid ${getThemeValue(THEME_NAME.BORDER_COLOR)};\n display: inline-block;\n background-color: ${getThemeValue(THEME_NAME.BACKGROUND)};\n pointer-events: auto;\n appearance: none;\n\n /** Focused */\n &:focus,\n &:active {\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n &:focus ~ span,\n &:active ~ span {\n color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /** Disabled */\n &:disabled {\n border-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n background-color: ${getThemeValue(THEME_NAME.DISABLED_BACKGROUND)};\n }\n\n &:disabled ~ span {\n color: ${getThemeValue(THEME_NAME.DISABLED)};\n }\n\n /** Invalid */\n &:focus:invalid {\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.ERROR_LIGHT)};\n }\n\n ${(props) =>\n props.touched\n ? `\n &:invalid {\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n\n &:invalid ~ span {\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n `\n : ''}\n\n /** Error */\n ${(props) =>\n props.errorText\n ? `\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n\n & ~ span {\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n `\n : ''}\n\n /** Required */\n &:required + span:after {\n content: '*';\n margin-left: 2px;\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n\n /** Label Animation */\n & + span {\n position: absolute;\n padding: 0 5px;\n top: 0px;\n left: 4px;\n font-size: 14px;\n line-height: 32px;\n transition: all 300ms ease;\n }\n\n ${(props) =>\n props.value !== ''\n ? `\n & + span {\n top: -8px;\n background: ${getThemeValue(THEME_NAME.BACKGROUND)};\n font-size: 12px;\n line-height: 14px;\n }\n `\n : ''}\n\n &:focus + span, &:placeholder-shown + span {\n top: -8px;\n background: ${getThemeValue(THEME_NAME.BACKGROUND)};\n font-size: 12px;\n line-height: 14px;\n }\n`;\n\nconst ErrorContainer = styled.div`\n color: ${getThemeValue(THEME_NAME.ERROR)};\n padding-top: 3px;\n font-size: 12px;\n line-height: 14px;\n margin-left: 3px;\n`;\n\nconst ArrowContainer = styled.span`\n position: absolute;\n right: 8px;\n top: 8px;\n`;\n\n/**\n * Select Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLSelectElement\n */\nfunction SelectComponent(props: SelectProps, forwardedRef: React.Ref<HTMLSelectElement>) {\n const [touched, setTouched] = useState(false);\n const [value, setValue] = useState(props.value || '');\n const errorId = useId();\n const prevValueRef = useRef<string>(undefined);\n const internalRef = useRef<HTMLSelectElement>(null);\n\n useImperativeHandle(forwardedRef, () => internalRef.current as HTMLSelectElement);\n\n // Sync prop value with state\n useEffect(() => {\n if (props.value !== prevValueRef.current) {\n setValue(props.value || '');\n prevValueRef.current = props.value as string;\n }\n }, [props.value]);\n\n useEffect(() => {\n if (internalRef.current) {\n internalRef.current.setCustomValidity(props.errorText || '');\n }\n }, [props.errorText]);\n\n const handleFocus = (e: React.FocusEvent<HTMLSelectElement>) => {\n setTouched(true);\n if (props.onFocus) {\n props.onFocus(e);\n }\n };\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLSelectElement>) => {\n if (props.onChange) {\n setValue(e.target.value);\n props.onChange(e);\n } else {\n setValue(e.target.value);\n }\n };\n\n return (\n <Label>\n <SelectField\n {...props}\n ref={internalRef}\n multiple={false}\n value={value}\n onChange={onChangeHandler}\n onFocus={handleFocus}\n touched={touched}\n aria-invalid={!!props.errorText}\n aria-required={props.required}\n aria-describedby={props.errorText ? errorId : undefined}\n >\n <option />\n {props.children}\n </SelectField>\n <span>{props.label}</span>\n <ArrowContainer aria-hidden=\"true\">\n <ExpandMore />\n </ArrowContainer>\n {props.errorText && <ErrorContainer id={errorId}>{props.errorText}</ErrorContainer>}\n </Label>\n );\n}\n\nconst Select = React.forwardRef(SelectComponent);\nexport default Select;\n"],"names":["Label","styled","SelectField","getThemeValue","THEME_NAME","BORDER_COLOR","BACKGROUND","PRIMARY","PRIMARY_LIGHT","DISABLED_BORDER","DISABLED_BACKGROUND","DISABLED","ERROR","ERROR_LIGHT","props","touched","errorText","value","ErrorContainer","ArrowContainer","SelectComponent","forwardedRef","setTouched","useState","setValue","errorId","useId","prevValueRef","useRef","undefined","internalRef","useImperativeHandle","current","useEffect","setCustomValidity","handleFocus","e","onFocus","onChangeHandler","onChange","target","_jsxs","ref","multiple","aria-invalid","aria-required","required","aria-describedby","_jsx","option","children","span","label","aria-hidden","ExpandMore","id","Select","React","forwardRef"],"mappings":";;;;;;AAgBA,MAAMA,OAAAA,iBAAQC,MAAAA,CAAAA,OAAAA,EAAAA;;;;AAad,MAAMC,WAAAA,iBAAcD,MAAAA,CAAAA,QAAAA,EAAAA;;;+HAQIE,aAAAA,CAAcC,UAAAA,CAAWC,YAAY,CAAA,EAAA,yCAAA,EAErCF,aAAAA,CAAcC,WAAWE,UAAU,CAAA,EAAA,qEAAA,EAOnCH,cAAcC,UAAAA,CAAWG,OAAO,6BACxBJ,aAAAA,CAAcC,UAAAA,CAAWI,aAAa,CAAA,EAAA,yCAAA,EAKrDL,aAAAA,CAAcC,WAAWG,OAAO,CAAA,EAAA,4BAAA,EAKzBJ,cAAcC,UAAAA,CAAWK,eAAe,yBACpCN,aAAAA,CAAcC,UAAAA,CAAWM,mBAAmB,CAAA,EAAA,4BAAA,EAIvDP,aAAAA,CAAcC,WAAWO,QAA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useRef, useEffect } from 'react';
2
+ import React, { useState, useId, useRef, useImperativeHandle, useEffect } from 'react';
3
3
  import styled from '@emotion/styled';
4
4
  import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
5
5
 
6
6
  const Label$4 = /*#__PURE__*/ styled("label", {
7
- target: "e1j32tnv0",
7
+ target: "e1towgf50",
8
8
  label: "Label"
9
9
  })("display:inline-flex;flex-direction:column;position:relative;margin:10px 5px;");
10
10
  const TextField = /*#__PURE__*/ styled("textarea", {
11
- target: "e1j32tnv1",
11
+ target: "e1towgf51",
12
12
  label: "TextField"
13
13
  })("border:none;color:inherit;padding:8px;min-height:150px;min-width:250px;border-radius:3px;border:1px solid ", getThemeValue(THEME_NAME.BORDER_COLOR), ";display:inline-block;background-color:", getThemeValue(THEME_NAME.BACKGROUND), ";&:focus,&:active{border-color:", getThemeValue(THEME_NAME.PRIMARY), ";box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}&:focus + span,&:active + span{color:", getThemeValue(THEME_NAME.PRIMARY), ";}&:disabled{border-color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";background-color:", getThemeValue(THEME_NAME.DISABLED_BACKGROUND), ";}&:disabled + span{color:", getThemeValue(THEME_NAME.DISABLED), ";}&:focus:invalid{border-color:", getThemeValue(THEME_NAME.ERROR), ";box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.ERROR_LIGHT), ";}", (props)=>props.touched ? `
14
14
  &:invalid {
@@ -32,20 +32,22 @@ const TextField = /*#__PURE__*/ styled("textarea", {
32
32
  line-height: 14px;
33
33
  }
34
34
  ` : '', " &:focus + span,&:placeholder-shown + span{top:-8px;background:", getThemeValue(THEME_NAME.BACKGROUND), ";font-size:12px;line-height:14px;}");
35
- const ErrorContainer$2 = /*#__PURE__*/ styled("div", {
36
- target: "e1j32tnv2",
35
+ const ErrorContainer$4 = /*#__PURE__*/ styled("div", {
36
+ target: "e1towgf52",
37
37
  label: "ErrorContainer"
38
38
  })("color:", getThemeValue(THEME_NAME.ERROR), ";padding-top:3px;font-size:12px;line-height:14px;margin-left:3px;");
39
39
  /**
40
40
  * TextArea Component
41
41
  * @param props - Component props
42
42
  * @param ref - Ref forwarded to the underlying HTMLTextAreaElement
43
- */ function TextAreaComponent(props, ref) {
43
+ */ function TextAreaComponent(props, forwardedRef) {
44
44
  const { label, errorText, value: propsValue, required, ...rest } = props;
45
45
  const [touched, setTouched] = useState(false);
46
46
  const [value, setValue] = useState(propsValue || '');
47
47
  const errorId = useId();
48
48
  const prevValueRef = useRef(undefined);
49
+ const internalRef = useRef(null);
50
+ useImperativeHandle(forwardedRef, ()=>internalRef.current);
49
51
  useEffect(()=>{
50
52
  if (propsValue !== undefined && propsValue !== prevValueRef.current) {
51
53
  setValue(propsValue);
@@ -54,6 +56,13 @@ const ErrorContainer$2 = /*#__PURE__*/ styled("div", {
54
56
  }, [
55
57
  propsValue
56
58
  ]);
59
+ useEffect(()=>{
60
+ if (internalRef.current) {
61
+ internalRef.current.setCustomValidity(errorText || '');
62
+ }
63
+ }, [
64
+ errorText
65
+ ]);
57
66
  const handleFocus = (e)=>{
58
67
  setTouched(true);
59
68
  if (props.onFocus) {
@@ -72,7 +81,7 @@ const ErrorContainer$2 = /*#__PURE__*/ styled("div", {
72
81
  children: [
73
82
  /*#__PURE__*/ jsx(TextField, {
74
83
  ...rest,
75
- ref: ref,
84
+ ref: internalRef,
76
85
  value: value,
77
86
  onChange: onChangeHandler,
78
87
  onFocus: handleFocus,
@@ -85,7 +94,7 @@ const ErrorContainer$2 = /*#__PURE__*/ styled("div", {
85
94
  /*#__PURE__*/ jsx("span", {
86
95
  children: label
87
96
  }),
88
- errorText && /*#__PURE__*/ jsx(ErrorContainer$2, {
97
+ errorText && /*#__PURE__*/ jsx(ErrorContainer$4, {
89
98
  id: errorId,
90
99
  children: errorText
91
100
  })
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.js","sources":["../../../src/components/Input/TextArea.tsx"],"sourcesContent":["import React, { useState, useEffect, useId, useRef } from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\ntype TextAreaProps = {\n /** Label for the field */\n label: string;\n /** Error text to be shown below the field */\n errorText?: string;\n} & React.InputHTMLAttributes<HTMLTextAreaElement>;\n\ntype TextAreaInternalProps = {\n touched: boolean;\n errorText?: string;\n};\n\nconst Label = styled.label`\n display: inline-flex;\n flex-direction: column;\n position: relative;\n margin: 10px 5px;\n`;\n\nconst TextField = styled.textarea<TextAreaInternalProps>`\n border: none;\n color: inherit;\n padding: 8px;\n min-height: 150px;\n min-width: 250px;\n border-radius: 3px;\n border: 1px solid ${getThemeValue(THEME_NAME.BORDER_COLOR)};\n display: inline-block;\n background-color: ${getThemeValue(THEME_NAME.BACKGROUND)};\n\n /** Focused */\n &:focus,\n &:active {\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n &:focus + span,\n &:active + span {\n color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /** Disabled */\n &:disabled {\n border-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n background-color: ${getThemeValue(THEME_NAME.DISABLED_BACKGROUND)};\n }\n\n &:disabled + span {\n color: ${getThemeValue(THEME_NAME.DISABLED)};\n }\n\n /** Invalid */\n &:focus:invalid {\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.ERROR_LIGHT)};\n }\n\n ${(props) =>\n props.touched\n ? `\n &:invalid {\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n\n &:invalid + span {\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n `\n : ''}\n\n /** Error */\n ${(props) =>\n props.errorText\n ? `\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n\n & + span {\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n `\n : ''}\n\n /** Required */\n &:required + span:after {\n content: '*';\n margin-left: 2px;\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n\n /** Label Animation */\n & + span {\n position: absolute;\n padding: 0 5px;\n top: 0px;\n left: 4px;\n font-size: 14px;\n line-height: 32px;\n transition: all 300ms ease;\n }\n\n ${(props) =>\n props.value !== ''\n ? `\n & + span {\n top: -8px;\n background: ${getThemeValue(THEME_NAME.BACKGROUND)};\n font-size: 12px;\n line-height: 14px;\n }\n `\n : ''}\n\n &:focus + span, &:placeholder-shown + span {\n top: -8px;\n background: ${getThemeValue(THEME_NAME.BACKGROUND)};\n font-size: 12px;\n line-height: 14px;\n }\n`;\n\nconst ErrorContainer = styled.div`\n color: ${getThemeValue(THEME_NAME.ERROR)};\n padding-top: 3px;\n font-size: 12px;\n line-height: 14px;\n margin-left: 3px;\n`;\n\n/**\n * TextArea Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLTextAreaElement\n */\nfunction TextAreaComponent(props: TextAreaProps, ref: React.Ref<HTMLTextAreaElement>) {\n const { label, errorText, value: propsValue, required, ...rest } = props;\n const [touched, setTouched] = useState(false);\n const [value, setValue] = useState(propsValue || '');\n const errorId = useId();\n const prevValueRef = useRef<string>(undefined);\n\n useEffect(() => {\n if (propsValue !== undefined && propsValue !== prevValueRef.current) {\n setValue(propsValue);\n prevValueRef.current = propsValue as string;\n }\n }, [propsValue]);\n\n const handleFocus = (e: React.FocusEvent<HTMLTextAreaElement>) => {\n setTouched(true);\n if (props.onFocus) {\n props.onFocus(e);\n }\n };\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n if (props.onChange) {\n setValue(e.target.value);\n props.onChange(e);\n } else {\n setValue(e.target.value);\n }\n };\n\n return (\n <Label>\n <TextField\n {...rest}\n ref={ref}\n value={value}\n onChange={onChangeHandler}\n onFocus={handleFocus}\n touched={touched}\n required={required}\n aria-invalid={!!errorText}\n aria-required={required}\n aria-describedby={errorText ? errorId : undefined}\n />\n <span>{label}</span>\n {errorText && <ErrorContainer id={errorId}>{errorText}</ErrorContainer>}\n </Label>\n );\n}\n\nconst TextArea = React.forwardRef(TextAreaComponent);\nexport default TextArea;\n"],"names":["Label","styled","TextField","getThemeValue","THEME_NAME","BORDER_COLOR","BACKGROUND","PRIMARY","PRIMARY_LIGHT","DISABLED_BORDER","DISABLED_BACKGROUND","DISABLED","ERROR","ERROR_LIGHT","props","touched","errorText","value","ErrorContainer","TextAreaComponent","ref","label","propsValue","required","rest","setTouched","useState","setValue","errorId","useId","prevValueRef","useRef","undefined","useEffect","current","handleFocus","e","onFocus","onChangeHandler","onChange","target","_jsxs","_jsx","aria-invalid","aria-required","aria-describedby","span","id","TextArea","React","forwardRef"],"mappings":";;;;;AAgBA,MAAMA,OAAAA,iBAAQC,MAAAA,CAAAA,OAAAA,EAAAA;;;;AAOd,MAAMC,SAAAA,iBAAYD,MAAAA,CAAAA,UAAAA,EAAAA;;;iHAOME,aAAAA,CAAcC,UAAAA,CAAWC,YAAY,CAAA,EAAA,yCAAA,EAErCF,aAAAA,CAAcC,WAAWE,UAAU,CAAA,EAAA,iCAAA,EAKnCH,cAAcC,UAAAA,CAAWG,OAAO,6BACxBJ,aAAAA,CAAcC,UAAAA,CAAWI,aAAa,CAAA,EAAA,yCAAA,EAKrDL,aAAAA,CAAcC,WAAWG,OAAO,CAAA,EAAA,4BAAA,EAKzBJ,cAAcC,UAAAA,CAAWK,eAAe,yBACpCN,aAAAA,CAAcC,UAAAA,CAAWM,mBAAmB,CAAA,EAAA,4BAAA,EAIvDP,aAAAA,CAAcC,WAAWO,QAAQ,CAAA,EAAA,iCAAA,EAK1BR,cAAcC,UAAAA,CAAWQ,KAAK,6BACtBT,aAAAA,CAAcC,UAAAA,CAAWS,WAAW,CAAA,EAAA,IAAA,EAG9D,CAACC,QACCA,KAAAA,CAAMC,OAAO,GACP;;sBAEQ,EAAEZ,aAAAA,CAAcC,UAAAA,CAAWQ,KAAK,CAAA,CAAE;;;;e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UI;;0BAE5CU,GAAA,CAACI,MAAAA,EAAAA;AAAMzB,gBAAAA,QAAAA,EAAAA;;AACNL,YAAAA,SAAAA,kBAAa0B,GAAA,CAACxB,gBAAAA,EAAAA;gBAAe6B,EAAAA,EAAInB,OAAAA;AAAUZ,gBAAAA,QAAAA,EAAAA;;;;AAGxD;AAEA,MAAMgC,QAAAA,iBAAWC,KAAAA,CAAMC,UAAU,CAAC/B,iBAAAA;;;;"}
1
+ {"version":3,"file":"TextArea.js","sources":["../../../src/components/Input/TextArea.tsx"],"sourcesContent":["import React, { useState, useEffect, useId, useRef, useImperativeHandle } from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\ntype TextAreaProps = {\n /** Label for the field */\n label: string;\n /** Error text to be shown below the field */\n errorText?: string;\n} & React.InputHTMLAttributes<HTMLTextAreaElement>;\n\ntype TextAreaInternalProps = {\n touched: boolean;\n errorText?: string;\n};\n\nconst Label = styled.label`\n display: inline-flex;\n flex-direction: column;\n position: relative;\n margin: 10px 5px;\n`;\n\nconst TextField = styled.textarea<TextAreaInternalProps>`\n border: none;\n color: inherit;\n padding: 8px;\n min-height: 150px;\n min-width: 250px;\n border-radius: 3px;\n border: 1px solid ${getThemeValue(THEME_NAME.BORDER_COLOR)};\n display: inline-block;\n background-color: ${getThemeValue(THEME_NAME.BACKGROUND)};\n\n /** Focused */\n &:focus,\n &:active {\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n &:focus + span,\n &:active + span {\n color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /** Disabled */\n &:disabled {\n border-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n background-color: ${getThemeValue(THEME_NAME.DISABLED_BACKGROUND)};\n }\n\n &:disabled + span {\n color: ${getThemeValue(THEME_NAME.DISABLED)};\n }\n\n /** Invalid */\n &:focus:invalid {\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n box-shadow: 0 0 0 4px ${getThemeValue(THEME_NAME.ERROR_LIGHT)};\n }\n\n ${(props) =>\n props.touched\n ? `\n &:invalid {\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n\n &:invalid + span {\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n `\n : ''}\n\n /** Error */\n ${(props) =>\n props.errorText\n ? `\n border-color: ${getThemeValue(THEME_NAME.ERROR)};\n\n & + span {\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n `\n : ''}\n\n /** Required */\n &:required + span:after {\n content: '*';\n margin-left: 2px;\n color: ${getThemeValue(THEME_NAME.ERROR)};\n }\n\n /** Label Animation */\n & + span {\n position: absolute;\n padding: 0 5px;\n top: 0px;\n left: 4px;\n font-size: 14px;\n line-height: 32px;\n transition: all 300ms ease;\n }\n\n ${(props) =>\n props.value !== ''\n ? `\n & + span {\n top: -8px;\n background: ${getThemeValue(THEME_NAME.BACKGROUND)};\n font-size: 12px;\n line-height: 14px;\n }\n `\n : ''}\n\n &:focus + span, &:placeholder-shown + span {\n top: -8px;\n background: ${getThemeValue(THEME_NAME.BACKGROUND)};\n font-size: 12px;\n line-height: 14px;\n }\n`;\n\nconst ErrorContainer = styled.div`\n color: ${getThemeValue(THEME_NAME.ERROR)};\n padding-top: 3px;\n font-size: 12px;\n line-height: 14px;\n margin-left: 3px;\n`;\n\n/**\n * TextArea Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLTextAreaElement\n */\nfunction TextAreaComponent(props: TextAreaProps, forwardedRef: React.Ref<HTMLTextAreaElement>) {\n const { label, errorText, value: propsValue, required, ...rest } = props;\n const [touched, setTouched] = useState(false);\n const [value, setValue] = useState(propsValue || '');\n const errorId = useId();\n const prevValueRef = useRef<string>(undefined);\n const internalRef = useRef<HTMLTextAreaElement>(null);\n\n useImperativeHandle(forwardedRef, () => internalRef.current as HTMLTextAreaElement);\n\n useEffect(() => {\n if (propsValue !== undefined && propsValue !== prevValueRef.current) {\n setValue(propsValue);\n prevValueRef.current = propsValue as string;\n }\n }, [propsValue]);\n\n useEffect(() => {\n if (internalRef.current) {\n internalRef.current.setCustomValidity(errorText || '');\n }\n }, [errorText]);\n\n const handleFocus = (e: React.FocusEvent<HTMLTextAreaElement>) => {\n setTouched(true);\n if (props.onFocus) {\n props.onFocus(e);\n }\n };\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n if (props.onChange) {\n setValue(e.target.value);\n props.onChange(e);\n } else {\n setValue(e.target.value);\n }\n };\n\n return (\n <Label>\n <TextField\n {...rest}\n ref={internalRef}\n value={value}\n onChange={onChangeHandler}\n onFocus={handleFocus}\n touched={touched}\n required={required}\n aria-invalid={!!errorText}\n aria-required={required}\n aria-describedby={errorText ? errorId : undefined}\n />\n <span>{label}</span>\n {errorText && <ErrorContainer id={errorId}>{errorText}</ErrorContainer>}\n </Label>\n );\n}\n\nconst TextArea = React.forwardRef(TextAreaComponent);\nexport default TextArea;\n"],"names":["Label","styled","TextField","getThemeValue","THEME_NAME","BORDER_COLOR","BACKGROUND","PRIMARY","PRIMARY_LIGHT","DISABLED_BORDER","DISABLED_BACKGROUND","DISABLED","ERROR","ERROR_LIGHT","props","touched","errorText","value","ErrorContainer","TextAreaComponent","forwardedRef","label","propsValue","required","rest","setTouched","useState","setValue","errorId","useId","prevValueRef","useRef","undefined","internalRef","useImperativeHandle","current","useEffect","setCustomValidity","handleFocus","e","onFocus","onChangeHandler","onChange","target","_jsxs","_jsx","ref","aria-invalid","aria-required","aria-describedby","span","id","TextArea","React","forwardRef"],"mappings":";;;;;AAgBA,MAAMA,OAAAA,iBAAQC,MAAAA,CAAAA,OAAAA,EAAAA;;;;AAOd,MAAMC,SAAAA,iBAAYD,MAAAA,CAAAA,UAAAA,EAAAA;;;iHAOME,aAAAA,CAAcC,UAAAA,CAAWC,YAAY,CAAA,EAAA,yCAAA,EAErCF,aAAAA,CAAcC,WAAWE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ticComponent<{
3
3
  /** Label for the field */
4
4
  label?: string;
5
+ /** Error text to be shown below the field */
6
+ errorText?: string;
5
7
  } & React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
6
8
  export default Toggle;
@@ -1,33 +1,63 @@
1
1
  import { jsxs, jsx } from '@emotion/react/jsx-runtime';
2
- import React from 'react';
2
+ import React, { useRef, useId, useImperativeHandle, useEffect } from 'react';
3
3
  import styled from '@emotion/styled';
4
4
  import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
5
5
 
6
6
  const Switch = /*#__PURE__*/ styled("label", {
7
- target: "e185uavx0",
7
+ target: "ecxpw850",
8
8
  label: "Switch"
9
9
  })("position:relative;display:inline-flex;margin:5px 0;");
10
10
  const Input$1 = /*#__PURE__*/ styled("input", {
11
- target: "e185uavx1",
11
+ target: "ecxpw851",
12
12
  label: "Input"
13
13
  })("position:absolute;width:0;height:0;appearance:none;margin:0;& + span{position:relative;cursor:pointer;width:30px;height:18px;background-color:", getThemeValue(THEME_NAME.LIGHT_GREY), ";transition:0.4s;border-radius:10px;padding:0 3px;margin:0 10px 0 5px;}& + span:before{position:absolute;content:'';height:14px;width:14px;left:1px;top:1px;border:1px solid ", getThemeValue(THEME_NAME.DISABLED_BORDER), ";border-radius:50%;background-color:", getThemeValue(THEME_NAME.BACKGROUND), ";transition:0.4s;}&:checked + span{background-color:", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}&:checked + span:before{transform:translateX(18px);border-color:", getThemeValue(THEME_NAME.PRIMARY), ";}&:enabled:focus + span:before{box-shadow:0 0 0 3px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";border-color:", getThemeValue(THEME_NAME.PRIMARY), ";}&:enabled:hover ~ span{cursor:pointer;color:", getThemeValue(THEME_NAME.PRIMARY), ";}&:disabled ~ span{color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";}&:disabled + span{background-color:", getThemeValue(THEME_NAME.LIGHT_GREY), ";cursor:not-allowed;}&:disabled + span:before{background-color:", getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR), ";border-color:", getThemeValue(THEME_NAME.DISABLED_BORDER), ";}");
14
+ const ErrorContainer$1 = /*#__PURE__*/ styled("div", {
15
+ target: "ecxpw852",
16
+ label: "ErrorContainer"
17
+ })("color:", getThemeValue(THEME_NAME.ERROR), ";padding-top:3px;font-size:12px;line-height:14px;");
18
+ const Container$5 = /*#__PURE__*/ styled("div", {
19
+ target: "ecxpw853",
20
+ label: "Container"
21
+ })("display:inline-flex;flex-direction:column;");
14
22
  /**
15
23
  * Toggle Component
16
24
  * @param props - Component props
17
- * @param ref - Ref forwarded to the underlying HTMLInputElement
18
- */ function ToggleComponent(props, ref) {
19
- return /*#__PURE__*/ jsxs(Switch, {
25
+ * @param forwardedRef - Ref forwarded to the underlying HTMLInputElement
26
+ */ function ToggleComponent(props, forwardedRef) {
27
+ const { label, errorText, ...rest } = props;
28
+ const internalRef = useRef(null);
29
+ const errorId = useId();
30
+ useImperativeHandle(forwardedRef, ()=>internalRef.current);
31
+ useEffect(()=>{
32
+ if (internalRef.current) {
33
+ internalRef.current.setCustomValidity(errorText || '');
34
+ }
35
+ }, [
36
+ errorText
37
+ ]);
38
+ return /*#__PURE__*/ jsxs(Container$5, {
20
39
  children: [
21
- /*#__PURE__*/ jsx(Input$1, {
22
- ...props,
23
- ref: ref,
24
- type: "checkbox",
25
- role: "switch",
26
- "aria-checked": props.checked
40
+ /*#__PURE__*/ jsxs(Switch, {
41
+ children: [
42
+ /*#__PURE__*/ jsx(Input$1, {
43
+ ...rest,
44
+ ref: internalRef,
45
+ type: "checkbox",
46
+ role: "switch",
47
+ "aria-checked": props.checked,
48
+ "aria-invalid": !!errorText,
49
+ "aria-label": label,
50
+ "aria-describedby": errorText ? errorId : undefined
51
+ }),
52
+ /*#__PURE__*/ jsx("span", {}),
53
+ /*#__PURE__*/ jsx("span", {
54
+ children: label
55
+ })
56
+ ]
27
57
  }),
28
- /*#__PURE__*/ jsx("span", {}),
29
- /*#__PURE__*/ jsx("span", {
30
- children: props.label
58
+ errorText && /*#__PURE__*/ jsx(ErrorContainer$1, {
59
+ id: errorId,
60
+ children: errorText
31
61
  })
32
62
  ]
33
63
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Toggle.js","sources":["../../../src/components/Input/Toggle.tsx"],"sourcesContent":["import React from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\nconst Switch = styled.label`\n position: relative;\n display: inline-flex;\n margin: 5px 0;\n`;\n\nconst Input = styled.input`\n position: absolute;\n width: 0;\n height: 0;\n appearance: none;\n margin: 0;\n\n & + span {\n position: relative;\n cursor: pointer;\n width: 30px;\n height: 18px;\n background-color: ${getThemeValue(THEME_NAME.LIGHT_GREY)};\n transition: 0.4s;\n border-radius: 10px;\n padding: 0 3px;\n margin: 0 10px 0 5px;\n }\n & + span:before {\n position: absolute;\n content: '';\n height: 14px;\n width: 14px;\n left: 1px;\n top: 1px;\n border: 1px solid ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n border-radius: 50%;\n background-color: ${getThemeValue(THEME_NAME.BACKGROUND)};\n transition: 0.4s;\n }\n\n /* checked */\n &:checked + span {\n background-color: ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n &:checked + span:before {\n transform: translateX(18px);\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /* focus */\n &:enabled:focus + span:before {\n box-shadow: 0 0 0 3px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /* hover */\n &:enabled:hover ~ span {\n cursor: pointer;\n color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /* disabled */\n &:disabled ~ span {\n color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n }\n\n &:disabled + span {\n background-color: ${getThemeValue(THEME_NAME.LIGHT_GREY)};\n cursor: not-allowed;\n }\n\n &:disabled + span:before {\n background-color: ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};\n border-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n }\n`;\n\ntype ToggleProps = {\n /** Label for the field */\n label?: string;\n} & React.InputHTMLAttributes<HTMLInputElement>;\n\n/**\n * Toggle Component\n * @param props - Component props\n * @param ref - Ref forwarded to the underlying HTMLInputElement\n */\nfunction ToggleComponent(props: ToggleProps, ref: React.Ref<HTMLInputElement>) {\n return (\n <Switch>\n <Input\n {...props}\n ref={ref}\n type=\"checkbox\"\n role=\"switch\"\n aria-checked={props.checked}\n />\n <span></span>\n <span>{props.label}</span>\n </Switch>\n );\n}\n\nconst Toggle = React.forwardRef(ToggleComponent);\nexport default Toggle;\n"],"names":["Switch","styled","Input","getThemeValue","THEME_NAME","LIGHT_GREY","DISABLED_BORDER","BACKGROUND","PRIMARY_LIGHT","PRIMARY","BORDER_LIGHT_COLOR","ToggleComponent","props","ref","_jsxs","_jsx","type","role","aria-checked","checked","span","label","Toggle","React","forwardRef"],"mappings":";;;;;AAIA,MAAMA,MAAAA,iBAASC,MAAAA,CAAAA,OAAAA,EAAAA;;;;AAMf,MAAMC,OAAAA,iBAAQD,MAAAA,CAAAA,OAAAA,EAAAA;;;qJAYcE,aAAAA,CAAcC,UAAAA,CAAWC,UAAU,CAAA,EAAA,+KAAA,EAanCF,aAAAA,CAAcC,WAAWE,eAAe,CAAA,EAAA,sCAAA,EAExCH,cAAcC,UAAAA,CAAWG,UAAU,2DAMnCJ,aAAAA,CAAcC,UAAAA,CAAWI,aAAa,CAAA,EAAA,oEAAA,EAK1CL,aAAAA,CAAcC,WAAWK,OAAO,CAAA,EAAA,uDAAA,EAKxBN,cAAcC,UAAAA,CAAWI,aAAa,qBAC9CL,aAAAA,CAAcC,UAAAA,CAAWK,OAAO,CAAA,EAAA,gDAAA,EAMvCN,aAAAA,CAAcC,WAAWK,OAAO,CAAA,EAAA,4BAAA,EAKhCN,cAAcC,UAAAA,CAAWE,eAAe,4CAI7BH,aAAAA,CAAcC,UAAAA,CAAWC,UAAU,CAAA,EAAA,iEAAA,EAKnCF,aAAAA,CAAcC,WAAWM,kBAAkB,CAAA,EAAA,gBAAA,EAC/CP,aAAAA,CAAcC,UAAAA,CAAWE,eAAe,CAAA,EAAA,IAAA,CAAA;AAShE;;;;AAIC,IACD,SAASK,eAAAA,CAAgBC,KAAkB,EAAEC,GAAgC,EAAA;AACzE,IAAA,qBACIC,IAAA,CAACd,MAAAA,EAAAA;;0BACGe,GAAA,CAACb,OAAAA,EAAAA;AACI,gBAAA,GAAGU,KAAK;gBACTC,GAAAA,EAAKA,GAAAA;gBACLG,IAAAA,EAAK,UAAA;gBACLC,IAAAA,EAAK,QAAA;AACLC,gBAAAA,cAAAA,EAAcN,MAAMO;;0BAExBJ,GAAA,CAACK,MAAAA,EAAAA,EAAAA,CAAAA;0BACDL,GAAA,CAACK,MAAAA,EAAAA;AAAMR,gBAAAA,QAAAA,EAAAA,KAAAA,CAAMS;;;;AAGzB;AAEA,MAAMC,MAAAA,iBAASC,KAAAA,CAAMC,UAAU,CAACb,eAAAA;;;;"}
1
+ {"version":3,"file":"Toggle.js","sources":["../../../src/components/Input/Toggle.tsx"],"sourcesContent":["import React, { useEffect, useId, useRef, useImperativeHandle } from 'react';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\nconst Switch = styled.label`\n position: relative;\n display: inline-flex;\n margin: 5px 0;\n`;\n\nconst Input = styled.input`\n position: absolute;\n width: 0;\n height: 0;\n appearance: none;\n margin: 0;\n\n & + span {\n position: relative;\n cursor: pointer;\n width: 30px;\n height: 18px;\n background-color: ${getThemeValue(THEME_NAME.LIGHT_GREY)};\n transition: 0.4s;\n border-radius: 10px;\n padding: 0 3px;\n margin: 0 10px 0 5px;\n }\n & + span:before {\n position: absolute;\n content: '';\n height: 14px;\n width: 14px;\n left: 1px;\n top: 1px;\n border: 1px solid ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n border-radius: 50%;\n background-color: ${getThemeValue(THEME_NAME.BACKGROUND)};\n transition: 0.4s;\n }\n\n /* checked */\n &:checked + span {\n background-color: ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n }\n\n &:checked + span:before {\n transform: translateX(18px);\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /* focus */\n &:enabled:focus + span:before {\n box-shadow: 0 0 0 3px ${getThemeValue(THEME_NAME.PRIMARY_LIGHT)};\n border-color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /* hover */\n &:enabled:hover ~ span {\n cursor: pointer;\n color: ${getThemeValue(THEME_NAME.PRIMARY)};\n }\n\n /* disabled */\n &:disabled ~ span {\n color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n }\n\n &:disabled + span {\n background-color: ${getThemeValue(THEME_NAME.LIGHT_GREY)};\n cursor: not-allowed;\n }\n\n &:disabled + span:before {\n background-color: ${getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR)};\n border-color: ${getThemeValue(THEME_NAME.DISABLED_BORDER)};\n }\n`;\n\nconst ErrorContainer = styled.div`\n color: ${getThemeValue(THEME_NAME.ERROR)};\n padding-top: 3px;\n font-size: 12px;\n line-height: 14px;\n`;\n\nconst Container = styled.div`\n display: inline-flex;\n flex-direction: column;\n`;\n\ntype ToggleProps = {\n /** Label for the field */\n label?: string;\n /** Error text to be shown below the field */\n errorText?: string;\n} & React.InputHTMLAttributes<HTMLInputElement>;\n\n/**\n * Toggle Component\n * @param props - Component props\n * @param forwardedRef - Ref forwarded to the underlying HTMLInputElement\n */\nfunction ToggleComponent(props: ToggleProps, forwardedRef: React.Ref<HTMLInputElement>) {\n const { label, errorText, ...rest } = props;\n const internalRef = useRef<HTMLInputElement>(null);\n const errorId = useId();\n\n useImperativeHandle(forwardedRef, () => internalRef.current as HTMLInputElement);\n\n useEffect(() => {\n if (internalRef.current) {\n internalRef.current.setCustomValidity(errorText || '');\n }\n }, [errorText]);\n\n return (\n <Container>\n <Switch>\n <Input\n {...rest}\n ref={internalRef}\n type=\"checkbox\"\n role=\"switch\"\n aria-checked={props.checked}\n aria-invalid={!!errorText}\n aria-label={label}\n aria-describedby={errorText ? errorId : undefined}\n />\n <span></span>\n <span>{label}</span>\n </Switch>\n {errorText && <ErrorContainer id={errorId}>{errorText}</ErrorContainer>}\n </Container>\n );\n}\n\nconst Toggle = React.forwardRef(ToggleComponent);\nexport default Toggle;\n"],"names":["Switch","styled","Input","getThemeValue","THEME_NAME","LIGHT_GREY","DISABLED_BORDER","BACKGROUND","PRIMARY_LIGHT","PRIMARY","BORDER_LIGHT_COLOR","ErrorContainer","ERROR","Container","ToggleComponent","props","forwardedRef","label","errorText","rest","internalRef","useRef","errorId","useId","useImperativeHandle","current","useEffect","setCustomValidity","_jsxs","_jsx","ref","type","role","aria-checked","checked","aria-invalid","aria-label","aria-describedby","undefined","span","id","Toggle","React","forwardRef"],"mappings":";;;;;AAIA,MAAMA,MAAAA,iBAASC,MAAAA,CAAAA,OAAAA,EAAAA;;;;AAMf,MAAMC,OAAAA,iBAAQD,MAAAA,CAAAA,OAAAA,EAAAA;;;qJAYcE,aAAAA,CAAcC,UAAAA,CAAWC,UAAU,CAAA,EAAA,+KAAA,EAanCF,aAAAA,CAAcC,WAAWE,eAAe,CAAA,EAAA,sCAAA,EAExCH,cAAcC,UAAAA,CAAWG,UAAU,2DAMnCJ,aAAAA,CAAcC,UAAAA,CAAWI,aAAa,CAAA,EAAA,oEAAA,EAK1CL,aAAAA,CAAcC,WAAWK,OAAO,CAAA,EAAA,uDAAA,EAKxBN,cAAcC,UAAAA,CAAWI,aAAa,qBAC9CL,aAAAA,CAAcC,UAAAA,CAAWK,OAAO,CAAA,EAAA,gDAAA,EAMvCN,aAAAA,CAAcC,WAAWK,OAAO,CAAA,EAAA,4BAAA,EAKhCN,cAAcC,UAAAA,CAAWE,eAAe,4CAI7BH,aAAAA,CAAcC,UAAAA,CAAWC,UAAU,CAAA,EAAA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AAYnB,KAAAA;AACZoB,wBAAAA,kBAAAA,EAAkBnB,YAAYI,OAAAA,GAAUgB;;kCAE5CT,GAAA,CAACU,MAAAA,EAAAA,EAAAA,CAAAA;kCACDV,GAAA,CAACU,MAAAA,EAAAA;AAAMtB,wBAAAA,QAAAA,EAAAA;;;;AAEVC,YAAAA,SAAAA,kBAAaW,GAAA,CAAClB,gBAAAA,EAAAA;gBAAe6B,EAAAA,EAAIlB,OAAAA;AAAUJ,gBAAAA,QAAAA,EAAAA;;;;AAGxD;AAEA,MAAMuB,MAAAA,iBAASC,KAAAA,CAAMC,UAAU,CAAC7B,eAAAA;;;;"}
@@ -6,3 +6,4 @@ export { default as Toggle } from './Toggle';
6
6
  export { default as Radio } from './Radio';
7
7
  export { default as RadioButton, RadioGroup } from './RadioButton';
8
8
  export { default as Dropdown } from './Dropdown';
9
+ export { ErrorContainer } from '../../shared/styles';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- type MenuItemProps<T> = {
2
+ export type MenuItemProps<T> = {
3
3
  /** Value of the element */
4
4
  value: T;
5
5
  } & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'value'>;
@@ -6,7 +6,7 @@ import Checkbox from '../Input/Checkbox.js';
6
6
  import MenuContext from './MenuContext.js';
7
7
 
8
8
  const Container$4 = /*#__PURE__*/ styled("button", {
9
- target: "ebwocs30",
9
+ target: "e1u7wt750",
10
10
  label: "Container"
11
11
  })("font-weight:", (props)=>props.selected ? 'bold' : 'normal', ";padding:8px;border:none;border-left:4px solid\n ", (props)=>props.selected && !props.multiselect ? getThemeValue(THEME_NAME.TEXT_COLOR_DARK) : 'transparent', ";background-color:transparent;font-size:16px;border-bottom:1px solid ", getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR), ";min-height:41px;display:flex;align-items:center;cursor:pointer;position:relative;color:", getThemeValue(THEME_NAME.TEXT_COLOR_DARK), ";&:hover,&:focus,&:focus-within{background-color:", getThemeValue(THEME_NAME.BORDER_LIGHT_COLOR), ";}& > label{margin:0 4px 0 0;}");
12
12
  /**