no-frills-ui 0.0.14-alpha.8 → 0.0.14-rc.1

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 (151) hide show
  1. package/README.md +3 -3
  2. package/dist/index.js +847 -718
  3. package/dist/index.js.map +1 -1
  4. package/lib-esm/components/Accordion/Accordion.d.ts +9 -13
  5. package/lib-esm/components/Accordion/Accordion.js +13 -11
  6. package/lib-esm/components/Accordion/Accordion.js.map +1 -1
  7. package/lib-esm/components/Accordion/AccordionStep.d.ts +22 -22
  8. package/lib-esm/components/Accordion/AccordionStep.js +34 -29
  9. package/lib-esm/components/Accordion/AccordionStep.js.map +1 -1
  10. package/lib-esm/components/Badge/Badge.d.ts +13 -16
  11. package/lib-esm/components/Badge/Badge.js +10 -20
  12. package/lib-esm/components/Badge/Badge.js.map +1 -1
  13. package/lib-esm/components/Button/ActionButton.d.ts +9 -5
  14. package/lib-esm/components/Button/ActionButton.js +18 -3
  15. package/lib-esm/components/Button/ActionButton.js.map +1 -1
  16. package/lib-esm/components/Button/Button.d.ts +9 -5
  17. package/lib-esm/components/Button/Button.js +17 -5
  18. package/lib-esm/components/Button/Button.js.map +1 -1
  19. package/lib-esm/components/Button/IconButton.d.ts +9 -5
  20. package/lib-esm/components/Button/IconButton.js +18 -3
  21. package/lib-esm/components/Button/IconButton.js.map +1 -1
  22. package/lib-esm/components/Button/LinkButton.d.ts +9 -5
  23. package/lib-esm/components/Button/LinkButton.js +18 -3
  24. package/lib-esm/components/Button/LinkButton.js.map +1 -1
  25. package/lib-esm/components/Button/RaisedButton.d.ts +9 -5
  26. package/lib-esm/components/Button/RaisedButton.js +18 -3
  27. package/lib-esm/components/Button/RaisedButton.js.map +1 -1
  28. package/lib-esm/components/Card/Card.d.ts +4 -6
  29. package/lib-esm/components/Card/Card.js +16 -3
  30. package/lib-esm/components/Card/Card.js.map +1 -1
  31. package/lib-esm/components/Chip/Chip.d.ts +2 -2
  32. package/lib-esm/components/Chip/Chip.js +14 -8
  33. package/lib-esm/components/Chip/Chip.js.map +1 -1
  34. package/lib-esm/components/ChipInput/ChipInput.d.ts +28 -39
  35. package/lib-esm/components/ChipInput/ChipInput.js +37 -37
  36. package/lib-esm/components/ChipInput/ChipInput.js.map +1 -1
  37. package/lib-esm/components/Dialog/AlertDialog.d.ts +11 -12
  38. package/lib-esm/components/Dialog/AlertDialog.js +4 -11
  39. package/lib-esm/components/Dialog/AlertDialog.js.map +1 -1
  40. package/lib-esm/components/Dialog/ConfirmDialog.d.ts +13 -14
  41. package/lib-esm/components/Dialog/ConfirmDialog.js +4 -12
  42. package/lib-esm/components/Dialog/ConfirmDialog.js.map +1 -1
  43. package/lib-esm/components/Dialog/Dialog.d.ts +8 -14
  44. package/lib-esm/components/Dialog/Dialog.js +11 -9
  45. package/lib-esm/components/Dialog/Dialog.js.map +1 -1
  46. package/lib-esm/components/Dialog/PromptDialog.d.ts +18 -19
  47. package/lib-esm/components/Dialog/PromptDialog.js +10 -18
  48. package/lib-esm/components/Dialog/PromptDialog.js.map +1 -1
  49. package/lib-esm/components/DragAndDrop/DragAndDrop.d.ts +37 -59
  50. package/lib-esm/components/DragAndDrop/DragAndDrop.js +23 -26
  51. package/lib-esm/components/DragAndDrop/DragAndDrop.js.map +1 -1
  52. package/lib-esm/components/DragAndDrop/DragItem.d.ts +2 -2
  53. package/lib-esm/components/DragAndDrop/DragItem.js +40 -38
  54. package/lib-esm/components/DragAndDrop/DragItem.js.map +1 -1
  55. package/lib-esm/components/DragAndDrop/types.d.ts +3 -3
  56. package/lib-esm/components/DragAndDrop/types.js.map +1 -1
  57. package/lib-esm/components/Drawer/Drawer.d.ts +24 -31
  58. package/lib-esm/components/Drawer/Drawer.js +49 -45
  59. package/lib-esm/components/Drawer/Drawer.js.map +1 -1
  60. package/lib-esm/components/Groups/Group.d.ts +6 -8
  61. package/lib-esm/components/Groups/Group.js +12 -10
  62. package/lib-esm/components/Groups/Group.js.map +1 -1
  63. package/lib-esm/components/Input/Checkbox.d.ts +12 -15
  64. package/lib-esm/components/Input/Checkbox.js +30 -26
  65. package/lib-esm/components/Input/Checkbox.js.map +1 -1
  66. package/lib-esm/components/Input/Dropdown.d.ts +8 -18
  67. package/lib-esm/components/Input/Dropdown.js +42 -17
  68. package/lib-esm/components/Input/Dropdown.js.map +1 -1
  69. package/lib-esm/components/Input/Input.d.ts +8 -3
  70. package/lib-esm/components/Input/Input.js +20 -19
  71. package/lib-esm/components/Input/Input.js.map +1 -1
  72. package/lib-esm/components/Input/Radio.d.ts +4 -8
  73. package/lib-esm/components/Input/Radio.js +16 -13
  74. package/lib-esm/components/Input/Radio.js.map +1 -1
  75. package/lib-esm/components/Input/RadioButton.d.ts +4 -8
  76. package/lib-esm/components/Input/RadioButton.js +15 -12
  77. package/lib-esm/components/Input/RadioButton.js.map +1 -1
  78. package/lib-esm/components/Input/Select.d.ts +6 -13
  79. package/lib-esm/components/Input/Select.js +21 -18
  80. package/lib-esm/components/Input/Select.js.map +1 -1
  81. package/lib-esm/components/Input/TextArea.d.ts +6 -13
  82. package/lib-esm/components/Input/TextArea.js +29 -24
  83. package/lib-esm/components/Input/TextArea.js.map +1 -1
  84. package/lib-esm/components/Input/Toggle.d.ts +4 -9
  85. package/lib-esm/components/Input/Toggle.js +12 -10
  86. package/lib-esm/components/Input/Toggle.js.map +1 -1
  87. package/lib-esm/components/Menu/Menu.d.ts +4 -14
  88. package/lib-esm/components/Menu/Menu.js +24 -16
  89. package/lib-esm/components/Menu/Menu.js.map +1 -1
  90. package/lib-esm/components/Menu/MenuContext.d.ts +4 -4
  91. package/lib-esm/components/Menu/MenuContext.js +1 -0
  92. package/lib-esm/components/Menu/MenuContext.js.map +1 -1
  93. package/lib-esm/components/Menu/MenuItem.d.ts +10 -4
  94. package/lib-esm/components/Menu/MenuItem.js +19 -5
  95. package/lib-esm/components/Menu/MenuItem.js.map +1 -1
  96. package/lib-esm/components/Modal/Modal.d.ts +17 -23
  97. package/lib-esm/components/Modal/Modal.js +37 -34
  98. package/lib-esm/components/Modal/Modal.js.map +1 -1
  99. package/lib-esm/components/Notification/Notification.d.ts +39 -34
  100. package/lib-esm/components/Notification/Notification.js +16 -39
  101. package/lib-esm/components/Notification/Notification.js.map +1 -1
  102. package/lib-esm/components/Notification/NotificationManager.d.ts +4 -4
  103. package/lib-esm/components/Notification/NotificationManager.js +18 -14
  104. package/lib-esm/components/Notification/NotificationManager.js.map +1 -1
  105. package/lib-esm/components/Notification/index.d.ts +1 -0
  106. package/lib-esm/components/Notification/style.d.ts +2 -3
  107. package/lib-esm/components/Notification/style.js +11 -11
  108. package/lib-esm/components/Notification/style.js.map +1 -1
  109. package/lib-esm/components/Popover/Popover.d.ts +21 -20
  110. package/lib-esm/components/Popover/Popover.js +42 -44
  111. package/lib-esm/components/Popover/Popover.js.map +1 -1
  112. package/lib-esm/components/Spinner/Spinner.d.ts +14 -15
  113. package/lib-esm/components/Spinner/Spinner.js +12 -13
  114. package/lib-esm/components/Spinner/Spinner.js.map +1 -1
  115. package/lib-esm/components/Stepper/Step.d.ts +15 -12
  116. package/lib-esm/components/Stepper/Step.js +10 -8
  117. package/lib-esm/components/Stepper/Step.js.map +1 -1
  118. package/lib-esm/components/Stepper/Stepper.d.ts +11 -17
  119. package/lib-esm/components/Stepper/Stepper.js +25 -23
  120. package/lib-esm/components/Stepper/Stepper.js.map +1 -1
  121. package/lib-esm/components/Tabs/Tab.d.ts +10 -16
  122. package/lib-esm/components/Tabs/Tab.js +0 -8
  123. package/lib-esm/components/Tabs/Tab.js.map +1 -1
  124. package/lib-esm/components/Tabs/Tabs.d.ts +11 -22
  125. package/lib-esm/components/Tabs/Tabs.js +39 -31
  126. package/lib-esm/components/Tabs/Tabs.js.map +1 -1
  127. package/lib-esm/components/Toast/Toast.d.ts +7 -7
  128. package/lib-esm/components/Toast/Toast.js +13 -12
  129. package/lib-esm/components/Toast/Toast.js.map +1 -1
  130. package/lib-esm/components/Toast/ToastStory.d.ts +21 -24
  131. package/lib-esm/components/Tooltip/Tooltip.d.ts +11 -14
  132. package/lib-esm/components/Tooltip/Tooltip.js +11 -21
  133. package/lib-esm/components/Tooltip/Tooltip.js.map +1 -1
  134. package/lib-esm/icons/CheckCircle.js +2 -2
  135. package/lib-esm/icons/CheckCircle.js.map +1 -1
  136. package/lib-esm/icons/ErrorOutline.js +2 -2
  137. package/lib-esm/icons/ErrorOutline.js.map +1 -1
  138. package/lib-esm/icons/Info.js +2 -2
  139. package/lib-esm/icons/Info.js.map +1 -1
  140. package/lib-esm/icons/ReportProblem.js +2 -2
  141. package/lib-esm/icons/ReportProblem.js.map +1 -1
  142. package/lib-esm/index.js +43 -0
  143. package/lib-esm/shared/LayerManager.d.ts +5 -4
  144. package/lib-esm/shared/LayerManager.js +111 -111
  145. package/lib-esm/shared/LayerManager.js.map +1 -1
  146. package/lib-esm/shared/styles.d.ts +1 -1
  147. package/lib-esm/shared/styles.js +9 -9
  148. package/lib-esm/shared/styles.js.map +1 -1
  149. package/package.json +66 -31
  150. package/lib-esm/components/index.js +0 -43
  151. /package/lib-esm/{components/index.js.map → index.js.map} +0 -0
