@loadsmart/loadsmart-ui 7.5.0 → 7.6.0
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/index.js +162 -162
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4063 -5327
- package/dist/index.mjs.map +1 -1
- package/dist/miranda-compatibility.theme-ChPV-BBw.js +2 -0
- package/dist/miranda-compatibility.theme-ChPV-BBw.js.map +1 -0
- package/dist/{miranda-compatibility.theme-ClCWbTIT.mjs → miranda-compatibility.theme-DQDHkWzC.mjs} +256 -312
- package/dist/miranda-compatibility.theme-DQDHkWzC.mjs.map +1 -0
- package/dist/prop-5m3D4883.mjs +54 -0
- package/dist/{prop-C4yDbi0C.mjs.map → prop-5m3D4883.mjs.map} +1 -1
- package/dist/prop-BwhJNJHO.js +2 -0
- package/dist/{prop-pWSEOvKc.js.map → prop-BwhJNJHO.js.map} +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/index.mjs +44 -43
- package/dist/testing/index.mjs.map +1 -1
- package/dist/theming/index.js +1 -1
- package/dist/theming/index.js.map +1 -1
- package/dist/theming/index.mjs +13 -12
- package/dist/theming/index.mjs.map +1 -1
- package/dist/toArray-BW3gx_gH.js +2 -0
- package/dist/toArray-BW3gx_gH.js.map +1 -0
- package/dist/toArray-DqgeO2ua.mjs +8 -0
- package/dist/toArray-DqgeO2ua.mjs.map +1 -0
- package/dist/tools/index.js +1 -1
- package/dist/tools/index.mjs +1 -1
- package/package.json +6 -5
- package/dist/miranda-compatibility.theme-C3Dt-45K.js +0 -2
- package/dist/miranda-compatibility.theme-C3Dt-45K.js.map +0 -1
- package/dist/miranda-compatibility.theme-ClCWbTIT.mjs.map +0 -1
- package/dist/prop-C4yDbi0C.mjs +0 -53
- package/dist/prop-pWSEOvKc.js +0 -2
- package/dist/toArray-BJfx0Xhj.mjs +0 -38
- package/dist/toArray-BJfx0Xhj.mjs.map +0 -1
- package/dist/toArray-Dw6F-w3t.js +0 -2
- package/dist/toArray-Dw6F-w3t.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop-
|
|
1
|
+
{"version":3,"file":"prop-5m3D4883.mjs","sources":["../src/tools/conditional.ts","../src/tools/prop.ts"],"sourcesContent":["import { isObject } from '@loadsmart/utils-object'\nimport { isFunction } from '@loadsmart/utils-function'\nimport type { F } from 'ts-toolbelt'\n\nimport { getToken } from 'theming'\nimport type { ThemeToken, ThemedProps } from 'theming'\nimport get from 'utils/toolset/get'\nimport toArray from 'utils/toolset/toArray'\n\ntype WhenProps<K> = K | undefined | ((value: K) => boolean | undefined)\n\nexport type When<P> = {\n [Key in keyof P]?: WhenProps<P[Key]> | WhenProps<P[Key]>[] | undefined\n}\n\n/**\n * Utility to generate style/class name conditions based on a components props.\n * Expected prop values can be a single value, an array of values or a function/callback.\n * @example\n * ```jsx\n * whenProps({\n * 'prop-a': true, // checks `props['prop-a']` === true`\n * 'prop-b': [1, 2], // checks `toArray([1, 2]).includes(props['prop-b'])`\n * 'prop-c': (value) => value + 1 // checks `Boolean(callback(props['prop-c']))`\n * 'prop-d': Boolean // checks `Boolean(Boolean(props['prop-d']))`\n * })\n * ```\n * @param {...Object} conditions\n * @returns {(props: Object}) => boolean} Returns function that consumes component props.\n */\nexport function whenProps<P>(conditions: When<F.Narrow<P>> | When<F.Narrow<P>>[]) {\n return function (props: P): boolean {\n const safeConditions = toArray(conditions)\n\n let res = false\n\n for (let i = 0; i < safeConditions.length; i++) {\n const condition = safeConditions[i]\n const keys = Object.keys(condition)\n\n let temp = true\n\n for (let j = 0; j < keys.length && temp; j++) {\n const key = keys[j]\n const propValue = get(props, key) as P[keyof P]\n const conditionValue = condition[key as keyof typeof condition]\n\n if (Array.isArray(conditionValue)) {\n temp = temp && toArray(conditionValue).includes(propValue)\n } else if (isFunction(conditionValue)) {\n temp = temp && Boolean(conditionValue(propValue))\n } else {\n temp = temp && (conditionValue as unknown) === propValue\n }\n }\n\n res = res || temp\n }\n\n return res\n }\n}\n\ntype ConditionObject<P> = Record<\n string,\n string | number | boolean | ((props: P) => boolean) | undefined\n>\n\nfunction handleConditionObject<P>(condition: ConditionObject<P>, props: P): string {\n const keys = Object.keys(condition || {})\n\n const res = keys.reduce((acc, key) => {\n let value = condition[key]\n\n if (isFunction(value)) {\n value = value(props)\n }\n\n if (value) {\n const tokenKey = key as ThemeToken\n const result = (getToken(tokenKey, props as unknown as ThemedProps) ?? key) as string\n return [...acc, result]\n }\n\n return acc\n }, [] as string[])\n\n return res.join(' ')\n}\n\ntype Condition<P> = number | string | ConditionObject<P> | ((props: P) => string)\n\n/**\n * Concatenate style properties or class names conditionally.\n * Conditions can be functions that consume components props,\n * objects, strings, or numbers (that will be coerced to strings).\n * @example\n * ```jsx\n * conditional(1, 'some-class', {\n * 'class-a': true,\n * 'class-b': (props) => props.showClassB,\n * }, (props) => props.className)\n * ```\n * @param conditions\n * @returns {(props: ThemedProps) => string} Returns function that consumes component props.\n */\nfunction conditional<P>(...conditions: Condition<P>[]) {\n return function (props: P): string {\n let classes: string[] = []\n\n for (let i = 0; i < conditions.length; i++) {\n const condition = conditions[i]\n\n if (isFunction(condition)) {\n classes.push(condition(props))\n } else if (isObject(condition)) {\n classes = classes.concat(handleConditionObject<P>(condition, props))\n } else if (condition) {\n classes.push(String(condition))\n }\n }\n\n return classes.join(' ')\n }\n}\n\nexport default conditional\n","function compare(...args: any[]): unknown {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const [value, defaultValue] = args\n\n if (value == null || value === false || Number.isNaN(value)) {\n return defaultValue || value\n }\n\n if (typeof value === 'string' && value.length === 0) {\n return defaultValue || value\n }\n\n return value\n}\n\n/**\n * Retrieve the key value from the props object\n * @example\n * ```jsx\n * -transform: scaleY(${(props) => props.$height || 1});\n * +transform: scaleY(${prop('$height', 1)});\n * ```\n * @param name a valid property name from the object\n * @param defaultValue a fallback value in case the property value is invalid\n * @param comparatorFn a function to be used to decide between value or defaultValue\n * @returns {(props: ThemedProps) => string} Returns function that consumes component props.\n */\nfunction prop<P, K extends keyof P = keyof P>(\n name: K,\n defaultValue?: NonNullable<P[K]>,\n comparatorFn = compare\n) {\n return (props: P): P[K] => comparatorFn(props[name], defaultValue) as P[K]\n}\n\nexport default prop\n"],"names":["whenProps","conditions","props","safeConditions","toArray","res","i","length","condition","keys","Object","temp","j","key","propValue","get","conditionValue","Array","isArray","includes","isFunction","Boolean","handleConditionObject","reduce","acc","value","result","getToken","join","conditional","classes","push","isObject","concat","String","compare","args","defaultValue","Number","isNaN","prop","name","comparatorFn"],"mappings":";;;;;AA8BO,SAASA,EAAaC,GAAqD;AAChF,SAAO,SAAUC,GAAmB;AAC5BC,UAAAA,IAAiBC,EAAQH,CAAU;AAEzC,QAAII,IAAM;AAEV,aAASC,IAAI,GAAGA,IAAIH,EAAeI,QAAQD,KAAK;AACxCE,YAAAA,IAAYL,EAAeG,CAAC,GAC5BG,IAAOC,OAAOD,KAAKD,CAAS;AAElC,UAAIG,IAAO;AAEX,eAASC,IAAI,GAAGA,IAAIH,EAAKF,UAAUI,GAAMC,KAAK;AACtCC,cAAAA,IAAMJ,EAAKG,CAAC,GACZE,IAAYC,EAAIb,GAAOW,CAAG,GAC1BG,IAAiBR,EAAUK,CAA6B;AAE1DI,QAAAA,MAAMC,QAAQF,CAAc,IAC9BL,IAAOA,KAAQP,EAAQY,CAAc,EAAEG,SAASL,CAAS,IAChDM,EAAWJ,CAAc,IAClCL,IAAOA,KAAQU,EAAQL,EAAeF,CAAS,IAE/CH,IAAOA,KAASK,MAA+BF;AAAAA,MACjD;AAGFT,MAAAA,IAAMA,KAAOM;AAAAA,IAAAA;AAGRN,WAAAA;AAAAA,EACT;AACF;AAOA,SAASiB,EAAyBd,GAA+BN,GAAkB;AAmB1EG,SAlBMK,OAAOD,KAAKD,KAAa,CAAA,CAAE,EAEvBe,OAAO,CAACC,GAAKX,MAAQ;AAChCY,QAAAA,IAAQjB,EAAUK,CAAG;AAMzB,QAJIO,EAAWK,CAAK,MAClBA,IAAQA,EAAMvB,CAAK,IAGjBuB,GAAO;AAET,YAAMC,IAAUC,EADCd,GACkBX,CAA+B,KAAKW;AAChE,aAAA,CAAC,GAAGW,GAAKE,CAAM;AAAA,IAAA;AAGjBF,WAAAA;AAAAA,EACT,GAAG,EAAc,EAENI,KAAK,GAAG;AACrB;AAkBA,SAASC,KAAkB5B,GAA4B;AACrD,SAAO,SAAUC,GAAkB;AACjC,QAAI4B,IAAoB,CAAE;AAE1B,aAASxB,IAAI,GAAGA,IAAIL,EAAWM,QAAQD,KAAK;AACpCE,YAAAA,IAAYP,EAAWK,CAAC;AAE1Bc,MAAAA,EAAWZ,CAAS,IACduB,EAAAA,KAAKvB,EAAUN,CAAK,CAAC,IACpB8B,EAASxB,CAAS,IAC3BsB,IAAUA,EAAQG,OAAOX,EAAyBd,GAAWN,CAAK,CAAC,IAC1DM,KACDuB,EAAAA,KAAKG,OAAO1B,CAAS,CAAC;AAAA,IAChC;AAGKsB,WAAAA,EAAQF,KAAK,GAAG;AAAA,EACzB;AACF;AC5HA,SAASO,KAAWC,GAAsB;AAElC,QAAA,CAACX,GAAOY,CAAY,IAAID;AAM9B,UAJIX,KAAS,QAAQA,MAAU,MAASa,OAAOC,MAAMd,CAAK,KAItD,OAAOA,KAAU,YAAYA,EAAMlB,WAAW,MACzC8B,KAAgBZ;AAI3B;AAcA,SAASe,EACPC,GACAJ,GACAK,IAAeP,GACf;AACA,SAAO,CAACjC,MAAmBwC,EAAaxC,EAAMuC,CAAI,GAAGJ,CAAY;AACnE;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const g=require("@loadsmart/utils-object"),a=require("@loadsmart/utils-function"),h=require("./theming/index.js"),p=require("lodash/get.js"),y=require("./toArray-BW3gx_gH.js"),j=t=>t&&t.__esModule?t:{default:t},b=j(p);function k(t){return function(e){const n=y.toArray(t);let r=!1;for(let o=0;o<n.length;o++){const u=n[o],s=Object.keys(u);let i=!0;for(let c=0;c<s.length&&i;c++){const d=s[c],f=b.default(e,d),l=u[d];Array.isArray(l)?i=i&&y.toArray(l).includes(f):a.isFunction(l)?i=i&&!!l(f):i=i&&l===f}r=r||i}return r}}function _(t,e){return Object.keys(t||{}).reduce((o,u)=>{let s=t[u];if(a.isFunction(s)&&(s=s(e)),s){const i=u,c=h.getToken(i,e)??u;return[...o,c]}return o},[]).join(" ")}function q(...t){return function(e){let n=[];for(let r=0;r<t.length;r++){const o=t[r];a.isFunction(o)?n.push(o(e)):g.isObject(o)?n=n.concat(_(o,e)):o&&n.push(String(o))}return n.join(" ")}}function A(...t){const[e,n]=t;return(e==null||e===!1||Number.isNaN(e)||typeof e=="string"&&e.length===0)&&n||e}function O(t,e,n=A){return r=>n(r[t],e)}exports.conditional=q;exports.prop=O;exports.whenProps=k;
|
|
2
|
+
//# sourceMappingURL=prop-BwhJNJHO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop-
|
|
1
|
+
{"version":3,"file":"prop-BwhJNJHO.js","sources":["../src/tools/conditional.ts","../src/tools/prop.ts"],"sourcesContent":["import { isObject } from '@loadsmart/utils-object'\nimport { isFunction } from '@loadsmart/utils-function'\nimport type { F } from 'ts-toolbelt'\n\nimport { getToken } from 'theming'\nimport type { ThemeToken, ThemedProps } from 'theming'\nimport get from 'utils/toolset/get'\nimport toArray from 'utils/toolset/toArray'\n\ntype WhenProps<K> = K | undefined | ((value: K) => boolean | undefined)\n\nexport type When<P> = {\n [Key in keyof P]?: WhenProps<P[Key]> | WhenProps<P[Key]>[] | undefined\n}\n\n/**\n * Utility to generate style/class name conditions based on a components props.\n * Expected prop values can be a single value, an array of values or a function/callback.\n * @example\n * ```jsx\n * whenProps({\n * 'prop-a': true, // checks `props['prop-a']` === true`\n * 'prop-b': [1, 2], // checks `toArray([1, 2]).includes(props['prop-b'])`\n * 'prop-c': (value) => value + 1 // checks `Boolean(callback(props['prop-c']))`\n * 'prop-d': Boolean // checks `Boolean(Boolean(props['prop-d']))`\n * })\n * ```\n * @param {...Object} conditions\n * @returns {(props: Object}) => boolean} Returns function that consumes component props.\n */\nexport function whenProps<P>(conditions: When<F.Narrow<P>> | When<F.Narrow<P>>[]) {\n return function (props: P): boolean {\n const safeConditions = toArray(conditions)\n\n let res = false\n\n for (let i = 0; i < safeConditions.length; i++) {\n const condition = safeConditions[i]\n const keys = Object.keys(condition)\n\n let temp = true\n\n for (let j = 0; j < keys.length && temp; j++) {\n const key = keys[j]\n const propValue = get(props, key) as P[keyof P]\n const conditionValue = condition[key as keyof typeof condition]\n\n if (Array.isArray(conditionValue)) {\n temp = temp && toArray(conditionValue).includes(propValue)\n } else if (isFunction(conditionValue)) {\n temp = temp && Boolean(conditionValue(propValue))\n } else {\n temp = temp && (conditionValue as unknown) === propValue\n }\n }\n\n res = res || temp\n }\n\n return res\n }\n}\n\ntype ConditionObject<P> = Record<\n string,\n string | number | boolean | ((props: P) => boolean) | undefined\n>\n\nfunction handleConditionObject<P>(condition: ConditionObject<P>, props: P): string {\n const keys = Object.keys(condition || {})\n\n const res = keys.reduce((acc, key) => {\n let value = condition[key]\n\n if (isFunction(value)) {\n value = value(props)\n }\n\n if (value) {\n const tokenKey = key as ThemeToken\n const result = (getToken(tokenKey, props as unknown as ThemedProps) ?? key) as string\n return [...acc, result]\n }\n\n return acc\n }, [] as string[])\n\n return res.join(' ')\n}\n\ntype Condition<P> = number | string | ConditionObject<P> | ((props: P) => string)\n\n/**\n * Concatenate style properties or class names conditionally.\n * Conditions can be functions that consume components props,\n * objects, strings, or numbers (that will be coerced to strings).\n * @example\n * ```jsx\n * conditional(1, 'some-class', {\n * 'class-a': true,\n * 'class-b': (props) => props.showClassB,\n * }, (props) => props.className)\n * ```\n * @param conditions\n * @returns {(props: ThemedProps) => string} Returns function that consumes component props.\n */\nfunction conditional<P>(...conditions: Condition<P>[]) {\n return function (props: P): string {\n let classes: string[] = []\n\n for (let i = 0; i < conditions.length; i++) {\n const condition = conditions[i]\n\n if (isFunction(condition)) {\n classes.push(condition(props))\n } else if (isObject(condition)) {\n classes = classes.concat(handleConditionObject<P>(condition, props))\n } else if (condition) {\n classes.push(String(condition))\n }\n }\n\n return classes.join(' ')\n }\n}\n\nexport default conditional\n","function compare(...args: any[]): unknown {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const [value, defaultValue] = args\n\n if (value == null || value === false || Number.isNaN(value)) {\n return defaultValue || value\n }\n\n if (typeof value === 'string' && value.length === 0) {\n return defaultValue || value\n }\n\n return value\n}\n\n/**\n * Retrieve the key value from the props object\n * @example\n * ```jsx\n * -transform: scaleY(${(props) => props.$height || 1});\n * +transform: scaleY(${prop('$height', 1)});\n * ```\n * @param name a valid property name from the object\n * @param defaultValue a fallback value in case the property value is invalid\n * @param comparatorFn a function to be used to decide between value or defaultValue\n * @returns {(props: ThemedProps) => string} Returns function that consumes component props.\n */\nfunction prop<P, K extends keyof P = keyof P>(\n name: K,\n defaultValue?: NonNullable<P[K]>,\n comparatorFn = compare\n) {\n return (props: P): P[K] => comparatorFn(props[name], defaultValue) as P[K]\n}\n\nexport default prop\n"],"names":["whenProps","conditions","props","safeConditions","toArray","res","i","length","condition","keys","Object","temp","j","key","propValue","get","conditionValue","Array","isArray","includes","isFunction","Boolean","handleConditionObject","reduce","acc","value","tokenKey","result","getToken","join","conditional","classes","push","isObject","concat","String","compare","args","defaultValue","Number","isNaN","prop","name","comparatorFn"],"mappings":"uOA8BO,SAASA,EAAaC,EAAqD,CAChF,OAAO,SAAUC,EAAmB,CAC5BC,MAAAA,EAAiBC,UAAQH,CAAU,EAEzC,IAAII,EAAM,GAEV,QAASC,EAAI,EAAGA,EAAIH,EAAeI,OAAQD,IAAK,CACxCE,MAAAA,EAAYL,EAAeG,CAAC,EAC5BG,EAAOC,OAAOD,KAAKD,CAAS,EAElC,IAAIG,EAAO,GAEX,QAASC,EAAI,EAAGA,EAAIH,EAAKF,QAAUI,EAAMC,IAAK,CAC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CAElC,KAAA,CAACZ,EAAOa,CAAY,EAAID,EAM9B,OAJIZ,GAAS,MAAQA,IAAU,IAASc,OAAOC,MAAMf,CAAK,GAItD,OAAOA,GAAU,UAAYA,EAAMlB,SAAW,IACzC+B,GAAgBb,CAI3B,CAcA,SAASgB,EACPC,EACAJ,EACAK,EAAeP,EACf,CACA,OAAQlC,GAAmByC,EAAazC,EAAMwC,CAAI,EAAGJ,CAAY,CACnE"}
|
package/dist/testing/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@testing-library/react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@testing-library/react"),E=require("../toArray-BW3gx_gH.js"),B=require("@loadsmart/utils-function"),C=require("../miranda-compatibility.theme-ChPV-BBw.js"),D=require("react"),q=require("../DragDropFile.context-D-EBrXnw.js"),b=e=>e&&e.__esModule?e:{default:e},S=b(D);function i(e){return e.parentNode.parentNode.parentNode.parentNode}async function g(e){const t=i(e);n.queries.queryByRole(t,"menu")||(n.fireEvent.click(e),await n.waitFor(()=>{expect(n.queries.getByRole(t,"menu")).toBeInTheDocument()}))}async function u(e){const t=i(e);n.queries.queryByRole(t,"menu")&&(n.fireEvent.click(n.queries.getByText(t,"Close")),await n.waitFor(()=>{expect(n.queries.queryByRole(t,"menu")).not.toBeInTheDocument()}))}async function F(e,t){const a=i(t);await g(t),n.act(()=>{t.focus()});const r=n.queries.getByLabelText(a,e);r&&r.getAttribute("aria-checked")=="false"&&n.fireEvent.click(r),await u(t)}async function R(e){const t=i(e),a=n.queries.getByLabelText(t,"Clear selection");n.fireEvent.click(a),await u(e)}async function T(e){const t=i(e);await g(e);const a=n.queries.queryAllByRole(t,"checkbox",{checked:!0});return await u(e),a}const o={getContainer:i,expand:g,collapse:u,pick:F,clear:R,getSelectedDates:T};async function h(e){await o.expand(e)}async function m(e){await o.collapse(e)}async function P(e,t){const a=o.getContainer(t);await h(t);const[r,d]=e;if(r!=null){const f=n.queries.getByTestId(a,"input-date-range-start");await o.pick(r,f)}if(d!=null){const f=n.queries.getByTestId(a,"input-date-range-end");await o.pick(d,f)}await m(t)}async function I(e){await o.clear(e)}async function N(e){return o.getSelectedDates(e)}const A={getContainer:o.getContainer,expand:h,collapse:m,pick:P,clear:I,getSelectedDates:N},y=e=>e.parentNode,L=e=>{const t=y(e),a=n.createEvent.dragOver(t);n.fireEvent(t,a)},O=e=>{const t=y(e),a=n.createEvent.dragLeave(t);n.fireEvent(t,a)},$=(e,t)=>{const a=y(e),r=n.createEvent.drop(a);Object.defineProperty(r,"dataTransfer",{value:{files:E.toArray(t)}}),n.fireEvent(a,r)},M={dragOver:L,dragLeave:O,dropFiles:$};function w(e){return e.parentNode.parentNode.parentNode}function c(e){return e.parentNode.parentNode.nextSibling}function k(e){return e.parentNode.nextSibling.nextSibling}function x(e){return e.parentNode}function p(e){return w(e).children.length===3}async function v(e){const t=x(e);n.within(t).queryByTestId("select-trigger-loading")&&await n.waitForElementToBeRemoved(()=>n.within(t).queryByTestId("select-trigger-loading"),{timeout:2500})}async function s(e){if(await v(e),p(e))return;const t=k(e);await n.waitFor(()=>{expect(t).toBeEnabled()}),n.act(()=>{e.dispatchEvent(new MouseEvent("click",{bubbles:!0}))}),await n.waitFor(()=>{expect(n.within(w(e)).getByRole("listbox")).toBeInTheDocument()})}async function l(e){if(!p(e))return;const t=k(e);n.fireEvent.click(t),await n.waitFor(()=>{expect(n.within(w(e)).queryByRole("listbox")).not.toBeInTheDocument()})}async function _(e,t){await s(t);const a=c(t),r=await n.within(a).findByLabelText(e);r&&r.getAttribute("aria-selected")=="false"&&(n.fireEvent.mouseDown(r),n.act(()=>{r.focus()}),n.fireEvent.mouseUp(r),n.fireEvent.click(r)),await l(t)}async function j(e,t){await s(t);const a=c(t),r=await n.within(a).findByLabelText(e);r&&r.getAttribute("aria-selected")==="true"&&n.fireEvent.click(r),await l(t)}async function z(e){await v(e);const t=x(e),a=n.within(t).getByTestId("select-trigger-clear");a&&n.fireEvent.click(a)}async function H(e,t){n.fireEvent.change(t,{target:{value:e}}),await v(t);const a=c(t);await n.within(a).findAllByRole("option")}async function U(e){await s(e);const t=c(e),a=n.within(t).queryAllByRole("option");return await l(e),a}async function V(e){await s(e);const t=c(e);let a=[];try{a=await n.within(t).findAllByRole("option",{selected:!0})}catch{a=[]}return await l(e),a}const W={select:_,unselect:j,clear:z,search:H,expand:s,collapse:l,getOptions:U,getSelectedOptions:V,isMenuExpanded:p};function Q(e){return E.toArray(e).map(t=>{for(;B.isFunction(t);)t=t({theme:C.alice});return t}).join("")}const Z={fileList:[],onFilesAdded:jest.fn(),onRetryUpload:jest.fn(),onRemoveFile:jest.fn()},G=(e,t)=>{const a={...Z,...t},r=d=>S.default.createElement(q.DragDropFileContext.Provider,{value:a},d);return n.render(r(e))};exports.DatePickerEvent=o;exports.DateRangePickerEvent=A;exports.DragDropFileEvent=M;exports.SelectEvent=W;exports.getInterpolatedStyles=Q;exports.renderWithDragDropFileProvider=G;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/testing/DatePickerEvent/DatePickerEvent.ts","../../src/testing/DatePickerEvent/DateRangePickerEvent.ts","../../src/testing/DragDropFileEvent/DragDropFileEvent.ts","../../src/testing/SelectEvent/SelectEvent.ts","../../src/testing/getInterpolatedStyles/getInterpolatedStyles.ts","../../src/testing/renderWithDragDropFileProvider/renderWithDragDropFileProvider.tsx"],"sourcesContent":["/* eslint-disable */\nimport { act, queries, fireEvent, waitFor, waitForElementToBeRemoved } from '@testing-library/react'\n// find the date picker container from its input field 🤷\nfunction getContainerFromInput(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.parentNode!.parentNode!.parentNode as HTMLElement\n}\n\n/**\n * Expand the `DatePicker` calendar, if it not already expanded.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function expand(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n // if menu is rendered, then the select is already expanded\n if (queries.queryByRole(datePickerContainer, 'menu')) {\n return\n }\n\n fireEvent.click(input)\n\n await waitFor(() => {\n expect(queries.getByRole(datePickerContainer, 'menu')).toBeInTheDocument()\n })\n}\n\n/**\n * Collapse the `DatePicker` calendar, if it not already collapsed.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n // if menu is not rendered, then the select is already collapsed\n if (!queries.queryByRole(datePickerContainer, 'menu')) {\n return\n }\n\n fireEvent.click(queries.getByText(datePickerContainer, 'Close'))\n\n await waitFor(() => {\n expect(queries.queryByRole(datePickerContainer, 'menu')).not.toBeInTheDocument()\n })\n}\n\n/**\n * Pick (select) the provided day in the current month/year.\n * Notice that we programatically expand the `DatePicker` calendar before picking the date.\n * @param {string} day - Label for the day to be picked, formatted as mm/dd/yyyy.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function pick(day: string, input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n await expand(input)\n\n act(() => {\n input.focus()\n })\n\n const dayElement = queries.getByLabelText(datePickerContainer, day)\n\n if (dayElement && dayElement.getAttribute('aria-checked') == 'false') {\n fireEvent.click(dayElement)\n }\n\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function clear(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n const clearButton = queries.getByLabelText(datePickerContainer, 'Clear selection')\n\n fireEvent.click(clearButton)\n\n await collapse(input)\n}\n\n/**\n * Get options elements currently selected in the `DatePicker` calendar.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getSelectedDates(input: HTMLElement): Promise<HTMLElement[]> {\n const datePickerContainer = getContainerFromInput(input)\n\n await expand(input)\n\n const selectedDays: HTMLElement[] = queries.queryAllByRole(datePickerContainer, 'checkbox', {\n checked: true,\n })\n\n await collapse(input)\n\n return selectedDays\n}\n\nconst datePickerEvent = {\n getContainer: getContainerFromInput,\n expand,\n collapse,\n pick,\n clear,\n getSelectedDates,\n}\n\nexport default datePickerEvent\n","/* eslint-disable */\nimport { queries } from '@testing-library/react'\n\nimport DatePickerEvent from './DatePickerEvent'\n\n/**\n * Expand the `DatePicker` calendar, if it not already expanded.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function expand(input: HTMLElement): Promise<void> {\n await DatePickerEvent.expand(input)\n}\n\n/**\n * Collapse the `DatePicker` calendar, if it not already collapsed.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n await DatePickerEvent.collapse(input)\n}\n\n/**\n * Pick (select) the provided day in the current month/year.\n * Notice that we programatically expand the `DatePicker` calendar before picking the date.\n * @param {string} day - Label for the day to be picked, formatted as mm/dd/yyyy.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function pick(range: [string | null, string | null], input: HTMLElement): Promise<void> {\n const dateRangePickerContainer = DatePickerEvent.getContainer(input)\n\n await expand(input)\n\n const [rangeStart, rangeEnd] = range\n\n if (rangeStart != null) {\n const dateRangeStartInput = queries.getByTestId(\n dateRangePickerContainer,\n 'input-date-range-start'\n )\n\n await DatePickerEvent.pick(rangeStart, dateRangeStartInput)\n }\n\n if (rangeEnd != null) {\n const dateRangeEndInput = queries.getByTestId(dateRangePickerContainer, 'input-date-range-end')\n\n await DatePickerEvent.pick(rangeEnd, dateRangeEndInput)\n }\n\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function clear(input: HTMLElement): Promise<void> {\n await DatePickerEvent.clear(input)\n}\n\n/**\n * Get options elements currently selected in the `DatePicker` calendar.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getSelectedDates(input: HTMLElement): Promise<HTMLElement[]> {\n return DatePickerEvent.getSelectedDates(input)\n}\n\nexport const dateRangePickerEvent = {\n getContainer: DatePickerEvent.getContainer,\n expand,\n collapse,\n pick,\n clear,\n getSelectedDates,\n}\n\nexport default dateRangePickerEvent\n","import { createEvent, fireEvent } from '@testing-library/react'\n\nimport toArray from 'utils/toolset/toArray'\n\n/**\n * Get the input dropzone, which is the input parent (label).\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst getDropZoneFromInput = (input: HTMLInputElement): HTMLLabelElement =>\n input.parentNode as HTMLLabelElement\n\n/**\n * Simulates the onDragOver event on the drop zone.\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dragOver = (input: HTMLInputElement) => {\n const dropzone = getDropZoneFromInput(input)\n\n const dragOverEvent = createEvent.dragOver(dropzone)\n\n fireEvent(dropzone, dragOverEvent)\n}\n\n/**\n * Simulates the onDragLeave event on the drop zone.\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dragLeave = (input: HTMLInputElement) => {\n const dropzone = getDropZoneFromInput(input)\n\n const dragLeaveEvent = createEvent.dragLeave(dropzone)\n\n fireEvent(dropzone, dragLeaveEvent)\n}\n\n/**\n * Simulates the onDrop event on the drop zone. You can provide a list of files or a single file.\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dropFiles = (input: HTMLInputElement, files: File | File[]) => {\n const dropzone = getDropZoneFromInput(input)\n\n const fileDropEvent = createEvent.drop(dropzone)\n\n Object.defineProperty(fileDropEvent, 'dataTransfer', { value: { files: toArray(files) } })\n\n fireEvent(dropzone, fileDropEvent)\n}\n\nexport const DragDropFileEvent = {\n dragOver,\n dragLeave,\n dropFiles,\n}\n\nexport default DragDropFileEvent\n","import { act, waitFor, within, waitForElementToBeRemoved, fireEvent } from '@testing-library/react'\n\n// based on https://github.com/romgain/react-select-event/blob/master/src/index.ts\n\n// find the select container from its input field 🤷\nfunction getSelectContainer(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.parentNode!.parentNode as HTMLElement\n}\n\n/**\n * Please, make sure to call expand before trying to get the menu container\n */\nfunction getSelectMenu(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.parentNode!.nextSibling as HTMLElement\n}\n\nfunction getSelectTriggerHandle(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.nextSibling!.nextSibling as HTMLElement\n}\n\nfunction getSelectSearchContainer(input: HTMLElement): HTMLElement {\n return input.parentNode as HTMLElement\n}\n\nfunction isSelectMenuExpanded(input: HTMLElement): boolean {\n const selectContainer = getSelectContainer(input)\n\n /**\n * Once the select is expanded, we have the following structure:\n * +-------------+\n * | Close button (visually hidden)\n * +-------------+\n * | DropdownTrigger\n * +-------------+\n * | Popover\n * +-------------+\n *\n * This, if the container has 3 children, we assume the menu is expanded\n */\n return selectContainer.children.length === 3\n}\n\n/**\n * This is needed because some datasources might be asynchronous.\n * To ensure that the data they retrieve will be available, we wait for the\n * querying phase to finish.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n */\nasync function waitForPendingQuery(input: HTMLElement) {\n const searchContainer = getSelectSearchContainer(input)\n\n if (!within(searchContainer).queryByTestId('select-trigger-loading')) {\n return\n }\n\n await waitForElementToBeRemoved(\n () => within(searchContainer).queryByTestId('select-trigger-loading'),\n { timeout: 2500 }\n )\n}\n\n/**\n * Expand the `Select` menu, if it not already expanded.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function expand(input: HTMLElement): Promise<void> {\n await waitForPendingQuery(input)\n\n if (isSelectMenuExpanded(input)) {\n return\n }\n\n const triggerHandle = getSelectTriggerHandle(input)\n\n await waitFor(() => {\n expect(triggerHandle).toBeEnabled()\n })\n\n /**\n * Using act and a manually dispatched event so we can account for the\n * state changes that happen when the search input is clicked.\n * This is mainly related to the `handleEvent` from the `useClickOutside` hook.\n */\n act(() => {\n input.dispatchEvent(new MouseEvent('click', { bubbles: true }))\n })\n\n await waitFor(() => {\n expect(within(getSelectContainer(input)).getByRole('listbox')).toBeInTheDocument()\n })\n}\n\n/**\n * Collapse the `Select` menu, if it not already collapsed.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n if (!isSelectMenuExpanded(input)) {\n return\n }\n\n const triggerHandle = getSelectTriggerHandle(input)\n\n fireEvent.click(triggerHandle)\n\n await waitFor(() => {\n expect(within(getSelectContainer(input)).queryByRole('listbox')).not.toBeInTheDocument()\n })\n}\n\n/**\n * Select the provided option(s), if they are present in the menu.\n * Notice that we programatically expand the `Select` menu before select the item\n * @param {string | RegExp} option - Label for the option to be selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function select(option: string | RegExp, input: HTMLElement): Promise<void> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const optionElement = await within(menuContainer).findByLabelText(option)\n\n // click the option if exists; Select currently closes when an item is clicked.\n if (optionElement && optionElement.getAttribute('aria-selected') == 'false') {\n /**\n * This is a replacement for the `userEvent.click`.\n * We are adopting this approach to remove the peer dep to @testing-library/user-event for\n * applications using this helper, so they are not tied to the same user-event as this library.\n * It follows the same sequence of event stated in the documentation available at:\n * https://testing-library.com/docs/guide-events/#interactions-vs-events\n */\n fireEvent.mouseDown(optionElement)\n\n act(() => {\n optionElement.focus()\n })\n\n fireEvent.mouseUp(optionElement)\n fireEvent.click(optionElement)\n }\n\n // we collapse in the case the option was not clicked\n await collapse(input)\n}\n\n/**\n * Unselect the provided option(s), if they are present in the menu AND are selected.\n * Notice that we programatically expand the `Select` menu before select the item\n * @param {string} option - Label for the option to be unselected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function unselect(option: string, input: HTMLElement): Promise<void> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const optionElement = await within(menuContainer).findByLabelText(option)\n\n // ensures that the option exists and IS selected\n if (optionElement && optionElement.getAttribute('aria-selected') === 'true') {\n fireEvent.click(optionElement)\n }\n\n // we collapse in the case the option was not clicked\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function clear(input: HTMLElement): Promise<void> {\n await waitForPendingQuery(input)\n\n const searchContainer = getSelectSearchContainer(input)\n\n const clearButton = within(searchContainer).getByTestId('select-trigger-clear')\n\n if (clearButton) {\n fireEvent.click(clearButton)\n }\n}\n\n/**\n * Perform search based on the given `query`. It will fail if the option is not found.\n * @param {string} query - Search term.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function search(query: string, input: HTMLElement): Promise<void> {\n fireEvent.change(input, {\n target: { value: query },\n })\n\n await waitForPendingQuery(input)\n\n const menuContainer = getSelectMenu(input)\n\n await within(menuContainer).findAllByRole('option')\n}\n\n/**\n * Get options elements currently available in the `Select` menu.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getOptions(input: HTMLElement): Promise<HTMLElement[]> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const options = within(menuContainer).queryAllByRole('option')\n\n await collapse(input)\n\n return options\n}\n\n/**\n * Get options elements currently selected in the `Select` menu.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getSelectedOptions(input: HTMLElement): Promise<HTMLElement[]> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n let selectedOptions: HTMLElement[] = []\n\n try {\n selectedOptions = await within(menuContainer).findAllByRole('option', {\n selected: true,\n })\n } catch (err) {\n selectedOptions = []\n }\n\n await collapse(input)\n\n return selectedOptions\n}\n\nexport const selectEvent = {\n select,\n unselect,\n clear,\n search,\n expand,\n collapse,\n getOptions,\n getSelectedOptions,\n isMenuExpanded: isSelectMenuExpanded,\n}\n\nexport default selectEvent\n","import type { Interpolation, ThemeProps } from 'styled-components'\nimport { isFunction } from '@loadsmart/utils-function'\n\nimport { Alice } from '../../theming/themes'\nimport type { CustomTheme } from '../../theming'\nimport toArray from 'utils/toolset/toArray'\n\ntype ThemedInterpolation = Interpolation<ThemeProps<CustomTheme>>\n\n/**\n * Use this function to simulate the CSS that would be generated by styled-components\n * @param {Interpolation<ThemeProps<CustomTheme>>} styles - A `css` reference with interpolated styles\n * @returns {string} The final CSS\n */\nexport default function getInterpolatedStyles(styles: ThemedInterpolation): string {\n return toArray(styles)\n .map((interpolation) => {\n while (isFunction(interpolation)) {\n interpolation = interpolation({ theme: Alice })\n }\n\n return interpolation\n })\n .join('')\n}\n","import React, { ReactNode } from 'react'\nimport { render } from '@testing-library/react'\nimport type { RenderResult } from '@testing-library/react'\n\nimport type { DragDropFileContextValue } from '../../components/DragDropFile/types'\nimport { DragDropFileContext } from '../../components/DragDropFile/DragDropFile.context'\n\nconst defaultContextValueMock: DragDropFileContextValue = {\n fileList: [],\n onFilesAdded: jest.fn(),\n onRetryUpload: jest.fn(),\n onRemoveFile: jest.fn(),\n}\n\nconst renderWithDragDropFileProvider = (\n ui: ReactNode,\n customContext?: Partial<DragDropFileContextValue>\n): RenderResult => {\n const contextValue = { ...defaultContextValueMock, ...customContext }\n\n const renderedUi = (children: ReactNode) => (\n <DragDropFileContext.Provider value={contextValue}>{children}</DragDropFileContext.Provider>\n )\n\n return render(renderedUi(ui))\n}\n\nexport default renderWithDragDropFileProvider\n"],"names":["getContainerFromInput","input","parentNode","expand","datePickerContainer","queries","queryByRole","fireEvent","click","waitFor","expect","getByRole","toBeInTheDocument","collapse","getByText","not","pick","day","act","focus","dayElement","getByLabelText","getAttribute","clear","clearButton","getSelectedDates","selectedDays","queryAllByRole","checked","datePickerEvent","getContainer","DatePickerEvent","range","dateRangePickerContainer","rangeStart","rangeEnd","dateRangeStartInput","getByTestId","dateRangeEndInput","dateRangePickerEvent","getDropZoneFromInput","dragOver","dropzone","dragOverEvent","createEvent","dragLeave","dragLeaveEvent","dropFiles","files","fileDropEvent","drop","defineProperty","value","toArray","DragDropFileEvent","getSelectContainer","getSelectMenu","nextSibling","getSelectTriggerHandle","getSelectSearchContainer","isSelectMenuExpanded","selectContainer","children","length","waitForPendingQuery","searchContainer","within","queryByTestId","waitForElementToBeRemoved","timeout","triggerHandle","toBeEnabled","dispatchEvent","MouseEvent","bubbles","select","option","menuContainer","optionElement","findByLabelText","mouseDown","mouseUp","unselect","search","query","change","target","findAllByRole","getOptions","options","getSelectedOptions","selectedOptions","selected","selectEvent","isMenuExpanded","getInterpolatedStyles","styles","map","interpolation","isFunction","theme","Alice","join","defaultContextValueMock","fileList","onFilesAdded","jest","fn","onRetryUpload","onRemoveFile","renderWithDragDropFileProvider","ui","customContext","contextValue","renderedUi","React","DragDropFileContext","render"],"mappings":"oUAGA,SAASA,EAAsBC,EAAiC,CAEvDA,OAAAA,EAAMC,WAAYA,WAAYA,WAAYA,UACnD,CAOA,eAAeC,EAAOF,EAAmC,CACjDG,MAAAA,EAAsBJ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AAA,WAAAA,WAAWD,CAAa,GAC7BA,EAAgBA,EAAc,CAAEE,MAAOC,EAAAA,KAAAA,CAAO,EAGzCH,OAAAA,CAAAA,CACR,EACAI,KAAK,EAAE,CACZ,CCjBA,MAAMC,EAAoD,CACxDC,SAAU,CAAE,EACZC,aAAcC,KAAKC,GAAG,EACtBC,cAAeF,KAAKC,GAAG,EACvBE,aAAcH,KAAKC,GAAG,CACxB,EAEMG,EAAiCA,CACrCC,EACAC,IACiB,CACjB,MAAMC,EAAe,CAAE,GAAGV,EAAyB,GAAGS,CAAc,EAE9DE,EAAcpD,GAClBqD,EAAAA,QAAA,cAACC,sBAAoB,SAApB,CAA6B,MAAOH,CAAAA,EAAenD,CAAS,EAGxDuD,OAAAA,EAAAA,OAAOH,EAAWH,CAAE,CAAC,CAC9B"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/testing/DatePickerEvent/DatePickerEvent.ts","../../src/testing/DatePickerEvent/DateRangePickerEvent.ts","../../src/testing/DragDropFileEvent/DragDropFileEvent.ts","../../src/testing/SelectEvent/SelectEvent.ts","../../src/testing/getInterpolatedStyles/getInterpolatedStyles.ts","../../src/testing/renderWithDragDropFileProvider/renderWithDragDropFileProvider.tsx"],"sourcesContent":["/* eslint-disable */\nimport { act, queries, fireEvent, waitFor, waitForElementToBeRemoved } from '@testing-library/react'\n// find the date picker container from its input field 🤷\nfunction getContainerFromInput(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.parentNode!.parentNode!.parentNode as HTMLElement\n}\n\n/**\n * Expand the `DatePicker` calendar, if it not already expanded.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function expand(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n // if menu is rendered, then the select is already expanded\n if (queries.queryByRole(datePickerContainer, 'menu')) {\n return\n }\n\n fireEvent.click(input)\n\n await waitFor(() => {\n expect(queries.getByRole(datePickerContainer, 'menu')).toBeInTheDocument()\n })\n}\n\n/**\n * Collapse the `DatePicker` calendar, if it not already collapsed.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n // if menu is not rendered, then the select is already collapsed\n if (!queries.queryByRole(datePickerContainer, 'menu')) {\n return\n }\n\n fireEvent.click(queries.getByText(datePickerContainer, 'Close'))\n\n await waitFor(() => {\n expect(queries.queryByRole(datePickerContainer, 'menu')).not.toBeInTheDocument()\n })\n}\n\n/**\n * Pick (select) the provided day in the current month/year.\n * Notice that we programatically expand the `DatePicker` calendar before picking the date.\n * @param {string} day - Label for the day to be picked, formatted as mm/dd/yyyy.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function pick(day: string, input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n await expand(input)\n\n act(() => {\n input.focus()\n })\n\n const dayElement = queries.getByLabelText(datePickerContainer, day)\n\n if (dayElement && dayElement.getAttribute('aria-checked') == 'false') {\n fireEvent.click(dayElement)\n }\n\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function clear(input: HTMLElement): Promise<void> {\n const datePickerContainer = getContainerFromInput(input)\n\n const clearButton = queries.getByLabelText(datePickerContainer, 'Clear selection')\n\n fireEvent.click(clearButton)\n\n await collapse(input)\n}\n\n/**\n * Get options elements currently selected in the `DatePicker` calendar.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getSelectedDates(input: HTMLElement): Promise<HTMLElement[]> {\n const datePickerContainer = getContainerFromInput(input)\n\n await expand(input)\n\n const selectedDays: HTMLElement[] = queries.queryAllByRole(datePickerContainer, 'checkbox', {\n checked: true,\n })\n\n await collapse(input)\n\n return selectedDays\n}\n\nconst datePickerEvent = {\n getContainer: getContainerFromInput,\n expand,\n collapse,\n pick,\n clear,\n getSelectedDates,\n}\n\nexport default datePickerEvent\n","/* eslint-disable */\nimport { queries } from '@testing-library/react'\n\nimport DatePickerEvent from './DatePickerEvent'\n\n/**\n * Expand the `DatePicker` calendar, if it not already expanded.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function expand(input: HTMLElement): Promise<void> {\n await DatePickerEvent.expand(input)\n}\n\n/**\n * Collapse the `DatePicker` calendar, if it not already collapsed.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n await DatePickerEvent.collapse(input)\n}\n\n/**\n * Pick (select) the provided day in the current month/year.\n * Notice that we programatically expand the `DatePicker` calendar before picking the date.\n * @param {string} day - Label for the day to be picked, formatted as mm/dd/yyyy.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function pick(range: [string | null, string | null], input: HTMLElement): Promise<void> {\n const dateRangePickerContainer = DatePickerEvent.getContainer(input)\n\n await expand(input)\n\n const [rangeStart, rangeEnd] = range\n\n if (rangeStart != null) {\n const dateRangeStartInput = queries.getByTestId(\n dateRangePickerContainer,\n 'input-date-range-start'\n )\n\n await DatePickerEvent.pick(rangeStart, dateRangeStartInput)\n }\n\n if (rangeEnd != null) {\n const dateRangeEndInput = queries.getByTestId(dateRangePickerContainer, 'input-date-range-end')\n\n await DatePickerEvent.pick(rangeEnd, dateRangeEndInput)\n }\n\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<void>}\n */\nasync function clear(input: HTMLElement): Promise<void> {\n await DatePickerEvent.clear(input)\n}\n\n/**\n * Get options elements currently selected in the `DatePicker` calendar.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `DatePicker`\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getSelectedDates(input: HTMLElement): Promise<HTMLElement[]> {\n return DatePickerEvent.getSelectedDates(input)\n}\n\nexport const dateRangePickerEvent = {\n getContainer: DatePickerEvent.getContainer,\n expand,\n collapse,\n pick,\n clear,\n getSelectedDates,\n}\n\nexport default dateRangePickerEvent\n","import { createEvent, fireEvent } from '@testing-library/react'\n\nimport toArray from 'utils/toolset/toArray'\n\n/**\n * Get the input dropzone, which is the input parent (label).\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst getDropZoneFromInput = (input: HTMLInputElement): HTMLLabelElement =>\n input.parentNode as HTMLLabelElement\n\n/**\n * Simulates the onDragOver event on the drop zone.\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dragOver = (input: HTMLInputElement) => {\n const dropzone = getDropZoneFromInput(input)\n\n const dragOverEvent = createEvent.dragOver(dropzone)\n\n fireEvent(dropzone, dragOverEvent)\n}\n\n/**\n * Simulates the onDragLeave event on the drop zone.\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dragLeave = (input: HTMLInputElement) => {\n const dropzone = getDropZoneFromInput(input)\n\n const dragLeaveEvent = createEvent.dragLeave(dropzone)\n\n fireEvent(dropzone, dragLeaveEvent)\n}\n\n/**\n * Simulates the onDrop event on the drop zone. You can provide a list of files or a single file.\n * @param {HTMLInputElement} input - You can refer to this element by the aria-label you provide to the DragDropFile component\n */\nconst dropFiles = (input: HTMLInputElement, files: File | File[]) => {\n const dropzone = getDropZoneFromInput(input)\n\n const fileDropEvent = createEvent.drop(dropzone)\n\n Object.defineProperty(fileDropEvent, 'dataTransfer', { value: { files: toArray(files) } })\n\n fireEvent(dropzone, fileDropEvent)\n}\n\nexport const DragDropFileEvent = {\n dragOver,\n dragLeave,\n dropFiles,\n}\n\nexport default DragDropFileEvent\n","import { act, waitFor, within, waitForElementToBeRemoved, fireEvent } from '@testing-library/react'\n\n// based on https://github.com/romgain/react-select-event/blob/master/src/index.ts\n\n// find the select container from its input field 🤷\nfunction getSelectContainer(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.parentNode!.parentNode as HTMLElement\n}\n\n/**\n * Please, make sure to call expand before trying to get the menu container\n */\nfunction getSelectMenu(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.parentNode!.nextSibling as HTMLElement\n}\n\nfunction getSelectTriggerHandle(input: HTMLElement): HTMLElement {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return input.parentNode!.nextSibling!.nextSibling as HTMLElement\n}\n\nfunction getSelectSearchContainer(input: HTMLElement): HTMLElement {\n return input.parentNode as HTMLElement\n}\n\nfunction isSelectMenuExpanded(input: HTMLElement): boolean {\n const selectContainer = getSelectContainer(input)\n\n /**\n * Once the select is expanded, we have the following structure:\n * +-------------+\n * | Close button (visually hidden)\n * +-------------+\n * | DropdownTrigger\n * +-------------+\n * | Popover\n * +-------------+\n *\n * This, if the container has 3 children, we assume the menu is expanded\n */\n return selectContainer.children.length === 3\n}\n\n/**\n * This is needed because some datasources might be asynchronous.\n * To ensure that the data they retrieve will be available, we wait for the\n * querying phase to finish.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n */\nasync function waitForPendingQuery(input: HTMLElement) {\n const searchContainer = getSelectSearchContainer(input)\n\n if (!within(searchContainer).queryByTestId('select-trigger-loading')) {\n return\n }\n\n await waitForElementToBeRemoved(\n () => within(searchContainer).queryByTestId('select-trigger-loading'),\n { timeout: 2500 }\n )\n}\n\n/**\n * Expand the `Select` menu, if it not already expanded.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function expand(input: HTMLElement): Promise<void> {\n await waitForPendingQuery(input)\n\n if (isSelectMenuExpanded(input)) {\n return\n }\n\n const triggerHandle = getSelectTriggerHandle(input)\n\n await waitFor(() => {\n expect(triggerHandle).toBeEnabled()\n })\n\n /**\n * Using act and a manually dispatched event so we can account for the\n * state changes that happen when the search input is clicked.\n * This is mainly related to the `handleEvent` from the `useClickOutside` hook.\n */\n act(() => {\n input.dispatchEvent(new MouseEvent('click', { bubbles: true }))\n })\n\n await waitFor(() => {\n expect(within(getSelectContainer(input)).getByRole('listbox')).toBeInTheDocument()\n })\n}\n\n/**\n * Collapse the `Select` menu, if it not already collapsed.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function collapse(input: HTMLElement): Promise<void> {\n if (!isSelectMenuExpanded(input)) {\n return\n }\n\n const triggerHandle = getSelectTriggerHandle(input)\n\n fireEvent.click(triggerHandle)\n\n await waitFor(() => {\n expect(within(getSelectContainer(input)).queryByRole('listbox')).not.toBeInTheDocument()\n })\n}\n\n/**\n * Select the provided option(s), if they are present in the menu.\n * Notice that we programatically expand the `Select` menu before select the item\n * @param {string | RegExp} option - Label for the option to be selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function select(option: string | RegExp, input: HTMLElement): Promise<void> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const optionElement = await within(menuContainer).findByLabelText(option)\n\n // click the option if exists; Select currently closes when an item is clicked.\n if (optionElement && optionElement.getAttribute('aria-selected') == 'false') {\n /**\n * This is a replacement for the `userEvent.click`.\n * We are adopting this approach to remove the peer dep to @testing-library/user-event for\n * applications using this helper, so they are not tied to the same user-event as this library.\n * It follows the same sequence of event stated in the documentation available at:\n * https://testing-library.com/docs/guide-events/#interactions-vs-events\n */\n fireEvent.mouseDown(optionElement)\n\n act(() => {\n optionElement.focus()\n })\n\n fireEvent.mouseUp(optionElement)\n fireEvent.click(optionElement)\n }\n\n // we collapse in the case the option was not clicked\n await collapse(input)\n}\n\n/**\n * Unselect the provided option(s), if they are present in the menu AND are selected.\n * Notice that we programatically expand the `Select` menu before select the item\n * @param {string} option - Label for the option to be unselected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function unselect(option: string, input: HTMLElement): Promise<void> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const optionElement = await within(menuContainer).findByLabelText(option)\n\n // ensures that the option exists and IS selected\n if (optionElement && optionElement.getAttribute('aria-selected') === 'true') {\n fireEvent.click(optionElement)\n }\n\n // we collapse in the case the option was not clicked\n await collapse(input)\n}\n\n/**\n * Clear the selection, if there are any options selected.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function clear(input: HTMLElement): Promise<void> {\n await waitForPendingQuery(input)\n\n const searchContainer = getSelectSearchContainer(input)\n\n const clearButton = within(searchContainer).getByTestId('select-trigger-clear')\n\n if (clearButton) {\n fireEvent.click(clearButton)\n }\n}\n\n/**\n * Perform search based on the given `query`. It will fail if the option is not found.\n * @param {string} query - Search term.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<void>}\n */\nasync function search(query: string, input: HTMLElement): Promise<void> {\n fireEvent.change(input, {\n target: { value: query },\n })\n\n await waitForPendingQuery(input)\n\n const menuContainer = getSelectMenu(input)\n\n await within(menuContainer).findAllByRole('option')\n}\n\n/**\n * Get options elements currently available in the `Select` menu.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getOptions(input: HTMLElement): Promise<HTMLElement[]> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n\n const options = within(menuContainer).queryAllByRole('option')\n\n await collapse(input)\n\n return options\n}\n\n/**\n * Get options elements currently selected in the `Select` menu.\n * @param {HTMLElement} input - You can refer to this element by the label you applied to the `Select`.\n * @returns {Promise<HTMLElement[]>}\n */\nasync function getSelectedOptions(input: HTMLElement): Promise<HTMLElement[]> {\n await expand(input)\n\n const menuContainer = getSelectMenu(input)\n let selectedOptions: HTMLElement[] = []\n\n try {\n selectedOptions = await within(menuContainer).findAllByRole('option', {\n selected: true,\n })\n } catch (err) {\n selectedOptions = []\n }\n\n await collapse(input)\n\n return selectedOptions\n}\n\nexport const selectEvent = {\n select,\n unselect,\n clear,\n search,\n expand,\n collapse,\n getOptions,\n getSelectedOptions,\n isMenuExpanded: isSelectMenuExpanded,\n}\n\nexport default selectEvent\n","import type { Interpolation, ThemeProps } from 'styled-components'\nimport { isFunction } from '@loadsmart/utils-function'\n\nimport { Alice } from '../../theming/themes'\nimport type { CustomTheme } from '../../theming'\nimport toArray from 'utils/toolset/toArray'\n\ntype ThemedInterpolation = Interpolation<ThemeProps<CustomTheme>>\n\n/**\n * Use this function to simulate the CSS that would be generated by styled-components\n * @param {Interpolation<ThemeProps<CustomTheme>>} styles - A `css` reference with interpolated styles\n * @returns {string} The final CSS\n */\nexport default function getInterpolatedStyles(styles: ThemedInterpolation): string {\n return toArray(styles)\n .map((interpolation) => {\n while (isFunction(interpolation)) {\n interpolation = interpolation({ theme: Alice })\n }\n\n return interpolation\n })\n .join('')\n}\n","import React, { ReactNode } from 'react'\nimport { render } from '@testing-library/react'\nimport type { RenderResult } from '@testing-library/react'\n\nimport type { DragDropFileContextValue } from '../../components/DragDropFile/types'\nimport { DragDropFileContext } from '../../components/DragDropFile/DragDropFile.context'\n\nconst defaultContextValueMock: DragDropFileContextValue = {\n fileList: [],\n onFilesAdded: jest.fn(),\n onRetryUpload: jest.fn(),\n onRemoveFile: jest.fn(),\n}\n\nconst renderWithDragDropFileProvider = (\n ui: ReactNode,\n customContext?: Partial<DragDropFileContextValue>\n): RenderResult => {\n const contextValue = { ...defaultContextValueMock, ...customContext }\n\n const renderedUi = (children: ReactNode) => (\n <DragDropFileContext.Provider value={contextValue}>{children}</DragDropFileContext.Provider>\n )\n\n return render(renderedUi(ui))\n}\n\nexport default renderWithDragDropFileProvider\n"],"names":["getContainerFromInput","input","parentNode","expand","datePickerContainer","queries","queryByRole","fireEvent","click","waitFor","expect","getByRole","toBeInTheDocument","collapse","getByText","not","pick","day","act","focus","dayElement","getByLabelText","getAttribute","clear","clearButton","getSelectedDates","selectedDays","queryAllByRole","checked","datePickerEvent","getContainer","DatePickerEvent","range","dateRangePickerContainer","rangeStart","rangeEnd","dateRangeStartInput","getByTestId","dateRangeEndInput","dateRangePickerEvent","getDropZoneFromInput","dragOver","dropzone","dragOverEvent","createEvent","dragLeave","dragLeaveEvent","dropFiles","files","fileDropEvent","drop","defineProperty","value","toArray","DragDropFileEvent","getSelectContainer","getSelectMenu","nextSibling","getSelectTriggerHandle","getSelectSearchContainer","isSelectMenuExpanded","selectContainer","children","length","waitForPendingQuery","searchContainer","within","queryByTestId","waitForElementToBeRemoved","timeout","triggerHandle","toBeEnabled","dispatchEvent","MouseEvent","bubbles","select","option","menuContainer","optionElement","findByLabelText","mouseDown","mouseUp","unselect","search","query","change","target","findAllByRole","getOptions","options","getSelectedOptions","selectedOptions","selected","selectEvent","isMenuExpanded","getInterpolatedStyles","styles","map","interpolation","isFunction","theme","Alice","join","defaultContextValueMock","fileList","onFilesAdded","jest","fn","onRetryUpload","onRemoveFile","renderWithDragDropFileProvider","ui","customContext","contextValue","renderedUi","React","DragDropFileContext","render"],"mappings":"2WAGA,SAASA,EAAsBC,EAAiC,CAEvDA,OAAAA,EAAMC,WAAYA,WAAYA,WAAYA,UACnD,CAOA,eAAeC,EAAOF,EAAmC,CACjDG,MAAAA,EAAsBJ,EAAsBC,CAAK,EAGnDI,UAAQC,YAAYF,EAAqB,MAAM,IAInDG,EAAAA,UAAUC,MAAMP,CAAK,EAErB,MAAMQ,UAAQ,IAAM,CAClBC,OAAOL,UAAQM,UAAUP,EAAqB,MAAM,CAAC,EAAEQ,kBAAkB,CAAA,CAC1E,EACH,CAOA,eAAeC,EAASZ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GAAG,EACvBE,aAAcH,KAAKC,GAAG,CACxB,EAEMG,EAAiCA,CACrCC,EACAC,IACiB,CACjB,MAAMC,EAAe,CAAE,GAAGV,EAAyB,GAAGS,CAAc,EAE9DE,EAAcpD,GAClBqD,EAAAA,QAAA,cAACC,sBAAoB,SAApB,CAA6B,MAAOH,CAAAA,EAAenD,CAAS,EAGxDuD,OAAAA,EAAAA,OAAOH,EAAWH,CAAE,CAAC,CAC9B"}
|
package/dist/testing/index.mjs
CHANGED
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
import { queries as
|
|
2
|
-
import { t as E } from "../toArray-
|
|
3
|
-
import {
|
|
1
|
+
import { queries as r, fireEvent as o, act as w, waitFor as l, createEvent as m, within as c, waitForElementToBeRemoved as S, render as T } from "@testing-library/react";
|
|
2
|
+
import { t as E } from "../toArray-DqgeO2ua.mjs";
|
|
3
|
+
import { isFunction as I } from "@loadsmart/utils-function";
|
|
4
|
+
import { a as P } from "../miranda-compatibility.theme-DQDHkWzC.mjs";
|
|
4
5
|
import F from "react";
|
|
5
6
|
import { D as N } from "../DragDropFile.context-jVTIKfj5.mjs";
|
|
6
7
|
function s(e) {
|
|
7
8
|
return e.parentNode.parentNode.parentNode.parentNode;
|
|
8
9
|
}
|
|
9
|
-
async function
|
|
10
|
+
async function k(e) {
|
|
10
11
|
const t = s(e);
|
|
11
|
-
|
|
12
|
-
expect(
|
|
12
|
+
r.queryByRole(t, "menu") || (o.click(e), await l(() => {
|
|
13
|
+
expect(r.getByRole(t, "menu")).toBeInTheDocument();
|
|
13
14
|
}));
|
|
14
15
|
}
|
|
15
16
|
async function y(e) {
|
|
16
17
|
const t = s(e);
|
|
17
|
-
|
|
18
|
-
expect(
|
|
18
|
+
r.queryByRole(t, "menu") && (o.click(r.getByText(t, "Close")), await l(() => {
|
|
19
|
+
expect(r.queryByRole(t, "menu")).not.toBeInTheDocument();
|
|
19
20
|
}));
|
|
20
21
|
}
|
|
21
22
|
async function q(e, t) {
|
|
22
23
|
const n = s(t);
|
|
23
|
-
await
|
|
24
|
+
await k(t), w(() => {
|
|
24
25
|
t.focus();
|
|
25
26
|
});
|
|
26
|
-
const a =
|
|
27
|
+
const a = r.getByLabelText(n, e);
|
|
27
28
|
a && a.getAttribute("aria-checked") == "false" && o.click(a), await y(t);
|
|
28
29
|
}
|
|
29
30
|
async function A(e) {
|
|
30
|
-
const t = s(e), n =
|
|
31
|
+
const t = s(e), n = r.getByLabelText(t, "Clear selection");
|
|
31
32
|
o.click(n), await y(e);
|
|
32
33
|
}
|
|
33
34
|
async function L(e) {
|
|
34
35
|
const t = s(e);
|
|
35
|
-
await
|
|
36
|
-
const n =
|
|
36
|
+
await k(e);
|
|
37
|
+
const n = r.queryAllByRole(t, "checkbox", {
|
|
37
38
|
checked: !0
|
|
38
39
|
});
|
|
39
40
|
return await y(e), n;
|
|
40
41
|
}
|
|
41
42
|
const i = {
|
|
42
43
|
getContainer: s,
|
|
43
|
-
expand:
|
|
44
|
+
expand: k,
|
|
44
45
|
collapse: y,
|
|
45
46
|
pick: q,
|
|
46
47
|
clear: A,
|
|
@@ -57,11 +58,11 @@ async function $(e, t) {
|
|
|
57
58
|
await D(t);
|
|
58
59
|
const [a, f] = e;
|
|
59
60
|
if (a != null) {
|
|
60
|
-
const p =
|
|
61
|
+
const p = r.getByTestId(n, "input-date-range-start");
|
|
61
62
|
await i.pick(a, p);
|
|
62
63
|
}
|
|
63
64
|
if (f != null) {
|
|
64
|
-
const p =
|
|
65
|
+
const p = r.getByTestId(n, "input-date-range-end");
|
|
65
66
|
await i.pick(f, p);
|
|
66
67
|
}
|
|
67
68
|
await h(t);
|
|
@@ -72,27 +73,27 @@ async function O(e) {
|
|
|
72
73
|
async function j(e) {
|
|
73
74
|
return i.getSelectedDates(e);
|
|
74
75
|
}
|
|
75
|
-
const
|
|
76
|
+
const ne = {
|
|
76
77
|
getContainer: i.getContainer,
|
|
77
78
|
expand: D,
|
|
78
79
|
collapse: h,
|
|
79
80
|
pick: $,
|
|
80
81
|
clear: O,
|
|
81
82
|
getSelectedDates: j
|
|
82
|
-
},
|
|
83
|
-
const t =
|
|
83
|
+
}, x = (e) => e.parentNode, M = (e) => {
|
|
84
|
+
const t = x(e), n = m.dragOver(t);
|
|
84
85
|
o(t, n);
|
|
85
86
|
}, U = (e) => {
|
|
86
|
-
const t =
|
|
87
|
+
const t = x(e), n = m.dragLeave(t);
|
|
87
88
|
o(t, n);
|
|
88
89
|
}, z = (e, t) => {
|
|
89
|
-
const n =
|
|
90
|
+
const n = x(e), a = m.drop(n);
|
|
90
91
|
Object.defineProperty(a, "dataTransfer", {
|
|
91
92
|
value: {
|
|
92
93
|
files: E(t)
|
|
93
94
|
}
|
|
94
95
|
}), o(n, a);
|
|
95
|
-
},
|
|
96
|
+
}, ae = {
|
|
96
97
|
dragOver: M,
|
|
97
98
|
dragLeave: U,
|
|
98
99
|
dropFiles: z
|
|
@@ -103,25 +104,25 @@ function B(e) {
|
|
|
103
104
|
function d(e) {
|
|
104
105
|
return e.parentNode.parentNode.nextSibling;
|
|
105
106
|
}
|
|
106
|
-
function
|
|
107
|
+
function R(e) {
|
|
107
108
|
return e.parentNode.nextSibling.nextSibling;
|
|
108
109
|
}
|
|
109
|
-
function
|
|
110
|
+
function b(e) {
|
|
110
111
|
return e.parentNode;
|
|
111
112
|
}
|
|
112
113
|
function v(e) {
|
|
113
114
|
return B(e).children.length === 3;
|
|
114
115
|
}
|
|
115
116
|
async function C(e) {
|
|
116
|
-
const t =
|
|
117
|
-
|
|
117
|
+
const t = b(e);
|
|
118
|
+
c(t).queryByTestId("select-trigger-loading") && await S(() => c(t).queryByTestId("select-trigger-loading"), {
|
|
118
119
|
timeout: 2500
|
|
119
120
|
});
|
|
120
121
|
}
|
|
121
122
|
async function u(e) {
|
|
122
123
|
if (await C(e), v(e))
|
|
123
124
|
return;
|
|
124
|
-
const t =
|
|
125
|
+
const t = R(e);
|
|
125
126
|
await l(() => {
|
|
126
127
|
expect(t).toBeEnabled();
|
|
127
128
|
}), w(() => {
|
|
@@ -129,32 +130,32 @@ async function u(e) {
|
|
|
129
130
|
bubbles: !0
|
|
130
131
|
}));
|
|
131
132
|
}), await l(() => {
|
|
132
|
-
expect(
|
|
133
|
+
expect(c(B(e)).getByRole("listbox")).toBeInTheDocument();
|
|
133
134
|
});
|
|
134
135
|
}
|
|
135
136
|
async function g(e) {
|
|
136
137
|
if (!v(e))
|
|
137
138
|
return;
|
|
138
|
-
const t =
|
|
139
|
+
const t = R(e);
|
|
139
140
|
o.click(t), await l(() => {
|
|
140
|
-
expect(
|
|
141
|
+
expect(c(B(e)).queryByRole("listbox")).not.toBeInTheDocument();
|
|
141
142
|
});
|
|
142
143
|
}
|
|
143
144
|
async function H(e, t) {
|
|
144
145
|
await u(t);
|
|
145
|
-
const n = d(t), a = await
|
|
146
|
+
const n = d(t), a = await c(n).findByLabelText(e);
|
|
146
147
|
a && a.getAttribute("aria-selected") == "false" && (o.mouseDown(a), w(() => {
|
|
147
148
|
a.focus();
|
|
148
149
|
}), o.mouseUp(a), o.click(a)), await g(t);
|
|
149
150
|
}
|
|
150
151
|
async function V(e, t) {
|
|
151
152
|
await u(t);
|
|
152
|
-
const n = d(t), a = await
|
|
153
|
+
const n = d(t), a = await c(n).findByLabelText(e);
|
|
153
154
|
a && a.getAttribute("aria-selected") === "true" && o.click(a), await g(t);
|
|
154
155
|
}
|
|
155
156
|
async function _(e) {
|
|
156
157
|
await C(e);
|
|
157
|
-
const t =
|
|
158
|
+
const t = b(e), n = c(t).getByTestId("select-trigger-clear");
|
|
158
159
|
n && o.click(n);
|
|
159
160
|
}
|
|
160
161
|
async function Q(e, t) {
|
|
@@ -164,11 +165,11 @@ async function Q(e, t) {
|
|
|
164
165
|
}
|
|
165
166
|
}), await C(t);
|
|
166
167
|
const n = d(t);
|
|
167
|
-
await
|
|
168
|
+
await c(n).findAllByRole("option");
|
|
168
169
|
}
|
|
169
170
|
async function W(e) {
|
|
170
171
|
await u(e);
|
|
171
|
-
const t = d(e), n =
|
|
172
|
+
const t = d(e), n = c(t).queryAllByRole("option");
|
|
172
173
|
return await g(e), n;
|
|
173
174
|
}
|
|
174
175
|
async function Z(e) {
|
|
@@ -176,7 +177,7 @@ async function Z(e) {
|
|
|
176
177
|
const t = d(e);
|
|
177
178
|
let n = [];
|
|
178
179
|
try {
|
|
179
|
-
n = await
|
|
180
|
+
n = await c(t).findAllByRole("option", {
|
|
180
181
|
selected: !0
|
|
181
182
|
});
|
|
182
183
|
} catch {
|
|
@@ -184,7 +185,7 @@ async function Z(e) {
|
|
|
184
185
|
}
|
|
185
186
|
return await g(e), n;
|
|
186
187
|
}
|
|
187
|
-
const
|
|
188
|
+
const oe = {
|
|
188
189
|
select: H,
|
|
189
190
|
unselect: V,
|
|
190
191
|
clear: _,
|
|
@@ -195,9 +196,9 @@ const ae = {
|
|
|
195
196
|
getSelectedOptions: Z,
|
|
196
197
|
isMenuExpanded: v
|
|
197
198
|
};
|
|
198
|
-
function
|
|
199
|
+
function re(e) {
|
|
199
200
|
return E(e).map((t) => {
|
|
200
|
-
for (; I
|
|
201
|
+
for (; I(t); )
|
|
201
202
|
t = t({
|
|
202
203
|
theme: P
|
|
203
204
|
});
|
|
@@ -218,10 +219,10 @@ const G = {
|
|
|
218
219
|
};
|
|
219
220
|
export {
|
|
220
221
|
i as DatePickerEvent,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
222
|
+
ne as DateRangePickerEvent,
|
|
223
|
+
ae as DragDropFileEvent,
|
|
224
|
+
oe as SelectEvent,
|
|
225
|
+
re as getInterpolatedStyles,
|
|
225
226
|
ce as renderWithDragDropFileProvider
|
|
226
227
|
};
|
|
227
228
|
//# sourceMappingURL=index.mjs.map
|