@loadsmart/loadsmart-ui 6.4.0 → 7.0.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/components/Table/Table.d.ts +4 -12
- package/dist/components/Table/Table.types.d.ts +0 -4
- package/dist/index.js +71 -96
- package/dist/index.js.map +1 -1
- package/dist/{miranda-compatibility.theme-22a9ce26.js → miranda-compatibility.theme-bb671a80.js} +2 -2
- package/dist/{miranda-compatibility.theme-22a9ce26.js.map → miranda-compatibility.theme-bb671a80.js.map} +1 -1
- package/dist/prop-e569d46a.js +2 -0
- package/dist/{prop-201ffe28.js.map → prop-e569d46a.js.map} +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/theming/index.js +1 -1
- package/dist/tools/index.js +1 -1
- package/package.json +1 -1
- package/src/components/Table/Table.stories.tsx +27 -27
- package/src/components/Table/Table.test.tsx +10 -10
- package/src/components/Table/Table.tsx +35 -90
- package/src/components/Table/Table.types.ts +0 -5
- package/src/testing/DatePickerEvent/DatePickerEvent.ts +15 -18
- package/src/testing/SelectEvent/SelectEvent.ts +2 -2
- package/src/theming/themes/miranda-compatibility.theme.ts +1 -1
- package/dist/prop-201ffe28.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var t=require("./toArray-b56541b4.js"),n=require("./miranda-compatibility.theme-bb671a80.js"),r=require("./theming/index.js");function e(t,e){return Object.keys(t||{}).reduce(((o,i)=>{var u;let s=t[i];if(n.isFunction(s)&&(s=s(e)),s){const t=i,n=null!==(u=r.getToken(t,e))&&void 0!==u?u:i;return[...o,n]}return o}),[]).join(" ")}function o(...t){const[n,r]=t;return null==n||!1===n||Number.isNaN(n)?r||n:"string"==typeof n&&0===n.length&&r||n}exports.conditional=function(...r){return function(o){let i=[];for(let u=0;u<r.length;u++){const s=r[u];n.isFunction(s)?i.push(s(o)):t.isObject(s)?i=i.concat(e(s,o)):s&&i.push(String(s))}return i.join(" ")}},exports.prop=function(t,n,r=o){return e=>r(e[t],n)},exports.whenProps=function(r){return function(e){const o=t.toArray(r);let i=!1;for(let r=0;r<o.length;r++){const u=o[r],s=Object.keys(u);let c=!0;for(let r=0;r<s.length&&c;r++){const o=s[r],i=n.lodash_get(e,o),l=u[o];c=Array.isArray(l)?c&&t.toArray(l).includes(i):n.isFunction(l)?c&&Boolean(l(i)):c&&l===i}i=i||c}return i}};
|
|
2
|
+
//# sourceMappingURL=prop-e569d46a.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop-
|
|
1
|
+
{"version":3,"file":"prop-e569d46a.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":["handleConditionObject","condition","props","Object","keys","reduce","acc","key","value","isFunction","tokenKey","result","_a","getToken","join","compare","args","defaultValue","Number","isNaN","length","conditions","classes","i","push","isObject","concat","String","name","comparatorFn","safeConditions","toArray","res","temp","j","propValue","get","conditionValue","Array","isArray","includes","Boolean"],"mappings":"2IAoEA,SAASA,EAAyBC,EAA+BC,GAmB/D,OAlBaC,OAAOC,KAAKH,GAAa,CAAE,GAEvBI,QAAO,CAACC,EAAKC,WAC5B,IAAIC,EAAQP,EAAUM,GAMtB,GAJIE,EAAAA,WAAWD,KACbA,EAAQA,EAAMN,IAGZM,EAAO,CACT,MAAME,EAAWH,EACXI,EAAiE,QAAvDC,EAAAC,EAAQA,SAACH,EAAUR,UAAoC,IAAAU,EAAAA,EAAAL,EACvE,MAAO,IAAID,EAAKK,EACjB,CAED,OAAOL,CAAG,GACT,IAEQQ,KAAK,IAClB,CCxFA,SAASC,KAAWC,GAElB,MAAOR,EAAOS,GAAgBD,EAE9B,OAAa,MAATR,IAA2B,IAAVA,GAAmBU,OAAOC,MAAMX,GAC5CS,GAAgBT,EAGJ,iBAAVA,GAAuC,IAAjBA,EAAMY,QAC9BH,GAGFT,CACT,qBD6FA,YAA2Ba,GACzB,OAAO,SAAUnB,GACf,IAAIoB,EAAoB,GAExB,IAAK,IAAIC,EAAI,EAAGA,EAAIF,EAAWD,OAAQG,IAAK,CAC1C,MAAMtB,EAAYoB,EAAWE,GAEzBd,EAAAA,WAAWR,GACbqB,EAAQE,KAAKvB,EAAUC,IACduB,EAAAA,SAASxB,GAClBqB,EAAUA,EAAQI,OAAO1B,EAAyBC,EAAWC,IACpDD,GACTqB,EAAQE,KAAKG,OAAO1B,GAEvB,CAED,OAAOqB,EAAQR,KAAK,IACtB,CACF,eCjGA,SACEc,EACAX,EACAY,EAAed,GAEf,OAAQb,GAAmB2B,EAAa3B,EAAM0B,GAAOX,EACvD,oBDHM,SAAuBI,GAC3B,OAAO,SAAUnB,GACf,MAAM4B,EAAiBC,UAAQV,GAE/B,IAAIW,GAAM,EAEV,IAAK,IAAIT,EAAI,EAAGA,EAAIO,EAAeV,OAAQG,IAAK,CAC9C,MAAMtB,EAAY6B,EAAeP,GAC3BnB,EAAOD,OAAOC,KAAKH,GAEzB,IAAIgC,GAAO,EAEX,IAAK,IAAIC,EAAI,EAAGA,EAAI9B,EAAKgB,QAAUa,EAAMC,IAAK,CAC5C,MAAM3B,EAAMH,EAAK8B,GACXC,EAAYC,EAAAA,WAAIlC,EAAOK,GACvB8B,EAAiBpC,EAAUM,GAG/B0B,EADEK,MAAMC,QAAQF,GACTJ,GAAQF,EAAOA,QAACM,GAAgBG,SAASL,GACvC1B,EAAAA,WAAW4B,GACbJ,GAAQQ,QAAQJ,EAAeF,IAE/BF,GAASI,IAA+BF,CAElD,CAEDH,EAAMA,GAAOC,CACd,CAED,OAAOD,CACT,CACF"}
|
package/dist/testing/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../DragDropFile.context-bbb7d631.js"),t=require("@testing-library/react"),i=require("../toArray-b56541b4.js"),n=require("../miranda-compatibility.theme-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../DragDropFile.context-bbb7d631.js"),t=require("@testing-library/react"),i=require("../toArray-b56541b4.js"),n=require("../miranda-compatibility.theme-bb671a80.js"),r=require("react");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@loadsmart/miranda-tokens");var c=o(r);function a(e){return e.parentNode.parentNode.parentNode.parentNode}function d(i){return e.__awaiter(this,void 0,void 0,(function*(){const e=a(i);t.queries.queryByRole(e,"menu")||(t.fireEvent.click(i),yield t.waitFor((()=>{expect(t.queries.getByRole(e,"menu")).toBeInTheDocument()})))}))}function u(i){return e.__awaiter(this,void 0,void 0,(function*(){const e=a(i);t.queries.queryByRole(e,"menu")&&(t.fireEvent.click(t.queries.getByText(e,"Close")),yield t.waitFor((()=>{expect(t.queries.queryByRole(e,"menu")).not.toBeInTheDocument()})))}))}const l={getContainer:a,expand:d,collapse:u,pick:function(i,n){return e.__awaiter(this,void 0,void 0,(function*(){const e=a(n);yield d(n),t.act((()=>{n.focus()}));const r=t.queries.getByLabelText(e,i);r&&"false"==r.getAttribute("aria-checked")&&t.fireEvent.click(r),yield u(n)}))},clear:function(i){return e.__awaiter(this,void 0,void 0,(function*(){const e=a(i),n=t.queries.getByLabelText(e,"Clear selection");t.fireEvent.click(n),yield u(i)}))},getSelectedDates:function(i){return e.__awaiter(this,void 0,void 0,(function*(){const e=a(i);yield d(i);const n=t.queries.queryAllByRole(e,"checkbox",{checked:!0});return yield u(i),n}))}};function s(t){return e.__awaiter(this,void 0,void 0,(function*(){yield l.expand(t)}))}function f(t){return e.__awaiter(this,void 0,void 0,(function*(){yield l.collapse(t)}))}const v={getContainer:l.getContainer,expand:s,collapse:f,pick:function(i,n){return e.__awaiter(this,void 0,void 0,(function*(){const e=l.getContainer(n);yield s(n);const[r,o]=i;if(null!=r){const i=t.queries.getByTestId(e,"input-date-range-start");yield l.pick(r,i)}if(null!=o){const i=t.queries.getByTestId(e,"input-date-range-end");yield l.pick(o,i)}yield f(n)}))},clear:function(t){return e.__awaiter(this,void 0,void 0,(function*(){yield l.clear(t)}))},getSelectedDates:function(t){return e.__awaiter(this,void 0,void 0,(function*(){return l.getSelectedDates(t)}))}},y=e=>e.parentNode,p={dragOver:e=>{const i=y(e),n=t.createEvent.dragOver(i);t.fireEvent(i,n)},dragLeave:e=>{const i=y(e),n=t.createEvent.dragLeave(i);t.fireEvent(i,n)},dropFiles:(e,n)=>{const r=y(e),o=t.createEvent.drop(r);Object.defineProperty(o,"dataTransfer",{value:{files:i.toArray(n)}}),t.fireEvent(r,o)}};function g(e){return e.parentNode.parentNode.parentNode}function h(e){return e.parentNode.parentNode.nextSibling}function _(e){return e.parentNode.nextSibling.nextSibling}function w(e){return e.parentNode}function b(e){return 3===g(e).children.length}function x(i){return e.__awaiter(this,void 0,void 0,(function*(){const e=w(i);t.within(e).queryByTestId("select-trigger-loading")&&(yield t.waitForElementToBeRemoved((()=>t.within(e).queryByTestId("select-trigger-loading")),{timeout:2500}))}))}function E(i){return e.__awaiter(this,void 0,void 0,(function*(){if(yield x(i),b(i))return;const e=_(i);yield t.waitFor((()=>{expect(e).toBeEnabled()})),t.act((()=>{i.dispatchEvent(new MouseEvent("click",{bubbles:!0}))})),yield t.waitFor((()=>{expect(t.within(g(i)).getByRole("listbox")).toBeInTheDocument()}))}))}function B(i){return e.__awaiter(this,void 0,void 0,(function*(){if(!b(i))return;const e=_(i);t.fireEvent.click(e),yield t.waitFor((()=>{expect(t.within(g(i)).queryByRole("listbox")).not.toBeInTheDocument()}))}))}const q={select:function(i,n){return e.__awaiter(this,void 0,void 0,(function*(){yield E(n);const e=h(n),r=yield t.within(e).findByLabelText(i);r&&"false"==r.getAttribute("aria-selected")&&(t.fireEvent.mouseDown(r),t.act((()=>{r.focus()})),t.fireEvent.mouseUp(r),t.fireEvent.click(r)),yield B(n)}))},unselect:function(i,n){return e.__awaiter(this,void 0,void 0,(function*(){yield E(n);const e=h(n),r=yield t.within(e).findByLabelText(i);r&&"true"===r.getAttribute("aria-selected")&&t.fireEvent.click(r),yield B(n)}))},clear:function(i){return e.__awaiter(this,void 0,void 0,(function*(){yield x(i);const e=w(i),n=t.within(e).getByTestId("select-trigger-clear");n&&t.fireEvent.click(n)}))},search:function(i,n){return e.__awaiter(this,void 0,void 0,(function*(){t.fireEvent.change(n,{target:{value:i}}),yield x(n);const e=h(n);yield t.within(e).findAllByRole("option")}))},expand:E,collapse:B,getOptions:function(i){return e.__awaiter(this,void 0,void 0,(function*(){yield E(i);const e=h(i),n=t.within(e).queryAllByRole("option");return yield B(i),n}))},getSelectedOptions:function(i){return e.__awaiter(this,void 0,void 0,(function*(){yield E(i);const e=h(i);let n=[];try{n=yield t.within(e).findAllByRole("option",{selected:!0})}catch(e){n=[]}return yield B(i),n}))},isMenuExpanded:b};const m={fileList:[],onFilesAdded:jest.fn(),onRetryUpload:jest.fn(),onRemoveFile:jest.fn()};exports.DatePickerEvent=l,exports.DateRangePickerEvent=v,exports.DragDropFileEvent=p,exports.SelectEvent=q,exports.getInterpolatedStyles=function(e){return i.toArray(e).map((e=>{for(;n.isFunction(e);)e=e({theme:n.alice});return e})).join("")},exports.renderWithDragDropFileProvider=(i,n)=>{const r=Object.assign(Object.assign({},m),n);return t.render((o=i,c.default.createElement(e.DragDropFileContext.Provider,{value:r},o)));var o};
|
|
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/renderWithDragDropFileProvider/renderWithDragDropFileProvider.tsx","../../src/testing/getInterpolatedStyles/getInterpolatedStyles.ts"],"sourcesContent":["/* eslint-disable */\nimport { act, queries, fireEvent, waitForElementToBeRemoved } from '@testing-library/react'\n\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 await act(async () => {\n fireEvent.click(input)\n\n expect(await queries.findByRole(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 await act(async () => {\n fireEvent.click(queries.getByText(datePickerContainer, 'Close'))\n\n await waitForElementToBeRemoved(() => queries.queryByRole(datePickerContainer, 'menu'))\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 await act(async () => {\n input.focus()\n\n const dayElement = queries.getByLabelText(datePickerContainer, day)\n\n if (dayElement && dayElement.getAttribute('aria-checked') == 'false') {\n fireEvent.click(dayElement)\n }\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 await act(async () => {\n const clearButton = queries.getByLabelText(datePickerContainer, 'Clear selection')\n\n fireEvent.click(clearButton)\n })\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(async () => {\n expect(await within(getSelectContainer(input)).findByRole('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 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","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"],"names":["getContainerFromInput","input","parentNode","expand","datePickerContainer","queries","queryByRole","act","__awaiter","this","fireEvent","click","expect","findByRole","toBeInTheDocument","collapse","getByText","waitForElementToBeRemoved","datePickerEvent","getContainer","day","focus","dayElement","getByLabelText","getAttribute","clearButton","selectedDays","queryAllByRole","checked","DatePickerEvent","dateRangePickerEvent","pick","range","dateRangePickerContainer","rangeStart","rangeEnd","dateRangeStartInput","getByTestId","dateRangeEndInput","clear","getSelectedDates","getDropZoneFromInput","DragDropFileEvent","dragOver","dropzone","dragOverEvent","createEvent","dragLeave","dragLeaveEvent","dropFiles","files","fileDropEvent","drop","Object","defineProperty","value","toArray","getSelectContainer","getSelectMenu","nextSibling","getSelectTriggerHandle","getSelectSearchContainer","isSelectMenuExpanded","children","length","waitForPendingQuery","searchContainer","within","queryByTestId","timeout","triggerHandle","waitFor","toBeEnabled","dispatchEvent","MouseEvent","bubbles","not","selectEvent","select","option","menuContainer","optionElement","findByLabelText","mouseDown","mouseUp","unselect","search","query","change","target","findAllByRole","getOptions","options","getSelectedOptions","selectedOptions","selected","err","isMenuExpanded","defaultContextValueMock","fileList","onFilesAdded","jest","fn","onRetryUpload","onRemoveFile","styles","map","interpolation","isFunction","theme","Alice","join","ui","customContext","contextValue","assign","render","React","createElement","DragDropFileContext","Provider"],"mappings":"oYAIA,SAASA,EAAsBC,GAE7B,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D,GACZC,KAAKC,IACJ,KAAOC,EAAAA,WAAWD,IAChBA,EAAgBA,EAAc,CAAEE,MAAOC,EAAAA,QAGzC,OAAOH,CAAa,IAErBI,KAAK,GACV,yCDVuC,CACrCC,EACAC,KAEA,MAAMC,EAAoB7D,OAAA8D,OAAA9D,OAAA8D,OAAA,GAAAjB,GAA4Be,GAMtD,OAAOG,UAJarD,EAIKiD,EAHvBK,EAAAA,QAACC,cAAAC,EAAAA,oBAAoBC,SAAQ,CAACjE,MAAO2D,GAAenD,KADnC,IAACA,CAIS"}
|
|
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/renderWithDragDropFileProvider/renderWithDragDropFileProvider.tsx","../../src/testing/getInterpolatedStyles/getInterpolatedStyles.ts"],"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 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","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"],"names":["getContainerFromInput","input","parentNode","expand","datePickerContainer","queries","queryByRole","fireEvent","click","waitFor","expect","getByRole","toBeInTheDocument","collapse","getByText","not","datePickerEvent","getContainer","day","act","focus","dayElement","getByLabelText","getAttribute","clearButton","selectedDays","queryAllByRole","checked","DatePickerEvent","dateRangePickerEvent","pick","range","dateRangePickerContainer","rangeStart","rangeEnd","dateRangeStartInput","getByTestId","dateRangeEndInput","clear","getSelectedDates","getDropZoneFromInput","DragDropFileEvent","dragOver","dropzone","dragOverEvent","createEvent","dragLeave","dragLeaveEvent","dropFiles","files","fileDropEvent","drop","Object","defineProperty","value","toArray","getSelectContainer","getSelectMenu","nextSibling","getSelectTriggerHandle","getSelectSearchContainer","isSelectMenuExpanded","children","length","waitForPendingQuery","searchContainer","within","queryByTestId","waitForElementToBeRemoved","timeout","triggerHandle","toBeEnabled","dispatchEvent","MouseEvent","bubbles","selectEvent","select","option","menuContainer","optionElement","findByLabelText","mouseDown","mouseUp","unselect","search","query","change","target","findAllByRole","getOptions","options","getSelectedOptions","selectedOptions","selected","err","isMenuExpanded","defaultContextValueMock","fileList","onFilesAdded","jest","fn","onRetryUpload","onRemoveFile","styles","map","interpolation","isFunction","theme","Alice","join","ui","customContext","contextValue","assign","render","React","createElement","DragDropFileContext","Provider"],"mappings":"oYAGA,SAASA,EAAsBC,GAE7B,OAAOA,EAAMC,WAAYA,WAAYA,WAAYA,UACnD,CAOA,SAAeC,EAAOF,sDACpB,MAAMG,EAAsBJ,EAAsBC,GAG9CI,UAAQC,YAAYF,EAAqB,UAI7CG,YAAUC,MAAMP,SAEVQ,EAAOA,SAAC,KACZC,OAAOL,EAAOA,QAACM,UAAUP,EAAqB,SAASQ,mBAAmB,OAE7E,CAOD,SAAeC,EAASZ,sDACtB,MAAMG,EAAsBJ,EAAsBC,GAG7CI,EAAAA,QAAQC,YAAYF,EAAqB,UAI9CG,EAASA,UAACC,MAAMH,EAAOA,QAACS,UAAUV,EAAqB,gBAEjDK,EAAOA,SAAC,KACZC,OAAOL,EAAAA,QAAQC,YAAYF,EAAqB,SAASW,IAAIH,mBAAmB,OAEnF,CA6DD,MAAMI,EAAkB,CACtBC,a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EAgDCrF,SACAU,WACA4E,WA3CF,SAA0BxF,4DAClBE,EAAOF,GAEb,MAAM6E,EAAgBrB,EAAcxD,GAE9ByF,EAAUxB,EAAAA,OAAOY,GAAepD,eAAe,UAIrD,aAFMb,EAASZ,GAERyF,IACR,EAkCCC,mBA3BF,SAAkC1F,4DAC1BE,EAAOF,GAEb,MAAM6E,EAAgBrB,EAAcxD,GACpC,IAAI2F,EAAiC,GAErC,IACEA,QAAwB1B,EAAMA,OAACY,GAAeU,cAAc,SAAU,CACpEK,UAAU,GAEb,CAAC,MAAOC,GACPF,EAAkB,EACnB,CAID,aAFM/E,EAASZ,GAER2F,IACR,EAWCG,eAAgBlC,GC7PlB,MAAMmC,EAAoD,CACxDC,SAAU,GACVC,aAAcC,KAAKC,KACnBC,cAAeF,KAAKC,KACpBE,aAAcH,KAAKC,+ICGG,SAAsBG,GAC5C,OAAOhD,EAAAA,QAAQgD,GACZC,KAAKC,IACJ,KAAOC,EAAAA,WAAWD,IAChBA,EAAgBA,EAAc,CAAEE,MAAOC,EAAAA,QAGzC,OAAOH,CAAa,IAErBI,KAAK,GACV,yCDVuC,CACrCC,EACAC,KAEA,MAAMC,EAAoB5D,OAAA6D,OAAA7D,OAAA6D,OAAA,GAAAjB,GAA4Be,GAMtD,OAAOG,UAJapD,EAIKgD,EAHvBK,EAAAA,QAACC,cAAAC,EAAAA,oBAAoBC,SAAQ,CAAChE,MAAO0D,GAAelD,KADnC,IAACA,CAIS"}
|
package/dist/theming/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../miranda-compatibility.theme-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../miranda-compatibility.theme-bb671a80.js");require("@loadsmart/miranda-tokens");var t=Object.freeze({__proto__:null,Alice:e.alice,Loadsmart:e.loadsmart,Miranda:e.mirandaCompatibility});function r(t,r){const a=e.isFunction(t)?t(r):t;return r.theme[a]}exports.Themes=t,exports.getToken=function(e,t){return void 0===t?t=>r(e,t):r(e,t)};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/tools/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../prop-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../prop-e569d46a.js");require("../toArray-b56541b4.js"),require("../miranda-compatibility.theme-bb671a80.js"),require("@loadsmart/miranda-tokens"),require("../theming/index.js"),exports.conditional=e.conditional,exports.prop=e.prop,exports.whenProps=e.whenProps;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -518,45 +518,45 @@ export function WithExpandableRow(args: TableProps): JSX.Element {
|
|
|
518
518
|
|
|
519
519
|
return (
|
|
520
520
|
<div className="p-4 bg-neutral-white">
|
|
521
|
-
<Table
|
|
522
|
-
<Table.
|
|
521
|
+
<Table {...args}>
|
|
522
|
+
<Table.Head>
|
|
523
523
|
<Table.Row>
|
|
524
|
-
<Table.
|
|
525
|
-
<Table.
|
|
526
|
-
<Table.
|
|
527
|
-
<Table.
|
|
524
|
+
<Table.HeadCell />
|
|
525
|
+
<Table.HeadCell>reference</Table.HeadCell>
|
|
526
|
+
<Table.HeadCell>product</Table.HeadCell>
|
|
527
|
+
<Table.HeadCell>price</Table.HeadCell>
|
|
528
528
|
</Table.Row>
|
|
529
|
-
</Table.
|
|
529
|
+
</Table.Head>
|
|
530
530
|
|
|
531
531
|
<Table.Body>
|
|
532
|
-
<Table.
|
|
532
|
+
<Table.ExpandableRow
|
|
533
533
|
leading={leading}
|
|
534
534
|
expandableContent={<div>Forced expanded with custom leading</div>}
|
|
535
535
|
expanded
|
|
536
536
|
>
|
|
537
|
-
<Table.
|
|
538
|
-
<Table.
|
|
539
|
-
<Table.
|
|
540
|
-
</Table.
|
|
541
|
-
<Table.
|
|
537
|
+
<Table.Cell>123456</Table.Cell>
|
|
538
|
+
<Table.Cell>Body 1</Table.Cell>
|
|
539
|
+
<Table.Cell>12345</Table.Cell>
|
|
540
|
+
</Table.ExpandableRow>
|
|
541
|
+
<Table.ExpandableRow
|
|
542
542
|
leading={leading}
|
|
543
543
|
expandableContent={<div>Initial expanded row with custom leading</div>}
|
|
544
544
|
initialExpanded
|
|
545
545
|
>
|
|
546
|
-
<Table.
|
|
547
|
-
<Table.
|
|
548
|
-
<Table.
|
|
549
|
-
</Table.
|
|
550
|
-
<Table.
|
|
551
|
-
<Table.
|
|
552
|
-
<Table.
|
|
553
|
-
<Table.
|
|
554
|
-
</Table.
|
|
555
|
-
<Table.
|
|
556
|
-
<Table.
|
|
557
|
-
<Table.
|
|
558
|
-
<Table.
|
|
559
|
-
</Table.
|
|
546
|
+
<Table.Cell>123456</Table.Cell>
|
|
547
|
+
<Table.Cell>Body 2</Table.Cell>
|
|
548
|
+
<Table.Cell>12345</Table.Cell>
|
|
549
|
+
</Table.ExpandableRow>
|
|
550
|
+
<Table.ExpandableRow expandableContent={<div>Expandable row</div>}>
|
|
551
|
+
<Table.Cell>123456</Table.Cell>
|
|
552
|
+
<Table.Cell>Body 3</Table.Cell>
|
|
553
|
+
<Table.Cell>12345</Table.Cell>
|
|
554
|
+
</Table.ExpandableRow>
|
|
555
|
+
<Table.ExpandableRow expanded>
|
|
556
|
+
<Table.Cell>123456</Table.Cell>
|
|
557
|
+
<Table.Cell>Body 5</Table.Cell>
|
|
558
|
+
<Table.Cell>12345</Table.Cell>
|
|
559
|
+
</Table.ExpandableRow>
|
|
560
560
|
</Table.Body>
|
|
561
561
|
</Table>
|
|
562
562
|
</div>
|
|
@@ -183,21 +183,21 @@ describe('<Table />', () => {
|
|
|
183
183
|
expect(checkboxes[1]).toBeChecked()
|
|
184
184
|
})
|
|
185
185
|
|
|
186
|
-
it('Table.
|
|
186
|
+
it('Table.ExpandableRow renders correclty', () => {
|
|
187
187
|
const onExpandedChange = jest.fn()
|
|
188
188
|
|
|
189
189
|
const expandableTable = ({ controlledExpanded4 }: { controlledExpanded4: boolean }) => (
|
|
190
190
|
<React.Fragment>
|
|
191
191
|
<Table.Head>
|
|
192
192
|
<Table.Row>
|
|
193
|
-
<Table.
|
|
193
|
+
<Table.HeadCell />
|
|
194
194
|
<Table.HeadCell># Number</Table.HeadCell>
|
|
195
195
|
<Table.HeadCell>Company</Table.HeadCell>
|
|
196
196
|
<Table.HeadCell alignment="right">Price $</Table.HeadCell>
|
|
197
197
|
</Table.Row>
|
|
198
198
|
</Table.Head>
|
|
199
199
|
<Table.Body>
|
|
200
|
-
<Table.
|
|
200
|
+
<Table.ExpandableRow
|
|
201
201
|
expandableContent={<div>This is an expandable content on index 0</div>}
|
|
202
202
|
expanded
|
|
203
203
|
>
|
|
@@ -206,15 +206,15 @@ describe('<Table />', () => {
|
|
|
206
206
|
<Table.Cell format="currency" alignment="right">
|
|
207
207
|
$9876,50
|
|
208
208
|
</Table.Cell>
|
|
209
|
-
</Table.
|
|
210
|
-
<Table.
|
|
209
|
+
</Table.ExpandableRow>
|
|
210
|
+
<Table.ExpandableRow>
|
|
211
211
|
<Table.Cell format="number">#000000-2</Table.Cell>
|
|
212
212
|
<Table.Cell>Modal X 21</Table.Cell>
|
|
213
213
|
<Table.Cell format="currency" alignment="right">
|
|
214
214
|
$9876,50
|
|
215
215
|
</Table.Cell>
|
|
216
|
-
</Table.
|
|
217
|
-
<Table.
|
|
216
|
+
</Table.ExpandableRow>
|
|
217
|
+
<Table.ExpandableRow
|
|
218
218
|
expandableContent={<div>This is an expandable content on index 2</div>}
|
|
219
219
|
leading={(expanded) => (expanded ? 'open' : 'closed')}
|
|
220
220
|
onExpandedChange={onExpandedChange}
|
|
@@ -224,8 +224,8 @@ describe('<Table />', () => {
|
|
|
224
224
|
<Table.Cell format="currency" alignment="right">
|
|
225
225
|
$9876,50
|
|
226
226
|
</Table.Cell>
|
|
227
|
-
</Table.
|
|
228
|
-
<Table.
|
|
227
|
+
</Table.ExpandableRow>
|
|
228
|
+
<Table.ExpandableRow
|
|
229
229
|
expandableContent={<div>This is an expandable content on index 3</div>}
|
|
230
230
|
expanded={controlledExpanded4}
|
|
231
231
|
>
|
|
@@ -234,7 +234,7 @@ describe('<Table />', () => {
|
|
|
234
234
|
<Table.Cell format="currency" alignment="right">
|
|
235
235
|
$9876,50
|
|
236
236
|
</Table.Cell>
|
|
237
|
-
</Table.
|
|
237
|
+
</Table.ExpandableRow>
|
|
238
238
|
</Table.Body>
|
|
239
239
|
</React.Fragment>
|
|
240
240
|
)
|
|
@@ -36,7 +36,6 @@ import type {
|
|
|
36
36
|
TablePickerItemProps,
|
|
37
37
|
TablePickerProps,
|
|
38
38
|
ExpandableTableRowProps,
|
|
39
|
-
TableHeadCellProps,
|
|
40
39
|
} from './Table.types'
|
|
41
40
|
|
|
42
41
|
const StyledTableBody = styled.tbody`
|
|
@@ -83,7 +82,6 @@ const StyledTableCell = styled.td<{ alignment?: string; format?: string }>`
|
|
|
83
82
|
const StyledTableHeadCell = styled.th<{
|
|
84
83
|
alignment?: string
|
|
85
84
|
clickable: boolean
|
|
86
|
-
capitalized?: boolean
|
|
87
85
|
}>`
|
|
88
86
|
${StyledCell}
|
|
89
87
|
|
|
@@ -91,10 +89,7 @@ const StyledTableHeadCell = styled.th<{
|
|
|
91
89
|
|
|
92
90
|
font-weight: ${token('font-weight-bold')};
|
|
93
91
|
|
|
94
|
-
text-transform:
|
|
95
|
-
uppercase: whenProps({ capitalized: false }),
|
|
96
|
-
capitalize: whenProps({ capitalized: true }),
|
|
97
|
-
})};
|
|
92
|
+
text-transform: capitalize;
|
|
98
93
|
|
|
99
94
|
cursor: ${conditional({
|
|
100
95
|
pointer: whenProps({ clickable: true }),
|
|
@@ -103,17 +98,6 @@ const StyledTableHeadCell = styled.th<{
|
|
|
103
98
|
`
|
|
104
99
|
|
|
105
100
|
const StyledTableHead = styled.thead`
|
|
106
|
-
box-shadow: 0 1px 0 ${token('color-neutral')};
|
|
107
|
-
|
|
108
|
-
${StyledTableCell} {
|
|
109
|
-
padding: ${token('space-s')};
|
|
110
|
-
|
|
111
|
-
font-weight: ${token('font-weight-bold')};
|
|
112
|
-
text-transform: uppercase;
|
|
113
|
-
}
|
|
114
|
-
`
|
|
115
|
-
|
|
116
|
-
const StyledExpandableTableHead = styled.thead`
|
|
117
101
|
border: 1px solid ${token('color-neutral-lighter')};
|
|
118
102
|
|
|
119
103
|
${StyledTableCell} {
|
|
@@ -124,43 +108,24 @@ const StyledExpandableTableHead = styled.thead`
|
|
|
124
108
|
}
|
|
125
109
|
`
|
|
126
110
|
|
|
127
|
-
const
|
|
111
|
+
const StyledTableRow = styled.tr<{ selected: boolean; isExpanded: boolean }>`
|
|
128
112
|
${StyledTableHead} > & {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
background-color: ${token('color-neutral-white')};
|
|
113
|
+
background-color: ${token('color-neutral-lightest')};
|
|
132
114
|
}
|
|
133
115
|
|
|
134
|
-
${
|
|
135
|
-
${
|
|
136
|
-
outline: 1px solid ${token('color-accent')};
|
|
137
|
-
`}
|
|
138
|
-
|
|
139
|
-
${focusable`
|
|
140
|
-
box-shadow: inset ${token('shadow-glow-primary')};
|
|
141
|
-
`}
|
|
116
|
+
${StyledTableFoot} > & {
|
|
117
|
+
background-color: ${token('color-neutral-lightest')};
|
|
142
118
|
}
|
|
143
|
-
`
|
|
144
119
|
|
|
145
|
-
const StyledTableRow = styled(BaseStyledTableRow)<{ selected?: boolean }>`
|
|
146
120
|
background-color: ${conditional({
|
|
147
121
|
'table-row-selected-color': whenProps({ selected: true }),
|
|
148
|
-
'color-
|
|
122
|
+
'color-neutral-white': whenProps({ selected: false }),
|
|
149
123
|
})};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
&:nth-child(even) ${StyledTableCell} {
|
|
157
|
-
background: ${token('color-transparent')};
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
`
|
|
161
|
-
|
|
162
|
-
const StyledExpandableTableRow = styled.tr<{ $isExpanded: boolean }>`
|
|
163
|
-
background-color: ${token('color-neutral-white')};
|
|
124
|
+
${hoverable`
|
|
125
|
+
background-color: ${conditional({
|
|
126
|
+
'table-row-selected-color': whenProps({ selected: true }),
|
|
127
|
+
})} !important;
|
|
128
|
+
`}
|
|
164
129
|
|
|
165
130
|
border-color: ${token('color-neutral-lighter')};
|
|
166
131
|
border-width: 1px;
|
|
@@ -168,22 +133,24 @@ const StyledExpandableTableRow = styled.tr<{ $isExpanded: boolean }>`
|
|
|
168
133
|
border-right-style: solid;
|
|
169
134
|
border-left-style: solid;
|
|
170
135
|
border-bottom-style: ${conditional({
|
|
171
|
-
solid: whenProps({
|
|
172
|
-
hidden: whenProps({
|
|
136
|
+
solid: whenProps({ isExpanded: false }),
|
|
137
|
+
hidden: whenProps({ isExpanded: true }),
|
|
173
138
|
})};
|
|
174
139
|
|
|
175
140
|
box-shadow: ${conditional({
|
|
176
|
-
'0px 3px 3px 0px #C1CED9': whenProps({
|
|
177
|
-
none: whenProps({
|
|
141
|
+
'0px 3px 3px 0px #C1CED9': whenProps({ isExpanded: true }),
|
|
142
|
+
none: whenProps({ isExpanded: false }),
|
|
178
143
|
})};
|
|
179
144
|
|
|
180
|
-
${
|
|
181
|
-
|
|
182
|
-
|
|
145
|
+
${StyledTableBody} > & {
|
|
146
|
+
${hoverable`
|
|
147
|
+
background-color: ${token('color-neutral-lighter')};
|
|
148
|
+
`}
|
|
183
149
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
150
|
+
${focusable`
|
|
151
|
+
box-shadow: inset ${token('shadow-glow-primary')};
|
|
152
|
+
`}
|
|
153
|
+
}
|
|
187
154
|
`
|
|
188
155
|
|
|
189
156
|
const StyledExpandableContentRow = styled.tr`
|
|
@@ -195,20 +162,16 @@ const StyledExpandableContentRow = styled.tr`
|
|
|
195
162
|
border-bottom-style: solid;
|
|
196
163
|
`
|
|
197
164
|
|
|
198
|
-
const StyledTable = styled.table<{ scale?: string
|
|
165
|
+
const StyledTable = styled.table<{ scale?: string }>`
|
|
199
166
|
width: 100%;
|
|
200
167
|
|
|
201
168
|
white-space: nowrap;
|
|
202
169
|
|
|
203
|
-
background-color: ${
|
|
204
|
-
'color-neutral-lightest': whenProps({ withExpandableRows: true }),
|
|
205
|
-
'color-neutral-white': whenProps({ withExpandableRows: false }),
|
|
206
|
-
})};
|
|
170
|
+
background-color: ${token('color-neutral-lightest')};
|
|
207
171
|
|
|
208
172
|
border-collapse: collapse;
|
|
209
173
|
|
|
210
|
-
${StyledTableBody} ${StyledTableRow}
|
|
211
|
-
${StyledTableBody} ${StyledExpandableTableRow} {
|
|
174
|
+
${StyledTableBody} ${StyledTableRow} {
|
|
212
175
|
height: ${conditional({
|
|
213
176
|
'24px': whenProps({ scale: 'small' }),
|
|
214
177
|
'48px': whenProps({ scale: 'default' }),
|
|
@@ -240,14 +203,13 @@ function Table<T>({
|
|
|
240
203
|
children,
|
|
241
204
|
selection,
|
|
242
205
|
scale = 'default',
|
|
243
|
-
withExpandableRows,
|
|
244
206
|
...others
|
|
245
207
|
}: TableProps<T>): JSX.Element {
|
|
246
208
|
return (
|
|
247
209
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
248
210
|
// @ts-ignore
|
|
249
211
|
<TableSelectionProvider selection={selection}>
|
|
250
|
-
<StyledTable scale={scale}
|
|
212
|
+
<StyledTable scale={scale} {...others}>
|
|
251
213
|
{children}
|
|
252
214
|
</StyledTable>
|
|
253
215
|
</TableSelectionProvider>
|
|
@@ -273,10 +235,6 @@ function TableHead({ children, ...others }: TableSectionProps): JSX.Element {
|
|
|
273
235
|
return <StyledTableHead {...others}>{children}</StyledTableHead>
|
|
274
236
|
}
|
|
275
237
|
|
|
276
|
-
function ExpandableTableHead({ children, ...others }: TableSectionProps): JSX.Element {
|
|
277
|
-
return <StyledExpandableTableHead {...others}>{children}</StyledExpandableTableHead>
|
|
278
|
-
}
|
|
279
|
-
|
|
280
238
|
function TableBody({ children, ...others }: TableSectionProps): JSX.Element {
|
|
281
239
|
return <StyledTableBody {...others}>{children}</StyledTableBody>
|
|
282
240
|
}
|
|
@@ -344,19 +302,11 @@ function SelectionHeadCell<T>(props: SelectionCellProps<T>): JSX.Element {
|
|
|
344
302
|
)
|
|
345
303
|
}
|
|
346
304
|
|
|
347
|
-
function ExpandableHeadCell(props: TableHeadCellProps): JSX.Element {
|
|
348
|
-
return <TableHeadCell capitalized {...props} />
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
function ExpandableCell(props: TableCellProps): JSX.Element {
|
|
352
|
-
return <TableCell {...props} />
|
|
353
|
-
}
|
|
354
|
-
|
|
355
305
|
function TableRow({ children, ...others }: TableRowProps): JSX.Element {
|
|
356
306
|
const selected = useIsRowSelected(children)
|
|
357
307
|
|
|
358
308
|
return (
|
|
359
|
-
<StyledTableRow {...others} selected={selected}>
|
|
309
|
+
<StyledTableRow {...others} selected={selected} isExpanded={false}>
|
|
360
310
|
{children}
|
|
361
311
|
</StyledTableRow>
|
|
362
312
|
)
|
|
@@ -373,6 +323,8 @@ function ExpandableTableRow({
|
|
|
373
323
|
}: ExpandableTableRowProps): JSX.Element {
|
|
374
324
|
const [openState, setOpenState] = useState(initialExpanded)
|
|
375
325
|
|
|
326
|
+
const selected = useIsRowSelected(children)
|
|
327
|
+
|
|
376
328
|
const open = expanded ?? openState
|
|
377
329
|
const isExpanded = Boolean(open && expandableContent)
|
|
378
330
|
const colSpan = Array.isArray(children) ? children.length + 1 : 1
|
|
@@ -391,10 +343,10 @@ function ExpandableTableRow({
|
|
|
391
343
|
|
|
392
344
|
return (
|
|
393
345
|
<>
|
|
394
|
-
<
|
|
395
|
-
<
|
|
346
|
+
<StyledTableRow {...others} onClick={toggle} isExpanded={isExpanded} selected={selected}>
|
|
347
|
+
<TableCell>{expandableContent && leading}</TableCell>
|
|
396
348
|
{children}
|
|
397
|
-
</
|
|
349
|
+
</StyledTableRow>
|
|
398
350
|
{isExpanded && (
|
|
399
351
|
<StyledExpandableContentRow>
|
|
400
352
|
<StyledTableCell colSpan={colSpan}>{expandableContent}</StyledTableCell>
|
|
@@ -408,15 +360,13 @@ function TableHeadCell({
|
|
|
408
360
|
alignment = 'left',
|
|
409
361
|
children,
|
|
410
362
|
onClick,
|
|
411
|
-
capitalized = false,
|
|
412
363
|
...others
|
|
413
|
-
}:
|
|
364
|
+
}: TableCellProps): JSX.Element {
|
|
414
365
|
return (
|
|
415
366
|
<StyledTableHeadCell
|
|
416
367
|
clickable={onClick != null}
|
|
417
368
|
alignment={alignment}
|
|
418
369
|
onClick={onClick}
|
|
419
|
-
capitalized={capitalized}
|
|
420
370
|
{...others}
|
|
421
371
|
>
|
|
422
372
|
<Layout.Group space="xs" align="center">
|
|
@@ -563,12 +513,7 @@ Table.Selection = {
|
|
|
563
513
|
Cell: SelectionCell,
|
|
564
514
|
HeadCell: SelectionHeadCell,
|
|
565
515
|
}
|
|
566
|
-
Table.
|
|
567
|
-
Head: ExpandableTableHead,
|
|
568
|
-
HeadCell: ExpandableHeadCell,
|
|
569
|
-
Cell: ExpandableCell,
|
|
570
|
-
Row: ExpandableTableRow,
|
|
571
|
-
}
|
|
516
|
+
Table.ExpandableRow = ExpandableTableRow
|
|
572
517
|
Table.SortHandle = TableSortHandle
|
|
573
518
|
TablePicker.Item = TablePickerItem
|
|
574
519
|
Table.Picker = TablePicker
|