@loadsmart/loadsmart-ui 5.6.3 → 5.7.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 CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./DragDropFile.context-cf460901.js"),t=require("react"),n=require("styled-components"),r=require("./theming/index.js"),o=require("./loadsmart.theme-63c13988.js"),a=require("./toArray-b56541b4.js"),l=require("./prop-0c635ee9.js"),i=require("react-dom");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var d=c(t),u=s(t),g=c(n),p=c(i);function h(e){return`\n transition-property: ${(null==e?void 0:e.property)||"background, border-color, box-shadow, color, fill, left, stroke, transform, opacity"};\n transition-timing-function: ${(null==e?void 0:e.timingFunction)||"cubic-bezier(0.4, 0, 0.2, 1)"};\n transition-duration: ${(null==e?void 0:e.duration)||"450ms"};\n transition-delay: 0ms;\n `}const f=g.default.span`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./DragDropFile.context-cf460901.js"),t=require("react"),n=require("styled-components"),r=require("./theming/index.js"),o=require("./loadsmart.theme-63c13988.js"),a=require("./toArray-b56541b4.js"),l=require("./prop-0f94ff83.js"),i=require("react-dom");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var d=c(t),u=s(t),g=c(n),p=c(i);function h(e){return`\n transition-property: ${(null==e?void 0:e.property)||"background, border-color, box-shadow, color, fill, left, stroke, transform, opacity"};\n transition-timing-function: ${(null==e?void 0:e.timingFunction)||"cubic-bezier(0.4, 0, 0.2, 1)"};\n transition-duration: ${(null==e?void 0:e.duration)||"450ms"};\n transition-delay: 0ms;\n `}const f=g.default.span`
2
2
  display: inline-flex;
3
3
  align-items: center;
4
4
  justify-content: center;
@@ -1,2 +1,2 @@
1
1
  "use strict";var t=require("./toArray-b56541b4.js"),n=require("./loadsmart.theme-63c13988.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-0c635ee9.js.map
2
+ //# sourceMappingURL=prop-0f94ff83.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prop-0c635ee9.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","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":"+HAoEA,SAASA,EAAyBC,EAA+BC,GAmB/D,OAlBaC,OAAOC,KAAKH,GAAa,IAErBI,QAAO,CAACC,EAAKC,WAC5B,IAAIC,EAAQP,EAAUM,GAMtB,GAJIE,aAAWD,KACbA,EAAQA,EAAMN,IAGZM,EAAO,CACT,MAAME,EAAWH,EACXI,YAAUC,WAASF,EAAWR,kBAAqCK,EACzE,MAAO,IAAID,EAAKK,GAGlB,OAAOL,IACN,IAEQO,KAAK,KCvFlB,SAASC,KAAWC,GAElB,MAAOP,EAAOQ,GAAgBD,EAE9B,OAAa,MAATP,IAA2B,IAAVA,GAAmBS,OAAOC,MAAMV,GAC5CQ,GAAgBR,EAGJ,iBAAVA,GAAuC,IAAjBA,EAAMW,QAC9BH,GAGFR,sBD8FT,YAA2BY,GACzB,OAAO,SAAUlB,GACf,IAAImB,EAAoB,GAExB,IAAK,IAAIC,EAAI,EAAGA,EAAIF,EAAWD,OAAQG,IAAK,CAC1C,MAAMrB,EAAYmB,EAAWE,GAEzBb,aAAWR,GACboB,EAAQE,KAAKtB,EAAUC,IACdsB,WAASvB,GAClBoB,EAAUA,EAAQI,OAAOzB,EAAyBC,EAAWC,IACpDD,GACToB,EAAQE,KAAKG,OAAOzB,IAIxB,OAAOoB,EAAQR,KAAK,oBC/FxB,SACEc,EACAX,EACAY,EAAed,GAEf,OAAQZ,GAAmB0B,EAAa1B,EAAMyB,GAAOX,+BDF1BI,GAC3B,OAAO,SAAUlB,GACf,MAAM2B,EAAiBC,UAAQV,GAE/B,IAAIW,GAAM,EAEV,IAAK,IAAIT,EAAI,EAAGA,EAAIO,EAAeV,OAAQG,IAAK,CAC9C,MAAMrB,EAAY4B,EAAeP,GAC3BlB,EAAOD,OAAOC,KAAKH,GAEzB,IAAI+B,GAAO,EAEX,IAAK,IAAIC,EAAI,EAAGA,EAAI7B,EAAKe,QAAUa,EAAMC,IAAK,CAC5C,MAAM1B,EAAMH,EAAK6B,GACXC,EAAYC,aAAIjC,EAAOK,GACvB6B,EAAiBnC,EAAUM,GAG/ByB,EADEK,MAAMC,QAAQF,GACTJ,GAAQF,UAAQM,GAAgBG,SAASL,GACvCzB,aAAW2B,GACbJ,GAAQQ,QAAQJ,EAAeF,IAE/BF,GAASI,IAA+BF,EAInDH,EAAMA,GAAOC,EAGf,OAAOD"}
1
+ {"version":3,"file":"prop-0f94ff83.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","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":"+HAoEA,SAASA,EAAyBC,EAA+BC,GAmB/D,OAlBaC,OAAOC,KAAKH,GAAa,IAErBI,QAAO,CAACC,EAAKC,WAC5B,IAAIC,EAAQP,EAAUM,GAMtB,GAJIE,aAAWD,KACbA,EAAQA,EAAMN,IAGZM,EAAO,CACT,MAAME,EAAWH,EACXI,YAAUC,WAASF,EAAWR,kBAAqCK,EACzE,MAAO,IAAID,EAAKK,GAGlB,OAAOL,IACN,IAEQO,KAAK,KCvFlB,SAASC,KAAWC,GAElB,MAAOP,EAAOQ,GAAgBD,EAE9B,OAAa,MAATP,IAA2B,IAAVA,GAAmBS,OAAOC,MAAMV,GAC5CQ,GAAgBR,EAGJ,iBAAVA,GAAuC,IAAjBA,EAAMW,QAC9BH,GAGFR,sBD8FT,YAA2BY,GACzB,OAAO,SAAUlB,GACf,IAAImB,EAAoB,GAExB,IAAK,IAAIC,EAAI,EAAGA,EAAIF,EAAWD,OAAQG,IAAK,CAC1C,MAAMrB,EAAYmB,EAAWE,GAEzBb,aAAWR,GACboB,EAAQE,KAAKtB,EAAUC,IACdsB,WAASvB,GAClBoB,EAAUA,EAAQI,OAAOzB,EAAyBC,EAAWC,IACpDD,GACToB,EAAQE,KAAKG,OAAOzB,IAIxB,OAAOoB,EAAQR,KAAK,oBC/FxB,SACEc,EACAX,EACAY,EAAed,GAEf,OAAQZ,GAAmB0B,EAAa1B,EAAMyB,GAAOX,+BDF1BI,GAC3B,OAAO,SAAUlB,GACf,MAAM2B,EAAiBC,UAAQV,GAE/B,IAAIW,GAAM,EAEV,IAAK,IAAIT,EAAI,EAAGA,EAAIO,EAAeV,OAAQG,IAAK,CAC9C,MAAMrB,EAAY4B,EAAeP,GAC3BlB,EAAOD,OAAOC,KAAKH,GAEzB,IAAI+B,GAAO,EAEX,IAAK,IAAIC,EAAI,EAAGA,EAAI7B,EAAKe,QAAUa,EAAMC,IAAK,CAC5C,MAAM1B,EAAMH,EAAK6B,GACXC,EAAYC,aAAIjC,EAAOK,GACvB6B,EAAiBnC,EAAUM,GAG/ByB,EADEK,MAAMC,QAAQF,GACTJ,GAAQF,UAAQM,GAAgBG,SAASL,GACvCzB,aAAW2B,GACbJ,GAAQQ,QAAQJ,EAAeF,IAE/BF,GAASI,IAA+BF,EAInDH,EAAMA,GAAOC,EAGf,OAAOD"}
@@ -11,5 +11,6 @@ declare type TokenLike<P extends ThemedProps = ThemedProps> = ThemeToken | ((pro
11
11
  * @param {[ThemedStyledProps]} props - Component props.
12
12
  * @returns {ThemeTokenValue} Token value or `undefined` if the token was not found for the current theme.
13
13
  */
14
- export declare function getToken<P extends ThemedProps>(token: TokenLike<P>, props?: P): ThemeTokenValue | ((props: P) => ThemeTokenValue);
14
+ export declare function getToken<TProps extends ThemedProps>(token: TokenLike<TProps>): (props: TProps) => ThemeTokenValue;
15
+ export declare function getToken<TProps extends ThemedProps>(token: TokenLike<TProps>, props: TProps): ThemeTokenValue;
15
16
  export * as Themes from './themes';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/theming/index.ts"],"sourcesContent":["import { ThemeProps } from 'styled-components'\nimport { isFunction } from '@loadsmart/utils-function'\nimport ThemeAlice from './themes/alice.theme'\n\nexport type ThemeToken = keyof typeof ThemeAlice\nexport type ThemeTokenValue = string | number\n\nexport type CustomTheme = Record<ThemeToken, ThemeTokenValue>\nexport type ThemedProps = ThemeProps<CustomTheme>\n\ntype TokenLike<P extends ThemedProps = ThemedProps> = ThemeToken | ((props: P) => ThemeToken)\n\nfunction getTokenFromTheme<P extends ThemedProps>(token: TokenLike<P>, props: P): ThemeTokenValue {\n const tokenName = isFunction(token) ? token(props) : token\n return props.theme[tokenName]\n}\n\n/**\n * Return a design token value for the current theme.\n * @param {string} token - Token whose value should be returned.\n * @param {[ThemedStyledProps]} props - Component props.\n * @returns {ThemeTokenValue} Token value or `undefined` if the token was not found for the current theme.\n */\nexport function getToken<P extends ThemedProps>(\n token: TokenLike<P>,\n props?: P\n): ThemeTokenValue | ((props: P) => ThemeTokenValue) {\n if (props === undefined) {\n return (props) => getTokenFromTheme(token, props)\n }\n\n return getTokenFromTheme(token, props)\n}\n\nexport * as Themes from './themes'\n"],"names":["getTokenFromTheme","token","props","tokenName","isFunction","theme","undefined"],"mappings":"0LAYA,SAASA,EAAyCC,EAAqBC,GACrE,MAAMC,EAAYC,aAAWH,GAASA,EAAMC,GAASD,EACrD,OAAOC,EAAMG,MAAMF,8CAUnBF,EACAC,GAEA,YAAcI,IAAVJ,EACMA,GAAUF,EAAkBC,EAAOC,GAGtCF,EAAkBC,EAAOC"}
1
+ {"version":3,"file":"index.js","sources":["../../src/theming/index.ts"],"sourcesContent":["import { ThemeProps } from 'styled-components'\nimport { isFunction } from '@loadsmart/utils-function'\nimport ThemeAlice from './themes/alice.theme'\n\nexport type ThemeToken = keyof typeof ThemeAlice\nexport type ThemeTokenValue = string | number\n\nexport type CustomTheme = Record<ThemeToken, ThemeTokenValue>\nexport type ThemedProps = ThemeProps<CustomTheme>\n\ntype TokenLike<P extends ThemedProps = ThemedProps> = ThemeToken | ((props: P) => ThemeToken)\n\nfunction getTokenFromTheme<P extends ThemedProps>(token: TokenLike<P>, props: P): ThemeTokenValue {\n const tokenName = isFunction(token) ? token(props) : token\n return props.theme[tokenName]\n}\n\n/**\n * Return a design token value for the current theme.\n * @param {string} token - Token whose value should be returned.\n * @param {[ThemedStyledProps]} props - Component props.\n * @returns {ThemeTokenValue} Token value or `undefined` if the token was not found for the current theme.\n */\nexport function getToken<TProps extends ThemedProps>(\n token: TokenLike<TProps>\n): (props: TProps) => ThemeTokenValue\n\nexport function getToken<TProps extends ThemedProps>(\n token: TokenLike<TProps>,\n props: TProps\n): ThemeTokenValue\n\nexport function getToken<TProps extends ThemedProps>(token: any, props?: any): any {\n if (props === undefined) {\n return (props: TProps) => getTokenFromTheme(token, props)\n }\n\n return getTokenFromTheme(token, props)\n}\n\nexport * as Themes from './themes'\n"],"names":["getTokenFromTheme","token","props","tokenName","isFunction","theme","undefined"],"mappings":"0LAYA,SAASA,EAAyCC,EAAqBC,GACrE,MAAMC,EAAYC,aAAWH,GAASA,EAAMC,GAASD,EACrD,OAAOC,EAAMG,MAAMF,8CAkBgCF,EAAYC,GAC/D,YAAcI,IAAVJ,EACMA,GAAkBF,EAAkBC,EAAOC,GAG9CF,EAAkBC,EAAOC"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../prop-0c635ee9.js");require("../toArray-b56541b4.js"),require("../loadsmart.theme-63c13988.js"),require("../theming/index.js"),exports.conditional=e.conditional,exports.prop=e.prop,exports.whenProps=e.whenProps;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../prop-0f94ff83.js");require("../toArray-b56541b4.js"),require("../loadsmart.theme-63c13988.js"),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": "5.6.3",
3
+ "version": "5.7.0",
4
4
  "description": "Miranda UI, a React UI library",
5
5
  "main": "dist",
6
6
  "files": [
@@ -21,12 +21,18 @@ function getTokenFromTheme<P extends ThemedProps>(token: TokenLike<P>, props: P)
21
21
  * @param {[ThemedStyledProps]} props - Component props.
22
22
  * @returns {ThemeTokenValue} Token value or `undefined` if the token was not found for the current theme.
23
23
  */
24
- export function getToken<P extends ThemedProps>(
25
- token: TokenLike<P>,
26
- props?: P
27
- ): ThemeTokenValue | ((props: P) => ThemeTokenValue) {
24
+ export function getToken<TProps extends ThemedProps>(
25
+ token: TokenLike<TProps>
26
+ ): (props: TProps) => ThemeTokenValue
27
+
28
+ export function getToken<TProps extends ThemedProps>(
29
+ token: TokenLike<TProps>,
30
+ props: TProps
31
+ ): ThemeTokenValue
32
+
33
+ export function getToken<TProps extends ThemedProps>(token: any, props?: any): any {
28
34
  if (props === undefined) {
29
- return (props) => getTokenFromTheme(token, props)
35
+ return (props: TProps) => getTokenFromTheme(token, props)
30
36
  }
31
37
 
32
38
  return getTokenFromTheme(token, props)