@@ -1,37 +1,40 @@
1
1
  import { jsxs, jsx } from '@emotion/react/jsx-runtime';
2
- import 'react';
3
- import PropTypes from 'prop-types';
2
+ import React from 'react';
4
3
  import styled from '@emotion/styled';
5
4
  import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
6
5
 
7
6
  const Input = /*#__PURE__*/ styled("input", {
8
- target: "e1ed8pyp0",
7
+ target: "e1yp0s5y0",
9
8
  label: "Input"
10
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), ";}");
11
10
  const Label = /*#__PURE__*/ styled("label", {
12
- target: "e1ed8pyp1",
11
+ target: "e1yp0s5y1",
13
12
  label: "Label"
14
13
  })("display:inline-flex;&:focus-within{z-index:1;}");
15
14
  const RadioGroup = /*#__PURE__*/ styled("div", {
16
- target: "e1ed8pyp2",
15
+ target: "e1yp0s5y2",
17
16
  label: "RadioGroup"
18
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;}");
19
- function RadioButton(props) {
18
+ /**
19
+ * RadioButton Component
20
+ * @param props - Component props
21
+ * @param ref - Ref forwarded to the underlying HTMLInputElement
22
+ */ function RadioButtonComponent(props, ref) {
23
+ const { label, ...rest } = props;
20
24
  return /*#__PURE__*/ jsxs(Label, {
21
25
  children: [
22
26
  /*#__PURE__*/ jsx(Input, {
23
- ...props,
24
- type: "radio"
27
+ ...rest,
28
+ type: "radio",
29
+ ref: ref
25
30
  }),
26
31
  /*#__PURE__*/ jsx("span", {
27
- children: props.label
32
+ children: label
28
33
  })
29
34
  ]
30
35
  });
31
36
  }
32
- RadioButton.propTypes = {
33
- /** Label for the field */ label: PropTypes.string
34
- };
37
+ const RadioButton = /*#__PURE__*/ React.forwardRef(RadioButtonComponent);
35
38
 
36
39
  export { RadioGroup, RadioButton as default };
37
40
  //# sourceMappingURL=RadioButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RadioButton.js","sources":["../../../src/components/Input/RadioButton.tsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\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\nfunction RadioButton(\n props: PropTypes.InferProps<\n React.AllHTMLAttributes<HTMLInputElement> & typeof RadioButton.propTypes\n >,\n) {\n return (\n <Label>\n <Input {...props} type=\"radio\" />\n <span>{props.label}</span>\n </Label>\n );\n}\n\nRadioButton.propTypes = {\n /** Label for the field */\n label: PropTypes.string,\n};\n\nexport default RadioButton;\n"],"names":["Input","styled","getThemeValue","THEME_NAME","PRIMARY","PRIMARY_LIGHT","TEXT_COLOR_LIGHT","BORDER_LIGHT_COLOR","DISABLED_BORDER","Label","RadioGroup","RadioButton","props","_jsxs","_jsx","type","span","label","propTypes","PropTypes","string"],"mappings":";;;;;;AAKA,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;AAKR,SAASE,YACLC,KAEC,EAAA;AAED,IAAA,qBACIC,IAAA,CAACJ,KAAAA,EAAAA;;0BACGK,GAAA,CAACd,KAAAA,EAAAA;AAAO,gBAAA,GAAGY,KAAK;gBAAEG,IAAAA,EAAK;;0BACvBD,GAAA,CAACE,MAAAA,EAAAA;AAAMJ,gBAAAA,QAAAA,EAAAA,KAAAA,CAAMK;;;;AAGzB;AAEAN,WAAAA,CAAYO,SAAS,GAAG;+BAEpBD,KAAAA,EAAOE,SAAAA,CAAUC;AACrB,CAAA;;;;"}
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,15 +1,8 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
- interface SelectProps extends PropTypes.InferType<typeof Select.propTypes>, React.InputHTMLAttributes<HTMLSelectElement> {
4
- value?: string;
5
- }
6
- declare function Select(props: SelectProps): import("@emotion/react/jsx-runtime").JSX.Element;
7
- declare namespace Select {
8
- var propTypes: {
9
- /** Label for the field */
10
- label: PropTypes.Requireable<string>;
11
- /** Error text to be shown below the field */
12
- errorText: PropTypes.Requireable<string>;
13
- };
14
- }
2
+ declare const Select: React.ForwardRefExoticComponent<{
3
+ /** Label for the field */
4
+ label?: string;
5
+ /** Error text to be shown below the field */
6
+ errorText?: string;
7
+ } & React.InputHTMLAttributes<HTMLSelectElement> & React.RefAttributes<HTMLSelectElement>>;
15
8
  export default Select;
@@ -1,16 +1,15 @@
1
1
  import { jsxs, jsx } from '@emotion/react/jsx-runtime';
2
- import { useState, useId, useEffect } from 'react';
3
- import PropTypes from 'prop-types';
2
+ import React, { useState, useId, useRef, useEffect } from 'react';
4
3
  import styled from '@emotion/styled';
5
4
  import ExpandMore from '../../icons/ExpandMore.js';
6
5
  import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
7
6
 
8
- const Label = /*#__PURE__*/ styled("label", {
9
- target: "eao61d00",
7
+ const Label$3 = /*#__PURE__*/ styled("label", {
8
+ target: "e13b7jm0",
10
9
  label: "Label"
11
10
  })("display:inline-flex;flex-direction:column;position:relative;margin:10px 5px;pointer-events:none;max-width:268px;& svg{fill:currentColor;}");
12
11
  const SelectField = /*#__PURE__*/ styled("select", {
13
- target: "eao61d01",
12
+ target: "e13b7jm1",
14
13
  label: "SelectField"
15
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 ? `
16
15
  &:invalid {
@@ -34,21 +33,27 @@ const SelectField = /*#__PURE__*/ styled("select", {
34
33
  line-height: 14px;
35
34
  }
36
35
  ` : '', " &:focus + span,&:placeholder-shown + span{top:-8px;background:", getThemeValue(THEME_NAME.BACKGROUND), ";font-size:12px;line-height:14px;}");
37
- const ErrorContainer = /*#__PURE__*/ styled("div", {
38
- target: "eao61d02",
36
+ const ErrorContainer$1 = /*#__PURE__*/ styled("div", {
37
+ target: "e13b7jm2",
39
38
  label: "ErrorContainer"
40
39
  })("color:", getThemeValue(THEME_NAME.ERROR), ";padding-top:3px;font-size:12px;line-height:14px;margin-left:3px;");
41
- const ArrowContainer = /*#__PURE__*/ styled("span", {
42
- target: "eao61d03",
40
+ const ArrowContainer$1 = /*#__PURE__*/ styled("span", {
41
+ target: "e13b7jm3",
43
42
  label: "ArrowContainer"
44
43
  })("position:absolute;right:8px;top:8px;");
45
- function Select(props) {
44
+ /**
45
+ * Select Component
46
+ * @param props - Component props
47
+ * @param ref - Ref forwarded to the underlying HTMLSelectElement
48
+ */ function SelectComponent(props, ref) {
46
49
  const [touched, setTouched] = useState(false);
47
50
  const [value, setValue] = useState(props.value || '');
48
51
  const errorId = useId();
52
+ const prevValueRef = useRef(undefined);
49
53
  useEffect(()=>{
50
- if (props.value !== undefined) {
54
+ if (props.value !== undefined && props.value !== prevValueRef.current) {
51
55
  setValue(props.value);
56
+ prevValueRef.current = props.value;
52
57
  }
53
58
  }, [
54
59
  props.value
@@ -67,10 +72,11 @@ function Select(props) {
67
72
  setValue(e.target.value);
68
73
  }
69
74
  };
70
- return /*#__PURE__*/ jsxs(Label, {
75
+ return /*#__PURE__*/ jsxs(Label$3, {
71
76
  children: [
72
77
  /*#__PURE__*/ jsxs(SelectField, {
73
78
  ...props,
79
+ ref: ref,
74
80
  multiple: false,
75
81
  value: value,
76
82
  onChange: onChangeHandler,
@@ -87,21 +93,18 @@ function Select(props) {
87
93
  /*#__PURE__*/ jsx("span", {
88
94
  children: props.label
89
95
  }),
90
- /*#__PURE__*/ jsx(ArrowContainer, {
96
+ /*#__PURE__*/ jsx(ArrowContainer$1, {
91
97
  "aria-hidden": "true",
92
98
  children: /*#__PURE__*/ jsx(ExpandMore, {})
93
99
  }),
94
- props.errorText && /*#__PURE__*/ jsx(ErrorContainer, {
100
+ props.errorText && /*#__PURE__*/ jsx(ErrorContainer$1, {
95
101
  id: errorId,
96
102
  children: props.errorText
97
103
  })
98
104
  ]
99
105
  });
100
106
  }
101
- Select.propTypes = {
102
- /** Label for the field */ label: PropTypes.string,
103
- /** Error text to be shown below the field */ errorText: PropTypes.string
104
- };
107
+ const Select = /*#__PURE__*/ React.forwardRef(SelectComponent);
105
108
 
106
109
  export { Select as default };
107
110
  //# sourceMappingURL=Select.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Select.js","sources":["../../../src/components/Input/Select.tsx"],"sourcesContent":["import React, { useState, useEffect, useId } from 'react';\nimport PropTypes from 'prop-types';\nimport styled from '@emotion/styled';\nimport ExpandMore from '../../icons/ExpandMore';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\ninterface SelectProps\n extends\n PropTypes.InferType<typeof Select.propTypes>,\n React.InputHTMLAttributes<HTMLSelectElement> {\n value?: string;\n}\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\nexport default function Select(props: SelectProps) {\n const [touched, setTouched] = useState(false);\n const [value, setValue] = useState(props.value || '');\n const errorId = useId();\n\n useEffect(() => {\n if (props.value !== undefined) {\n setValue(props.value);\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 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\nSelect.propTypes = {\n /** Label for the field */\n label: PropTypes.string,\n /** Error text to be shown below the field */\n errorText: PropTypes.string,\n};\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","Select","setTouched","useState","setValue","errorId","useId","useEffect","undefined","handleFocus","e","onFocus","onChangeHandler","onChange","target","_jsxs","multiple","aria-invalid","aria-required","required","aria-describedby","_jsx","option","children","span","label","aria-hidden","ExpandMore","id","propTypes","PropTypes","string"],"mappings":";;;;;;;AAiBA,MAAMA,KAAAA,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,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,EAAU,KAAA;gBACVlB,KAAAA,EAAOA,KAAAA;gBACPe,QAAAA,EAAUD,eAAAA;gBACVD,OAAAA,EAASF,WAAAA;gBACTb,OAAAA,EAASA,OAAAA;gBACTqB,cAAAA,EAAc,CAAC,CAACtB,KAAAA,CAAME,SAAS;AAC/BqB,gBAAAA,eAAAA,EAAevB,MAAMwB,QAAQ;gBAC7BC,kBAAAA,EAAkBzB,KAAAA,CAAME,SAAS,GAAGQ,OAAAA,GAAUG,SAAAA;;kCAE9Ca,GAAA,CAACC,QAAAA,EAAAA,EAAAA,CAAAA;AACA3B,oBAAAA,KAAAA,CAAM4B;;;0BAEXF,GAAA,CAACG,MAAAA,EAAAA;AAAM7B,gBAAAA,QAAAA,EAAAA,KAAAA,CAAM8B;;0BACbJ,GAAA,CAACrB,cAAAA,EAAAA;gBAAe0B,aAAAA,EAAY,MAAA;AACxB,gBAAA,QAAA,gBAAAL,GAAA,CAACM,UAAAA,EAAAA,EAAAA;;YAEJhC,KAAAA,CAAME,SAAS,kBAAIwB,GAAA,CAACtB,cAAAA,EAAAA;gBAAe6B,EAAAA,EAAIvB,OAAAA;AAAUV,gBAAAA,QAAAA,EAAAA,KAAAA,CAAME;;;;AAGpE;AAEAI,MAAAA,CAAO4B,SAAS,GAAG;+BAEfJ,KAAAA,EAAOK,SAAAA,CAAUC,MAAM;kDAEvBlC,SAAAA,EAAWiC,SAAAA,CAAUC;AACzB,CAAA;;;;"}
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,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;;;;eAIzC,EAAET,aAAAA,CAAcC,UAAAA,CAAWQ,KAAK,CAAA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AE9Ce,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,15 +1,8 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
- interface TextAreaProps extends PropTypes.InferType<typeof TextArea.propTypes>, React.InputHTMLAttributes<HTMLTextAreaElement> {
4
- value?: string;
5
- }
6
- declare function TextArea(props: TextAreaProps): import("@emotion/react/jsx-runtime").JSX.Element;
7
- declare namespace TextArea {
8
- var propTypes: {
9
- /** Label for the field */
10
- label: PropTypes.Requireable<string>;
11
- /** Error text to be shown below the field */
12
- errorText: PropTypes.Requireable<string>;
13
- };
14
- }
2
+ declare const TextArea: React.ForwardRefExoticComponent<{
3
+ /** Label for the field */
4
+ label: string;
5
+ /** Error text to be shown below the field */
6
+ errorText?: string;
7
+ } & React.InputHTMLAttributes<HTMLTextAreaElement> & React.RefAttributes<HTMLTextAreaElement>>;
15
8
  export default TextArea;
@@ -1,15 +1,14 @@
1
1
  import { jsxs, jsx } from '@emotion/react/jsx-runtime';
2
- import { useState, useId, useEffect } from 'react';
3
- import PropTypes from 'prop-types';
2
+ import React, { useState, useId, useRef, useEffect } from 'react';
4
3
  import styled from '@emotion/styled';
5
4
  import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
6
5
 
7
- const Label = /*#__PURE__*/ styled("label", {
8
- target: "ee4amtm0",
6
+ const Label$4 = /*#__PURE__*/ styled("label", {
7
+ target: "e1j32tnv0",
9
8
  label: "Label"
10
9
  })("display:inline-flex;flex-direction:column;position:relative;margin:10px 5px;");
11
10
  const TextField = /*#__PURE__*/ styled("textarea", {
12
- target: "ee4amtm1",
11
+ target: "e1j32tnv1",
13
12
  label: "TextField"
14
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 ? `
15
14
  &:invalid {
@@ -33,20 +32,27 @@ const TextField = /*#__PURE__*/ styled("textarea", {
33
32
  line-height: 14px;
34
33
  }
35
34
  ` : '', " &:focus + span,&:placeholder-shown + span{top:-8px;background:", getThemeValue(THEME_NAME.BACKGROUND), ";font-size:12px;line-height:14px;}");
36
- const ErrorContainer = /*#__PURE__*/ styled("div", {
37
- target: "ee4amtm2",
35
+ const ErrorContainer$2 = /*#__PURE__*/ styled("div", {
36
+ target: "e1j32tnv2",
38
37
  label: "ErrorContainer"
39
38
  })("color:", getThemeValue(THEME_NAME.ERROR), ";padding-top:3px;font-size:12px;line-height:14px;margin-left:3px;");
40
- function TextArea(props) {
39
+ /**
40
+ * TextArea Component
41
+ * @param props - Component props
42
+ * @param ref - Ref forwarded to the underlying HTMLTextAreaElement
43
+ */ function TextAreaComponent(props, ref) {
44
+ const { label, errorText, value: propsValue, required, ...rest } = props;
41
45
  const [touched, setTouched] = useState(false);
42
- const [value, setValue] = useState(props.value || '');
46
+ const [value, setValue] = useState(propsValue || '');
43
47
  const errorId = useId();
48
+ const prevValueRef = useRef(undefined);
44
49
  useEffect(()=>{
45
- if (props.value !== undefined) {
46
- setValue(props.value);
50
+ if (propsValue !== undefined && propsValue !== prevValueRef.current) {
51
+ setValue(propsValue);
52
+ prevValueRef.current = propsValue;
47
53
  }
48
54
  }, [
49
- props.value
55
+ propsValue
50
56
  ]);
51
57
  const handleFocus = (e)=>{
52
58
  setTouched(true);
@@ -62,32 +68,31 @@ function TextArea(props) {
62
68
  setValue(e.target.value);
63
69
  }
64
70
  };
65
- return /*#__PURE__*/ jsxs(Label, {
71
+ return /*#__PURE__*/ jsxs(Label$4, {
66
72
  children: [
67
73
  /*#__PURE__*/ jsx(TextField, {
68
- ...props,
74
+ ...rest,
75
+ ref: ref,
69
76
  value: value,
70
77
  onChange: onChangeHandler,
71
78
  onFocus: handleFocus,
72
79
  touched: touched,
73
- "aria-invalid": !!props.errorText,
74
- "aria-required": props.required,
75
- "aria-describedby": props.errorText ? errorId : undefined
80
+ required: required,
81
+ "aria-invalid": !!errorText,
82
+ "aria-required": required,
83
+ "aria-describedby": errorText ? errorId : undefined
76
84
  }),
77
85
  /*#__PURE__*/ jsx("span", {
78
- children: props.label
86
+ children: label
79
87
  }),
80
- props.errorText && /*#__PURE__*/ jsx(ErrorContainer, {
88
+ errorText && /*#__PURE__*/ jsx(ErrorContainer$2, {
81
89
  id: errorId,
82
- children: props.errorText
90
+ children: errorText
83
91
  })
84
92
  ]
85
93
  });
86
94
  }
87
- TextArea.propTypes = {
88
- /** Label for the field */ label: PropTypes.string,
89
- /** Error text to be shown below the field */ errorText: PropTypes.string
90
- };
95
+ const TextArea = /*#__PURE__*/ React.forwardRef(TextAreaComponent);
91
96
 
92
97
  export { TextArea as default };
93
98
  //# sourceMappingURL=TextArea.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.js","sources":["../../../src/components/Input/TextArea.tsx"],"sourcesContent":["import React, { useState, useEffect, useId } from 'react';\nimport PropTypes from 'prop-types';\nimport styled from '@emotion/styled';\nimport { getThemeValue, THEME_NAME } from '../../shared/constants';\n\ninterface TextAreaProps\n extends\n PropTypes.InferType<typeof TextArea.propTypes>,\n React.InputHTMLAttributes<HTMLTextAreaElement> {\n value?: string;\n}\n\ntype TextAreaInternalProps = TextAreaProps & {\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`;\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\nexport default function TextArea(props: TextAreaProps) {\n const [touched, setTouched] = useState(false);\n const [value, setValue] = useState(props.value || '');\n const errorId = useId();\n\n useEffect(() => {\n if (props.value !== undefined) {\n setValue(props.value);\n }\n }, [props.value]);\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 {...props}\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 <span>{props.label}</span>\n {props.errorText && <ErrorContainer id={errorId}>{props.errorText}</ErrorContainer>}\n </Label>\n );\n}\n\nTextArea.propTypes = {\n /** Label for the field */\n label: PropTypes.string,\n /** Error text to be shown below the field */\n errorText: PropTypes.string,\n};\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","TextArea","setTouched","useState","setValue","errorId","useId","useEffect","undefined","handleFocus","e","onFocus","onChangeHandler","onChange","target","_jsxs","_jsx","aria-invalid","aria-required","required","aria-describedby","span","label","id","propTypes","PropTypes","string"],"mappings":";;;;;;AAgBA,MAAMA,KAAAA,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;;;;eAIzC,EAAET,aA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AM;kDAEvB5B,SAAAA,EAAW2B,SAAAA,CAAUC;AACzB,CAAA;;;;"}
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,CA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VoB,gBAAAA,cAAAA,EAAc,CAAC,CAAC3B,SAAAA;gBAChB4B,eAAAA,EAAerB,QAAAA;AACfsB,gBAAAA,kBAAAA,EAAkB7B,YAAYY,OAAAA,GAAUI;;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,11 +1,6 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
- type ToggleProps = PropTypes.InferProps<React.AllHTMLAttributes<HTMLInputElement> & typeof Toggle.propTypes>;
4
- declare function Toggle(props: ToggleProps): import("@emotion/react/jsx-runtime").JSX.Element;
5
- declare namespace Toggle {
6
- var propTypes: {
7
- /** Label for the field */
8
- label: PropTypes.Requireable<string>;
9
- };
10
- }
2
+ declare const Toggle: React.ForwardRefExoticComponent<{
3
+ /** Label for the field */
4
+ label?: string;
5
+ } & React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
11
6
  export default Toggle;
@@ -1,22 +1,26 @@
1
1
  import { jsxs, jsx } from '@emotion/react/jsx-runtime';
2
- import 'react';
3
- import PropTypes from 'prop-types';
2
+ import React from 'react';
4
3
  import styled from '@emotion/styled';
5
4
  import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
6
5
 
7
6
  const Switch = /*#__PURE__*/ styled("label", {
8
- target: "ecfiyvb0",
7
+ target: "e185uavx0",
9
8
  label: "Switch"
10
9
  })("position:relative;display:inline-flex;margin:5px 0;");
11
- const Input = /*#__PURE__*/ styled("input", {
12
- target: "ecfiyvb1",
10
+ const Input$1 = /*#__PURE__*/ styled("input", {
11
+ target: "e185uavx1",
13
12
  label: "Input"
14
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), ";}");
15
- function Toggle(props) {
14
+ /**
15
+ * Toggle Component
16
+ * @param props - Component props
17
+ * @param ref - Ref forwarded to the underlying HTMLInputElement
18
+ */ function ToggleComponent(props, ref) {
16
19
  return /*#__PURE__*/ jsxs(Switch, {
17
20
  children: [
18
- /*#__PURE__*/ jsx(Input, {
21
+ /*#__PURE__*/ jsx(Input$1, {
19
22
  ...props,
23
+ ref: ref,
20
24
  type: "checkbox",
21
25
  role: "switch",
22
26
  "aria-checked": props.checked
@@ -28,9 +32,7 @@ function Toggle(props) {
28
32
  ]
29
33
  });
30
34
  }
31
- Toggle.propTypes = {
32
- /** Label for the field */ label: PropTypes.string
33
- };
35
+ const Toggle = /*#__PURE__*/ React.forwardRef(ToggleComponent);
34
36
 
35
37
  export { Toggle as default };
36
38
  //# sourceMappingURL=Toggle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Toggle.js","sources":["../../../src/components/Input/Toggle.tsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\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 = PropTypes.InferProps<\n React.AllHTMLAttributes<HTMLInputElement> & typeof Toggle.propTypes\n>;\n\nfunction Toggle(props: ToggleProps) {\n return (\n <Switch>\n <Input {...props} type=\"checkbox\" role=\"switch\" aria-checked={props.checked} />\n <span></span>\n <span>{props.label}</span>\n </Switch>\n );\n}\n\nToggle.propTypes = {\n /** Label for the field */\n label: PropTypes.string,\n};\n\nexport default Toggle;\n"],"names":["Switch","styled","Input","getThemeValue","THEME_NAME","LIGHT_GREY","DISABLED_BORDER","BACKGROUND","PRIMARY_LIGHT","PRIMARY","BORDER_LIGHT_COLOR","Toggle","props","_jsxs","_jsx","type","role","aria-checked","checked","span","label","propTypes","PropTypes","string"],"mappings":";;;;;;AAKA,MAAMA,MAAAA,iBAASC,MAAAA,CAAAA,OAAAA,EAAAA;;;;AAMf,MAAMC,KAAAA,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;AAQhE,SAASK,OAAOC,KAAkB,EAAA;AAC9B,IAAA,qBACIC,IAAA,CAACb,MAAAA,EAAAA;;0BACGc,GAAA,CAACZ,KAAAA,EAAAA;AAAO,gBAAA,GAAGU,KAAK;gBAAEG,IAAAA,EAAK,UAAA;gBAAWC,IAAAA,EAAK,QAAA;AAASC,gBAAAA,cAAAA,EAAcL,MAAMM;;0BACpEJ,GAAA,CAACK,MAAAA,EAAAA,EAAAA,CAAAA;0BACDL,GAAA,CAACK,MAAAA,EAAAA;AAAMP,gBAAAA,QAAAA,EAAAA,KAAAA,CAAMQ;;;;AAGzB;AAEAT,MAAAA,CAAOU,SAAS,GAAG;+BAEfD,KAAAA,EAAOE,SAAAA,CAAUC;AACrB,CAAA;;;;"}
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,25 +1,15 @@
1
- import React, { ReactNode } from 'react';
1
+ import React from 'react';
2
2
  /**
3
3
  * Props for the Menu component.
4
4
  * @template T - The type of value(s) in the menu.
5
5
  */
6
- interface MenuProps<T> {
6
+ type MenuProps<T> = {
7
7
  /** Multiple Menu Items can be selected */
8
8
  multiSelect?: boolean;
9
9
  /** Value(s) selected */
10
10
  value?: T | T[];
11
11
  /** Callback when the selected value changes */
12
12
  onChange?: (value: T | T[]) => void;
13
- /** Menu Items */
14
- children?: ReactNode;
15
- }
16
- /**
17
- * Menu component that allows selection of items from a list.
18
- * Supports single and multi-select modes and keyboard navigation.
19
- *
20
- * @template T - The type of value(s) in the menu.
21
- * @param {MenuProps<T> & Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'>} props - The menu properties.
22
- * @param {ForwardedRef<HTMLDivElement>} ref - The ref forwarded to the menu container.
23
- */
24
- declare const Menu: React.ForwardRefExoticComponent<MenuProps<object> & Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> & React.RefAttributes<HTMLDivElement>>;
13
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'>;
14
+ declare const Menu: <T>(props: MenuProps<T> & React.RefAttributes<HTMLDivElement>) => React.ReactElement;
25
15
  export default Menu;
@@ -5,7 +5,7 @@ import { getThemeValue, THEME_NAME } from '../../shared/constants.js';
5
5
  import MenuContext from './MenuContext.js';
6
6
 
7
7
  const MenuContainer = /*#__PURE__*/ styled("div", {
8
- target: "ez48lhb0",
8
+ target: "e1qc23xy0",
9
9
  label: "MenuContainer"
10
10
  })("flex:1;display:flex;flex-direction:column;& div:last-child{border-bottom:none;}&:focus-within{box-shadow:0 0 0 4px ", getThemeValue(THEME_NAME.PRIMARY_LIGHT), ";}");
11
11
  /**
@@ -13,11 +13,17 @@ const MenuContainer = /*#__PURE__*/ styled("div", {
13
13
  * Supports single and multi-select modes and keyboard navigation.
14
14
  *
15
15
  * @template T - The type of value(s) in the menu.
16
- * @param {MenuProps<T> & Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'>} props - The menu properties.
17
- * @param {ForwardedRef<HTMLDivElement>} ref - The ref forwarded to the menu container.
18
- */ const Menu = /*#__PURE__*/ React.forwardRef(function(props, ref) {
19
- const { multiSelect, onChange, value: propValue, ...rest } = props;
20
- const [value, setValue] = useState(propValue || (multiSelect ? [] : ''));
16
+ * @param props - The menu properties.
17
+ * @param ref - The ref forwarded to the menu container.
18
+ */ /**
19
+ * Menu Component
20
+ * @template T - The type of value(s) in the menu.
21
+ * @param props - Component props
22
+ * @param ref - Ref forwarded to the underlying HTMLDivElement
23
+ */ function MenuInner(props, ref) {
24
+ const { multiSelect = false, onChange, value: propValue, children, ...rest } = props;
25
+ // State holds either a single T or an array of T when multiSelect
26
+ const [value, setValue] = useState(propValue);
21
27
  /**
22
28
  * Updates the selected value(s).
23
29
  * Handles both single and multi-select logic.
@@ -35,6 +41,10 @@ const MenuContainer = /*#__PURE__*/ styled("div", {
35
41
  val
36
42
  ];
37
43
  }
44
+ } else {
45
+ newVal = [
46
+ val
47
+ ];
38
48
  }
39
49
  } else {
40
50
  newVal = val;
@@ -100,10 +110,11 @@ const MenuContainer = /*#__PURE__*/ styled("div", {
100
110
  firstItem?.focus();
101
111
  }
102
112
  };
103
- return /*#__PURE__*/ jsx(MenuContext.Provider, {
113
+ return(// @ts-expect-error Generic context typing
114
+ /*#__PURE__*/ jsx(MenuContext.Provider, {
104
115
  value: {
105
- value,
106
- multiSelect,
116
+ value: value,
117
+ multiSelect: !!multiSelect,
107
118
  updateValue
108
119
  },
109
120
  children: /*#__PURE__*/ jsx(MenuContainer, {
@@ -114,14 +125,11 @@ const MenuContainer = /*#__PURE__*/ styled("div", {
114
125
  tabIndex: 0,
115
126
  onKeyDown: handleKeyDown,
116
127
  onFocus: focusHandler,
117
- children: props.children
128
+ children: children
118
129
  })
119
- });
120
- });
121
- Menu.displayName = 'Menu';
122
- Menu.defaultProps = {
123
- multiSelect: false
124
- };
130
+ }));
131
+ }
132
+ const Menu = /*#__PURE__*/ React.forwardRef(MenuInner);
125
133
 
126
134
  export { Menu as default };
127
135
  //# sourceMappingURL=Menu.js.map