@economic/taco 1.14.0 → 1.14.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.
- package/dist/esm/packages/taco/src/primitives/BubbleSelect.js +1 -1
- package/dist/esm/packages/taco/src/primitives/BubbleSelect.js.map +1 -1
- package/dist/taco.cjs.development.js +1 -1
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +2 -2
@@ -17,7 +17,7 @@ const BubbleSelect = props => {
|
|
17
17
|
if (prevValue !== value && setValue) {
|
18
18
|
if (Array.isArray(value)) {
|
19
19
|
value.forEach(v => {
|
20
|
-
const option = select.querySelector(`option[value
|
20
|
+
const option = select.querySelector(`option[value='${v}']`);
|
21
21
|
if (option) {
|
22
22
|
option.selected = true;
|
23
23
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"BubbleSelect.js","sources":["../../../../../../src/primitives/BubbleSelect.tsx"],"sourcesContent":["import React from 'react';\nimport { usePreviousValue } from '../hooks/usePrevious';\n\n// taken from radix - https://github.com/radix-ui/primitives/blob/main/packages/react/select/src/Select.tsx#L1183-L1224\nexport const BubbleSelect = (props: React.SelectHTMLAttributes<HTMLSelectElement>) => {\n const { value, ...selectProps } = props;\n const ref = React.useRef<HTMLSelectElement>(null);\n const prevValue = usePreviousValue(value);\n\n // Bubble value change to parents (e.g form change event)\n React.useEffect(() => {\n const select = ref.current!;\n const descriptor = Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype, 'value') as PropertyDescriptor;\n const setValue = descriptor.set;\n\n if (prevValue !== value && setValue) {\n if (Array.isArray(value)) {\n value.forEach(v => {\n const option: HTMLOptionElement | null = select.querySelector(`option[value
|
1
|
+
{"version":3,"file":"BubbleSelect.js","sources":["../../../../../../src/primitives/BubbleSelect.tsx"],"sourcesContent":["import React from 'react';\nimport { usePreviousValue } from '../hooks/usePrevious';\n\n// taken from radix - https://github.com/radix-ui/primitives/blob/main/packages/react/select/src/Select.tsx#L1183-L1224\nexport const BubbleSelect = (props: React.SelectHTMLAttributes<HTMLSelectElement>) => {\n const { value, ...selectProps } = props;\n const ref = React.useRef<HTMLSelectElement>(null);\n const prevValue = usePreviousValue(value);\n\n // Bubble value change to parents (e.g form change event)\n React.useEffect(() => {\n const select = ref.current!;\n const descriptor = Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype, 'value') as PropertyDescriptor;\n const setValue = descriptor.set;\n\n if (prevValue !== value && setValue) {\n if (Array.isArray(value)) {\n value.forEach(v => {\n const option: HTMLOptionElement | null = select.querySelector(`option[value='${v}']`);\n\n if (option) {\n option.selected = true;\n }\n });\n } else {\n setValue.call(select, value);\n }\n\n const event = new Event('change', { bubbles: true });\n select.dispatchEvent(event);\n }\n }, [prevValue, value]);\n\n /**\n * We purposefully do not use `type=\"hidden\"` here otherwise forms that\n * wrap it will not be able to access its value via the FormData API.\n *\n * We purposefully do not add the `value` attribute here to allow the value\n * to be set programatically and bubble to any parent form `onChange` event.\n * Adding the `value` will cause React to consider the programatic\n * dispatch a duplicate and it will get swallowed.\n */\n return <select {...selectProps} defaultValue={value} ref={ref} style={{ display: 'none' }} />;\n};\n"],"names":["BubbleSelect","props","value","selectProps","ref","React","useRef","prevValue","usePreviousValue","useEffect","select","current","descriptor","Object","getOwnPropertyDescriptor","window","HTMLSelectElement","prototype","setValue","set","Array","isArray","forEach","v","option","querySelector","selected","call","event","Event","bubbles","dispatchEvent","defaultValue","style","display"],"mappings":";;;AAGA;MACaA,YAAY,GAAIC,KAAoD;EAC7E,MAAM;IAAEC,KAAK;IAAE,GAAGC;GAAa,GAAGF,KAAK;EACvC,MAAMG,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAoB,IAAI,CAAC;EACjD,MAAMC,SAAS,GAAGC,gBAAgB,CAACN,KAAK,CAAC;;EAGzCG,cAAK,CAACI,SAAS,CAAC;IACZ,MAAMC,MAAM,GAAGN,GAAG,CAACO,OAAQ;IAC3B,MAAMC,UAAU,GAAGC,MAAM,CAACC,wBAAwB,CAACC,MAAM,CAACC,iBAAiB,CAACC,SAAS,EAAE,OAAO,CAAuB;IACrH,MAAMC,QAAQ,GAAGN,UAAU,CAACO,GAAG;IAE/B,IAAIZ,SAAS,KAAKL,KAAK,IAAIgB,QAAQ,EAAE;MACjC,IAAIE,KAAK,CAACC,OAAO,CAACnB,KAAK,CAAC,EAAE;QACtBA,KAAK,CAACoB,OAAO,CAACC,CAAC;UACX,MAAMC,MAAM,GAA6Bd,MAAM,CAACe,aAAa,kBAAkBF,KAAK,CAAC;UAErF,IAAIC,MAAM,EAAE;YACRA,MAAM,CAACE,QAAQ,GAAG,IAAI;;SAE7B,CAAC;OACL,MAAM;QACHR,QAAQ,CAACS,IAAI,CAACjB,MAAM,EAAER,KAAK,CAAC;;MAGhC,MAAM0B,KAAK,GAAG,IAAIC,KAAK,CAAC,QAAQ,EAAE;QAAEC,OAAO,EAAE;OAAM,CAAC;MACpDpB,MAAM,CAACqB,aAAa,CAACH,KAAK,CAAC;;GAElC,EAAE,CAACrB,SAAS,EAAEL,KAAK,CAAC,CAAC;;;;;;;;;;EAWtB,oBAAOG,yDAAYF,WAAW;IAAE6B,YAAY,EAAE9B,KAAK;IAAEE,GAAG,EAAEA,GAAG;IAAE6B,KAAK,EAAE;MAAEC,OAAO,EAAE;;KAAY;AACjG;;;;"}
|
@@ -8203,7 +8203,7 @@ const BubbleSelect = props => {
|
|
8203
8203
|
if (prevValue !== value && setValue) {
|
8204
8204
|
if (Array.isArray(value)) {
|
8205
8205
|
value.forEach(v => {
|
8206
|
-
const option = select.querySelector(`option[value
|
8206
|
+
const option = select.querySelector(`option[value='${v}']`);
|
8207
8207
|
if (option) {
|
8208
8208
|
option.selected = true;
|
8209
8209
|
}
|