@loadsmart/loadsmart-ui 7.0.1 → 7.1.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 +1 -1
- package/dist/{miranda-compatibility.theme-bb671a80.js → miranda-compatibility.theme-8689186b.js} +2 -2
- package/dist/{miranda-compatibility.theme-bb671a80.js.map → miranda-compatibility.theme-8689186b.js.map} +1 -1
- package/dist/{prop-e569d46a.js → prop-597d4792.js} +2 -2
- package/dist/{prop-e569d46a.js.map → prop-597d4792.js.map} +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/theming/index.js +1 -1
- package/dist/tools/index.js +1 -1
- package/package.json +5 -1
- package/src/theming/themes/miranda-compatibility.theme.ts +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("./toArray-b56541b4.js"),n=require("./miranda-compatibility.theme-
|
|
2
|
-
//# sourceMappingURL=prop-
|
|
1
|
+
"use strict";var t=require("./toArray-b56541b4.js"),n=require("./miranda-compatibility.theme-8689186b.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-597d4792.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prop-
|
|
1
|
+
{"version":3,"file":"prop-597d4792.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-8689186b.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
|
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-8689186b.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 i=e.isFunction(t)?t(r):t;return r.theme[i]}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-597d4792.js");require("../toArray-b56541b4.js"),require("../miranda-compatibility.theme-8689186b.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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loadsmart/loadsmart-ui",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"description": "Miranda UI, a React UI library",
|
|
5
5
|
"main": "dist",
|
|
6
6
|
"files": [
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
"stylelint --fix"
|
|
38
38
|
]
|
|
39
39
|
},
|
|
40
|
+
"jest-junit": {
|
|
41
|
+
"addFileAttribute": "true"
|
|
42
|
+
},
|
|
40
43
|
"devDependencies": {
|
|
41
44
|
"@babel/core": "^7.20.12",
|
|
42
45
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
@@ -110,6 +113,7 @@
|
|
|
110
113
|
"husky": "7.0.4",
|
|
111
114
|
"identity-obj-proxy": "^3.0.0",
|
|
112
115
|
"jest": "^27.5.1",
|
|
116
|
+
"jest-junit": "^16.0.0",
|
|
113
117
|
"jest-transformer-svg": "^1.0.2",
|
|
114
118
|
"lint-staged": "^11.0.0",
|
|
115
119
|
"npm-run-all": "^4.1.5",
|
|
@@ -729,7 +729,7 @@ const mirandaCompatibility = {
|
|
|
729
729
|
|
|
730
730
|
'label-tooltip-font-weight': font.weight('bold'),
|
|
731
731
|
'label-tooltip-font-size': font.size('5'),
|
|
732
|
-
'label-tooltip-font-color': color('
|
|
732
|
+
'label-tooltip-font-color': color('neutral-white'),
|
|
733
733
|
|
|
734
734
|
'label-tooltip-background-color': color('neutral'),
|
|
735
735
|
|