@elliemae/ds-typescript-helpers 3.54.0-next.4 → 3.54.0-next.6

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* prettier-ignore */\nexport namespace TypescriptHelpersT {\n /** ***************************************************************************\n * A11y Helpers\n **************************************************************************** */\n /**\n * WCAG recommends to not use tabindex values greater than 0 to ensure that the tab order is predictable.\n * @example\n * const tabIndex: WCAGTabIndex = 0; // valid\n * const tabIndex: WCAGTabIndex = -1; // valid\n *\n * const tabIndex: WCAGTabIndex = 1; // invalid\n * const tabIndex: WCAGTabIndex = \"1\"; // invalid\n * const tabIndex: WCAGTabIndex = \"0\"; // invalid\n * const tabIndex: WCAGTabIndex = \"-1\"; // invalid\n */\n export type WCAGTabIndex = 0 | -1;\n\n /** ***************************************************************************\n * Function Helpers\n **************************************************************************** */\n /**\n * Helper for declaring generic functions easly. This is usually painful because of the argument spreading\n * @example\n * const myFunction: GenericFunc<number,void> = (a) => { console.log(a) }; // a is a number\n * const myFunction2: GenericFunc<[number, number], string> = (a,b) => `${a + b}`; // a and b are numbers, the return type is a string\n */\n export type GenericFunc<T = unknown, R = unknown> = (...args: T extends Array<unknown> ? T : T[]) => R;\n /**\n * Helper for declaring a void function easly. This is usually painful because of the argument spreading.\n * @example\n * const myFunction: VoidGenericFunc<number> = (a) => { console.log(a) }; // a is a number\n * const myFunction2: VoidGenericFunc<[number, string]> = (a,b) => { console.log(a,b) }; // a is a number, b is a string\n */\n export type VoidGenericFunc<T = unknown> = GenericFunc<T, void>;\n /**\n * Helper for declaring a function that returns a boolean easly. This is usually painful because of the argument spreading\n * @example\n * const myFunction: BooleanGetter<number> = (a) => a > 0 // a is a number\n * const myFunction2: BooleanGetter<[number, string]> = (a,b) => a > 0 && b.length > 0 // a is a number, b is a string\n */\n export type BooleanGetter<T = unknown> = GenericFunc<T, boolean>;\n\n /** ***************************************************************************\n * Debugging Helpers\n **************************************************************************** */\n /**\n * debugging helper to show the expanded typescript contract,\n * it's only useful to debug, it's NOT MEANT to be used for actual declarations\n * using this for actual declarations will cause the types to be slow to compile/resolve and would have no benefit.\n * https://stackoverflow.com/questions/57683303/how-can-i-see-the-full-expanded-contract-of-a-typescript-type\n * @example\n * type Decorated = {\n * a?: string | null\n * b?: T2\n * c?: T1\n * d: string\n * e: number\n * }\n * type Injected = {\n * inj: object\n * }\n * // overriding the types from Decorated\n * type Text = Decorated &\n * Injected & {\n * name: string;\n * type: \"text\";\n * value: string;\n * subobject: Injected;\n * };\n *\n * type Expanded = DebugExpandT<Text>;\n */\n export type DebugExpandT<T> = T extends (...args: infer A) => infer R\n ? (...args: DebugExpandT<A>) => DebugExpandT<R>\n : T extends infer O\n ? { [K in keyof O]: O[K] }\n : never;\n\n /**\n * debugging helper to show the expanded typescript contract,\n * it's only useful to debug, it's NOT MEANT to be used for actual declarations\n * using this for actual declarations will cause the types to be slow to compile/resolve and would have no benefit.\n * https://stackoverflow.com/questions/57683303/how-can-i-see-the-full-expanded-contract-of-a-typescript-type\n * @example\n * type Decorated = {\n * a?: string | null\n * b?: T2\n * c?: T1\n * d: string\n * e: number\n * }\n * type Injected = {\n * inj: object\n * }\n * // overriding the types from Decorated\n * type Text = Decorated &\n * Injected & {\n * name: string;\n * type: \"text\";\n * value: string;\n * subobject: Injected;\n * };\n * interface SomeFunction {\n * (...args: Text[]): Injected & { error: boolean };\n * }\n *\n * type ExpandedRecursively = DebugExpandRecursivelyT<Text>;\n */\n export type DebugExpandRecursivelyT<T> = T extends (...args: infer A) => infer R\n ? (...args: DebugExpandRecursivelyT<A>) => DebugExpandRecursivelyT<R>\n : T extends object\n ? T extends infer O\n ? { [K in keyof O]: DebugExpandRecursivelyT<O[K]> }\n : never\n : T;\n\n /** ***************************************************************************\n * React Helpers\n **************************************************************************** */\n /**\n * An helper useful when you need the type of the second return value of React.useState\n * @example\n * const MyComponent = ({ setFoo }:{\n * setFoo: StateSetter<string>; // our children expects a react \"state setter\"\n * }) => {\n * const handleClick = () => {\n * setFoo('New value');\n * };\n * return <button onClick={handleClick}>Set Foo</button>;\n * };\n * const ParentComponent: React.FC = () => {\n * const [foo, setFoo] = React.useState<string>('Initial value');\n * return (\n * <div>\n * <p>Foo: {foo}</p>\n * <MyComponent setFoo={setFoo} />\n * </div>\n * );\n * };\n */\n export type StateSetter<T = unknown> = React.Dispatch<React.SetStateAction<T>>;\n\n /**\n * An helper useful when you need to type an higher order component that has no special requirements on the interface of the component it implements\n * @example\n * // a generic component that displays a label and a value for the sake of the example\n * interface LabelValueDisplayerPropsT {\n * foo: string;\n * bar: number;\n * }\n * const LabelValueDisplayer: React.ComponentType<LabelValueDisplayerPropsT> = ({ foo, bar }) => (\n * <div>\n * <label>{foo}</label>\n * <div>{bar}</div>\n * </div>\n * );\n *\n * // we are creating an example HOC that logs the props of the component it wraps before rendering it\n * const withLogging: TypescriptHelpersT.ReactFunctionalHOC<LabelValueDisplayerPropsT> = (Component) => (props) => {\n * console.log('Rendering component with props:', props);\n * return <Component {...props} />;\n * };\n *\n * // we can now use the HOC to wrap our component\n * const ComponentWithGenericLogging = withLogging(LabelValueDisplayer);\n * const ExampleUsageInComponent = () => {\n * return <ComponentWithGenericLogging foo=\"Test\" bar={123} />; // <-- this is correctly typed!\n * };\n */\n export type ReactFunctionalHOC<T = Record<string, unknown>> = (\n Component: React.ComponentType<React.JSX.IntrinsicAttributes & T>,\n ) => React.ComponentType<React.JSX.IntrinsicAttributes & T>;\n\n /**\n * An helper useful when you need to type an higher order component that has special requirements on the interface of the component it implements\n * @example\n * // a generic component that displays a label and a value for the sake of the example\n * interface LabelValueDisplayerPropsT {\n * foo: string;\n * bar: number;\n * }\n * const LabelValueDisplayer: React.ComponentType<LabelValueDisplayerPropsT> = ({ foo, bar }) => (\n * <div>\n * <label>{foo}</label>\n * <div>{bar}</div>\n * </div>\n * );\n *\n * interface LoggerProps { loggableTemplateLabel: string; loggableTemplateValue: string; }\n *\n * // the HOC we are creating has special requirements on the props of the component it wraps\n * // AND it has some requirements on it's own props\n * const withLogging: ReactFunctionalHOCWithDifferentInterface<LoggerProps, StartingProps> =\n * (Component) => ({ loggableTemplateLabel, loggableTemplateValue }) => {\n * const startingLabel = loggableTemplateLabel.replace(/{{label was}}/g, \"\");\n * const startingValue = parseInt(\n * loggableTemplateValue.replace(/{{value was}}/g, \"\"),\n * 10\n * );\n * console.log(\n * `${loggableTemplateLabel.replace(/{{label was}}/g, \"Label was -> \")}`,\n * `${loggableTemplateValue.replace(/{{value was}}/g, \"Value was -> \")}`\n * );\n * return <Component startA={startingLabel} startB={startingValue} />;\n * };\n *\n * const ComponentWithSpecialLogging = withLogging(LabelValueDisplayer); // <-- this is correctly typed!\n * const ExampleUsageInComponent = () => (\n * <ComponentWithSpecialLogging\n * loggableTemplateLabel=\"{{label was}}Starting count:\"\n * loggableTemplateValue=\"{{value was}}0\"\n * />\n * )\n */\n export type ReactFunctionalHOCWithDifferentInterface<K = Record<string, unknown>, T = Record<string, unknown>> = (\n Component: React.ComponentType<React.JSX.IntrinsicAttributes & T>,\n ) => React.ComponentType<K>;\n\n /**\n * An helper for declaring the return type of React.useRef in a way that reflects the reality of how it can be used\n * @example\n * const ComponentWithRef = () => {\n * // starting value for ref should be null\n * const myRef: T.AnyRef<HTMLDivElement> = React.useRef<HTMLDivElement>(null);\n * return (<div ref={\n * (node => {\n * // when used it should reflect what you can actually do with it, mutating it is valid.\n * myRef.current = node;\n * })\n * }>Hello, world!</div>)\n * };\n */\n export type AnyRef<T> = React.MutableRefObject<T | null> | ((_ref: T | null) => void);\n\n /**\n * An helper for defining the type of the children prop of a React component\n * @example\n * type ReactChildrenComplete = React.PropsWithChildren<object>[\"children\"];\n * type MyComponentProps = {\n * children: ReactChildrenComplete;\n * foo: string;\n * };\n * const MyComponent = ({ children, foo }: MyComponentProps) => ( <div>{children}{foo}</div> );\n */\n export type ReactChildrenComplete = React.PropsWithChildren<object>['children'];\n\n /** ***************************************************************************\n * Object Helpers\n **************************************************************************** */\n\n /**\n * Helper to declare an object that has at least one of the keys of the original object as required\n * https://www.typescriptlang.org/play?#code/C4TwDgpgBAShCOBXAlgJwgQWAGQgQwGdgB5AOwgB4AVAGigGkIQCoIAPYCUgExYGsmAewBmUKlAC8UASBFiAfJICwAKCjqoABWQBjPtToBRNjoA2ibpRlzaDJgXnzVGqADIoAb2cuNAbXpQyKR2zAC6ALQA-ABcsAgo6NwU2noGDI5uWniowMh4psm6+rbGZhaUjMx09I5OahoAvv72oaqqQZyowng60ACyXIgAkpwAtp7eucCmELFEqEEA5gDc3jqCo2CC5KTAMVCkiKMARhCoq-VmRfuHJ2cX6rrbc8ALpCuqDW0qoJBQAMKmIrEVD-DZbHbASRxJBoTA4fBEMiUAaHEYQUZ0ADkVz0WKgAB8oDjwdsuMAsXVVOtSEQoAB3ZDAAAWYM2ZN2sUBwNBpMh0K89XUUxmsQARJwiGKaN51Ot2ZDYgBWABMMqFgRp4qepDFn2+NLpjJZ3L0XKBehBbIh5IFsqgItmUAlECl6pcuL4yoALO6NDrtTS9Sovipqds6WdUIJUAB1JnMgByEATZ3NPOtHKhUkFLkd4slwGl9oDzp1wdD4dpUNIgkMqGjcYTACFBCz05beQrbTn7fnnYXixrPT6-XK+eTYirfSWtWWg-qwypDVCozH4yzWyzY8yuMiABKEWPR95UcBO018K0T3Z2jX9l1u+0jqBKmfDm-AcUEZmCRCmbgoFOA4jlOVAoF3dAhxcUsxXLRdvl+aA4FhdAyFMEBkTSSoWHYTgeH4IRRHEKRrGIxQJHtFJiiMExzEsCgyLEap7Ece13A8KB-ECYIcIiGJ7RcFCEggJJqOwtiNRcdxNGyXJ8goOB1lQJJSnoip7GqeQ6EQHgIGEIJRMklwmj4xDzygdDMPIS9r27W8pGEuErKw1FhjGbFPXxIkSXsikqWXCMazrBt1wTFzyFiCKIFsrsbQciZ7yZUUB1dIsxygF8lQAZnfGC5zghcQwNILWFCptNzbZkotIDDkVizN+V7JLpidR90ufC0vVfXKMvleKvx6jLYPg4ql1UAB6CaxGZZAWA6M5ul6BlkFMUwgOgRACFEh1BAdBY9Es2rrJirqsEa20Oj2-JTEERl3igPBgkEY4ACsIB0KFjWZICqvUdpdkWnpoEvNz0XGXMHWSp15iWB5Mq62JbjA+HS1h94LkrQLqwgwgtx+5q82hgs0ugjQsry8nPynSnHgK0asamqBEz2tdwNOHQ8C26B2F6AgWDAaNIByZBXUe9AoG2DCoG4Oabrunb6V3YJZfQT7pcIAhkEWUglke563o+qEgU6fIoCrOkxjADs+DBsZoWZPGqu+JmWbKxsZddMAmWgK3Hs+xAbpAXGADc9eOP6Oa57axAAZUl47pFrekWBZPAoT9ubHoBLq7Yxc3sctg6+CGXZBAwNa7qWfGarqmyursgboSt1QgA\n * @example\n * const myObject: RequireAtLeastOne<{a: string, b: string}> = {a: 'foo'}; // valid\n * const myObject2: RequireAtLeastOne<{a: string, b: string}> = {b: 'foo'}; // valid\n * const myObject3: RequireAtLeastOne<{a: string, b: string}> = {a: 'foo', b: 'bar'}; // valid\n *\n * const myObject4: RequireAtLeastOne<{a: string, b: string}> = {}; // invalid\n */\n export type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> &\n {\n [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;\n }[Keys];\n\n // helper to require specifically only one of the keys of an object\n // E.G.: type MyType = RequireOnlyOne<{a: string, b: string}>; // MyType = {a: string} | {b: string}\n /**\n * Helper to declare an object that has only one of the keys of the original object as required\n * @example\n * const myObject: RequireOnlyOne<{a: string, b: string}> = {a: 'foo'}; // valid\n * const myObject2: RequireOnlyOne<{a: string, b: string}> = {b: 'foo'}; // valid\n *\n * const myObject3: RequireOnlyOne<{a: string, b: string}> = {a: 'foo', b: 'bar'}; // invalid\n */\n export type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> &\n {\n [K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;\n }[Keys];\n\n /**\n * An Helper that given the type of an object, returns the type of the values of the object\n *\n * This is an useful alternative to typescripts enums, making your code as type safe as enums but without the typescript exclusive declaration and syntax\n *\n * Projects are free to decide wheter or not they wish to allow enums in their code base but we suggest being aware of the pitfalls of enums and double check the official documentation before making a decision\n *\n * https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums\n *\n * > The biggest argument in favour of this format over TypeScript's enum is that it keeps your codebase aligned with the state of JavaScript, and when/if enums are added to JavaScript then you can move to the additional syntax.\n *\n * https://github.com/tc39/proposal-type-annotations?tab=readme-ov-file#intentional-omissions\n * @example\n * type MyObject = {a: string, b: number};\n * type MyObjectValues = ObjectValues<MyObject>; // MyObjectValues = string | number\n * @example\n * const myEnumLikeObject = {\n * a: 'foo',\n * b: 'bar'\n * } as const;\n *\n * type myEnumLikeObjectValues = TypescriptHelpersT.ObjectValues<typeof myEnumLikeObject>; // myEnumLikeObjectValues = 'foo' | 'bar'\n * const foo: myEnumLikeObjectValues = 'foo'; // valid\n * const foo2: myEnumLikeObjectValues = 'bar'; // valid\n *\n * const foo3: myEnumLikeObjectValues = 'baz'; // invalid\n */\n export type ObjectValues<T> = T[keyof T];\n\n /**\n * A type that represents an object in which every key starts with \"data-\" and the value is a string, useful for declaring the data-* attributes of an HTML element\n * @example\n * const myObject: DataProps = { 'data-foo': 'bar' }; // valid\n *\n * const myObject2: DataProps = { 'aria-foo': 123 }; // invalid\n * const myObject3: DataProps = { 'foo': 'bar' }; // invalid\n */\n export type DataProps = {\n [key in `data-${string}`]: string;\n };\n /**\n * A type that represents an object in which every key starts with \"aria-\" and the value is a string, useful for declaring the aria-* attributes of an HTML element\n * @example\n * const myObject: AriaProps = { 'aria-foo': 'bar' }; // valid\n *\n * const myObject2: AriaProps = { 'data-foo': 123 }; // invalid\n * const myObject3: AriaProps = { 'foo': 'bar' }; // invalid\n */\n export type AriaProps = {\n [key in `aria-${string}`]: string;\n };\n /**\n * A type that represents an object in which every key starts with \"data-\" or \"aria-\" and the value is a string, useful for declaring the aria-* and data-* attributes of an HTML element\n * @example\n * const myObject: AriaAndDataProps = { 'aria-foo': 'bar' }; // valid\n * const myObject2: AriaAndDataProps = { 'data-foo': 'bar' }; // valid\n * const myObject3: AriaAndDataProps = { 'aria-foo': 'bar', 'data-foo': 'bar' }; // valid\n *\n * const myObject4: AriaAndDataProps = { 'foo': 'bar' }; // invalid\n */\n export type AriaAndDataProps = {\n [key in `data-${string}` | `aria-${string}`]: string;\n };\n\n /**\n * Type helper that excludes keys from one type that exist in another.\n * @example\n * type MyType = ExcludeKeys<{a: string, b: number}, {a: string}>; // MyType = {b: number}\n * type MyType2 = ExcludeKeys<{a: string, b: number}, {a: string, b: number}>; // MyType2 = {}\n * type MyType3 = ExcludeKeys<{a: string, b: number}, {c: string}>; // MyType3 = {a: string, b: number}\n */\n export type ExcludeKeys<T, U> = {\n [K in keyof T as K extends keyof U ? never : K]: T[K];\n };\n\n /** ***************************************************************************\n * Template Literals\n * Snake, Camel, Pascal, Kebab Case\n * https://stackoverflow.com/questions/60269936/typescript-convert-generic-object-from-snake-to-camel-case\n * https://www.typescriptlang.org/play?#code/C4TwDgpgBAygdgQwNYQCoHsDCCC2EA22AzhADwxQQAewEcAJkVEcAE4CWcA5gHxQC8AKCixKNOoygADACQBvTgDMIrKKgC+AfXlKVUAKrqpUAPzDp8jfOxh2wBPnYAvMvGRosuAsTL6ePIygALnMYQUFQSChsPHwMNxQfcjFaBiYWDm4+IREKalTJWQU4ZVUrYtKDQLMRItQUiSYbOwdnMlQ+EygAIk1u4J7u9XkAGXQAdxUAYwQSUg7huRiCeMRE2d8A4xDc8MjoZbj0AAVZmcIN5PzG5jZOXgFohFt7RxdyHgjwaFOic4xDkk8uI0rdMg9+AY4DMXq13jBPvsoL9-ugEhAgQ1QRl7tknrFVu4kvpoc8Wm9XP4vlF0RgUQ5MddsXcso9mq82uQ1h5AZcEZ9qdAANIQABGCFFhPWc2BBXSLIhoSxhR0JT0GgAtKrKoZjDULHINNo5CLxZK0dziVtgqE9t8oAA5R4AFgATHaoqgkABGb2PU0SqUYy7dAAWBHw6G6fAA9DGeuH8JHNON0Kx8PRuoK1D7Xf6xYGLUSQ4nIxrU6xM7H42GI+gU2mM1mkV7vQBmfNmoNJWtJ9DltP0DW0FjRqBxhN1hvp+iaEfAZv21vOzuF9E90v9itD+f9AA+UAA5Ip0P3xaxhxAWIfq5O+9PZ7uoAfuif6+e51eF9nWwBWVfmuulw4qyE4gVwP4+gAbAB3aXFIwDhhqCBwEQkwXuwRBanIDpGLe3SIRAmgoWhKiaJhmhuv0AAUSJOpCboAJQetAqC+o8tKeLEG51mOE69pGi6et6eaQpxvJzAJ9YVk2+GbgA6o2mY-u2HHcgCXgXJJm5zkQ06yeONabqgRCKTOQmsd6K5iepXHeCWU4yZmz49G+mjnnxRl1mZTYua+p4AEIIKwFlqN6-42e4GnccBCq3uBKkwZFKDRfZcwIeGxGoeh5F6fIuFSPhhEAILZSoACSRBUVAtH2vRUBMSxaiun6kKHHB2m8XJvE-q6on4isRbSmQUk+VWhl3smTmhagrodm1mkdSNxmmUpnmTfWwB6dNTWoG2rUDUc9JactXU-m2-XtScZwMg5fZjdG53zYddI3SdpBSSZD0Ci2zoHZxx08X2j2-f1ANvUDU1rYiS7Os94N-LdnX3lt+lVrtv4HcdqXvd0AASZ0tr+-XY3ZuME-d0M-r+z2kxJI0U5GX1Uz+UFY29S0fYzUYw56UEkxzQ3BpJ3PfaztOC0BIt1sz5k-fa5VwGAACuwCoPakJyOYRDcpoMwkJoKAgJo3pBFAcDKzgooqAANNruv60RRuaK6ZvgXb6hNQA8qrKtqxrUByFAADaQpQJwUBG+gihQIrfvq1EsywLZ9OkEKPAALpm3HqsJxAocZ1AnsxgAVOYSI+8A8cB1rIh18wlobCKICm+blvW6wADc5j1zrxYkM3rtgvc3ciJ7JcxuEpdl1AJdQMIc8AKIgkQ7DoHAZuYOvABuKjAObX4QPQUBgKw6CQKwwDsFeC-z7Pk9Ijn-uQA6h-H5r9vuHrGyGxAxut7XOufcUDfwNs7X0bsFQ9wbl-R2v9-5DwSmPO2IhgFETgc7RBCoPZNXEppHwr8WBH3mHieoTJJDoFFAAKwgFMfeXRAGh3DnASOf9o5qCgEnPBMU5hhwAGTDyyFnZOUUyYELfvMAunx1ADFQN7X2udviENoO-ERKUxEbGUcQp+ectH0B4EAA\n **************************************************************************** */\n\n /**\n * Converts a string from snake_case to camelCase\n * @example\n * type MyType = SnakeToCamelCase<'foo_bar'>; // MyType = 'fooBar'\n */\n export type SnakeToCamelCase<S extends string> = S extends `${infer T}_${infer U}`\n ? `${T}${Capitalize<SnakeToCamelCase<U>>}`\n : S;\n /**\n * Converts a string from snake_case to PascalCase\n * @example\n * type MyType = SnakeToPascalCase<'foo_bar'>; // MyType = 'FooBar'\n */\n export type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}`\n ? `${T extends Capitalize<T> ? '_' : ''}${Lowercase<T>}${CamelToSnakeCase<U>}`\n : S;\n /**\n * Converts a string from kebab-case to snake_case\n * @example\n * type MyType = KebabToSnakeCase<'foo-bar'>; // MyType = 'foo_bar'\n */\n export type KebabToSnakeCase<S extends string> = S extends `${infer T}-${infer U}`\n ? `${T}_${KebabToSnakeCase<U>}`\n : S;\n /**\n * Converts a string from snake_case to kebab-case\n * @example\n * type MyType = SnakeToKebabCase<'foo_bar'>; // MyType = 'foo-bar'\n */\n export type SnakeToKebabCase<S extends string> = S extends `${infer T}_${infer U}`\n ? `${T}-${SnakeToKebabCase<U>}`\n : S;\n /**\n * Converts a string from camelCase to PascalCase\n * @example\n * type MyType = CamelToPascalCase<'fooBar'>; // MyType = 'FooBar'\n */\n export type CamelToPascalCase<S extends string> = Capitalize<S>;\n /**\n * Converts a string from PascalCase to camelCase\n * @example\n * type MyType = PascalToCamelCase<'FooBar'>; // MyType = 'fooBar'\n */\n export type PascalToCamelCase<S extends string> = Uncapitalize<S>;\n /**\n * Converts a string from PascalCase to snake_case\n * @example\n * type MyType = PascalToSnakeCase<'FooBar'>; // MyType = 'foo_bar'\n */\n export type PascalToSnakeCase<S extends string> = CamelToSnakeCase<Uncapitalize<S>>;\n\n /**\n * Converts a string from snake_case to PascalCase\n * @example\n * type MyType = SnakeToPascalCase<'foo_bar'>; // MyType = 'FooBar'\n */\n export type SnakeToPascalCase<S extends string> = Capitalize<SnakeToCamelCase<S>>;\n\n /** ***************************************************************************\n * Template Literals\n * Dimsum specific (internal) helpers\n ****************************************************************************\n */\n export type RemoveDSPrefix<S extends string> = S extends `DS${infer T}` ? T : S;\n export type PropsForGlobalOnSlots<Name extends string, Slots extends Record<string, string>> = {\n [key in ObjectValues<Slots> as `ds${RemoveDSPrefix<Name>}${SnakeToPascalCase<KebabToSnakeCase<key>>}`]?:\n | object\n | ((arg: object) => object);\n };\n export type AriaAndDataPropsOrPropsGetter = AriaAndDataProps | (() => AriaAndDataProps);\n\n export type Hydraters<T, Args = unknown> = {\n [key in keyof T as key extends string ? `get${Capitalize<key>}` : key]: (\n ...args: Args extends Array<unknown> ? Args : Args[]\n ) => T[key];\n };\n}\n", "import * as React from 'react';\nexport { React };\n"],
4
+ "sourcesContent": ["/* prettier-ignore */\nexport namespace TypescriptHelpersT {\n /** ***************************************************************************\n * A11y Helpers\n **************************************************************************** */\n /**\n * WCAG recommends to not use tabindex values greater than 0 to ensure that the tab order is predictable.\n * @example\n * const tabIndex: WCAGTabIndex = 0; // valid\n * const tabIndex: WCAGTabIndex = -1; // valid\n *\n * const tabIndex: WCAGTabIndex = 1; // invalid\n * const tabIndex: WCAGTabIndex = \"1\"; // invalid\n * const tabIndex: WCAGTabIndex = \"0\"; // invalid\n * const tabIndex: WCAGTabIndex = \"-1\"; // invalid\n */\n export type WCAGTabIndex = 0 | -1;\n\n /** ***************************************************************************\n * Function Helpers\n **************************************************************************** */\n /**\n * Helper for declaring generic functions easly. This is usually painful because of the argument spreading\n * @example\n * const myFunction: GenericFunc<number,void> = (a) => { console.log(a) }; // a is a number\n * const myFunction2: GenericFunc<[number, number], string> = (a,b) => `${a + b}`; // a and b are numbers, the return type is a string\n */\n export type GenericFunc<T = unknown, R = unknown> = (...args: T extends Array<unknown> ? T : T[]) => R;\n /**\n * Helper for declaring a void function easly. This is usually painful because of the argument spreading.\n * @example\n * const myFunction: VoidGenericFunc<number> = (a) => { console.log(a) }; // a is a number\n * const myFunction2: VoidGenericFunc<[number, string]> = (a,b) => { console.log(a,b) }; // a is a number, b is a string\n */\n export type VoidGenericFunc<T = unknown> = GenericFunc<T, void>;\n /**\n * Helper for declaring a function that returns a boolean easly. This is usually painful because of the argument spreading\n * @example\n * const myFunction: BooleanGetter<number> = (a) => a > 0 // a is a number\n * const myFunction2: BooleanGetter<[number, string]> = (a,b) => a > 0 && b.length > 0 // a is a number, b is a string\n */\n export type BooleanGetter<T = unknown> = GenericFunc<T, boolean>;\n\n /** ***************************************************************************\n * Debugging Helpers\n **************************************************************************** */\n /**\n * debugging helper to show the expanded typescript contract,\n * it's only useful to debug, it's NOT MEANT to be used for actual declarations\n * using this for actual declarations will cause the types to be slow to compile/resolve and would have no benefit.\n * https://stackoverflow.com/questions/57683303/how-can-i-see-the-full-expanded-contract-of-a-typescript-type\n * @example\n * type Decorated = {\n * a?: string | null\n * b?: T2\n * c?: T1\n * d: string\n * e: number\n * }\n * type Injected = {\n * inj: object\n * }\n * // overriding the types from Decorated\n * type Text = Decorated &\n * Injected & {\n * name: string;\n * type: \"text\";\n * value: string;\n * subobject: Injected;\n * };\n *\n * type Expanded = DebugExpandT<Text>;\n */\n export type DebugExpandT<T> = T extends (...args: infer A) => infer R\n ? (...args: DebugExpandT<A>) => DebugExpandT<R>\n : T extends infer O\n ? { [K in keyof O]: O[K] }\n : never;\n\n /**\n * debugging helper to show the expanded typescript contract,\n * it's only useful to debug, it's NOT MEANT to be used for actual declarations\n * using this for actual declarations will cause the types to be slow to compile/resolve and would have no benefit.\n * https://stackoverflow.com/questions/57683303/how-can-i-see-the-full-expanded-contract-of-a-typescript-type\n * @example\n * type Decorated = {\n * a?: string | null\n * b?: T2\n * c?: T1\n * d: string\n * e: number\n * }\n * type Injected = {\n * inj: object\n * }\n * // overriding the types from Decorated\n * type Text = Decorated &\n * Injected & {\n * name: string;\n * type: \"text\";\n * value: string;\n * subobject: Injected;\n * };\n * interface SomeFunction {\n * (...args: Text[]): Injected & { error: boolean };\n * }\n *\n * type ExpandedRecursively = DebugExpandRecursivelyT<Text>;\n */\n export type DebugExpandRecursivelyT<T> = T extends (...args: infer A) => infer R\n ? (...args: DebugExpandRecursivelyT<A>) => DebugExpandRecursivelyT<R>\n : T extends object\n ? T extends infer O\n ? { [K in keyof O]: DebugExpandRecursivelyT<O[K]> }\n : never\n : T;\n\n /** ***************************************************************************\n * React Helpers\n **************************************************************************** */\n /**\n * An helper useful when you need the type of the second return value of React.useState\n * @example\n * const MyComponent = ({ setFoo }:{\n * setFoo: StateSetter<string>; // our children expects a react \"state setter\"\n * }) => {\n * const handleClick = () => {\n * setFoo('New value');\n * };\n * return <button onClick={handleClick}>Set Foo</button>;\n * };\n * const ParentComponent: React.FC = () => {\n * const [foo, setFoo] = React.useState<string>('Initial value');\n * return (\n * <div>\n * <p>Foo: {foo}</p>\n * <MyComponent setFoo={setFoo} />\n * </div>\n * );\n * };\n */\n export type StateSetter<T = unknown> = React.Dispatch<React.SetStateAction<T>>;\n\n /**\n * An helper useful when you need to type an higher order component that has no special requirements on the interface of the component it implements\n * @example\n * // a generic component that displays a label and a value for the sake of the example\n * interface LabelValueDisplayerPropsT {\n * foo: string;\n * bar: number;\n * }\n * const LabelValueDisplayer: React.ComponentType<LabelValueDisplayerPropsT> = ({ foo, bar }) => (\n * <div>\n * <label>{foo}</label>\n * <div>{bar}</div>\n * </div>\n * );\n *\n * // we are creating an example HOC that logs the props of the component it wraps before rendering it\n * const withLogging: TypescriptHelpersT.ReactFunctionalHOC<LabelValueDisplayerPropsT> = (Component) => (props) => {\n * console.log('Rendering component with props:', props);\n * return <Component {...props} />;\n * };\n *\n * // we can now use the HOC to wrap our component\n * const ComponentWithGenericLogging = withLogging(LabelValueDisplayer);\n * const ExampleUsageInComponent = () => {\n * return <ComponentWithGenericLogging foo=\"Test\" bar={123} />; // <-- this is correctly typed!\n * };\n */\n export type ReactFunctionalHOC<T = Record<string, unknown>> = (\n Component: React.ComponentType<React.JSX.IntrinsicAttributes & T>,\n ) => React.ComponentType<React.JSX.IntrinsicAttributes & T>;\n\n /**\n * An helper useful when you need to type an higher order component that has special requirements on the interface of the component it implements\n * @example\n * // a generic component that displays a label and a value for the sake of the example\n * interface LabelValueDisplayerPropsT {\n * foo: string;\n * bar: number;\n * }\n * const LabelValueDisplayer: React.ComponentType<LabelValueDisplayerPropsT> = ({ foo, bar }) => (\n * <div>\n * <label>{foo}</label>\n * <div>{bar}</div>\n * </div>\n * );\n *\n * interface LoggerProps { loggableTemplateLabel: string; loggableTemplateValue: string; }\n *\n * // the HOC we are creating has special requirements on the props of the component it wraps\n * // AND it has some requirements on it's own props\n * const withLogging: ReactFunctionalHOCWithDifferentInterface<LoggerProps, StartingProps> =\n * (Component) => ({ loggableTemplateLabel, loggableTemplateValue }) => {\n * const startingLabel = loggableTemplateLabel.replace(/{{label was}}/g, \"\");\n * const startingValue = parseInt(\n * loggableTemplateValue.replace(/{{value was}}/g, \"\"),\n * 10\n * );\n * console.log(\n * `${loggableTemplateLabel.replace(/{{label was}}/g, \"Label was -> \")}`,\n * `${loggableTemplateValue.replace(/{{value was}}/g, \"Value was -> \")}`\n * );\n * return <Component startA={startingLabel} startB={startingValue} />;\n * };\n *\n * const ComponentWithSpecialLogging = withLogging(LabelValueDisplayer); // <-- this is correctly typed!\n * const ExampleUsageInComponent = () => (\n * <ComponentWithSpecialLogging\n * loggableTemplateLabel=\"{{label was}}Starting count:\"\n * loggableTemplateValue=\"{{value was}}0\"\n * />\n * )\n */\n export type ReactFunctionalHOCWithDifferentInterface<K = Record<string, unknown>, T = Record<string, unknown>> = (\n Component: React.ComponentType<React.JSX.IntrinsicAttributes & T>,\n ) => React.ComponentType<K>;\n\n /**\n * An helper for declaring the return type of React.useRef in a way that reflects the reality of how it can be used\n * @example\n * const ComponentWithRef = () => {\n * // starting value for ref should be null\n * const myRef: T.AnyRef<HTMLDivElement> = React.useRef<HTMLDivElement>(null);\n * return (<div ref={\n * (node => {\n * // when used it should reflect what you can actually do with it, mutating it is valid.\n * myRef.current = node;\n * })\n * }>Hello, world!</div>)\n * };\n */\n export type AnyRef<T> = React.MutableRefObject<T | null> | ((_ref: T | null) => void);\n\n /**\n * An helper for defining the type of the children prop of a React component\n * @example\n * type ReactChildrenComplete = React.PropsWithChildren<object>[\"children\"];\n * type MyComponentProps = {\n * children: ReactChildrenComplete;\n * foo: string;\n * };\n * const MyComponent = ({ children, foo }: MyComponentProps) => ( <div>{children}{foo}</div> );\n */\n export type ReactChildrenComplete = React.PropsWithChildren<object>['children'];\n\n /** ***************************************************************************\n * Object Helpers\n **************************************************************************** */\n\n /**\n * Helper to declare an object that has at least one of the keys of the original object as required\n * https://www.typescriptlang.org/play?#code/C4TwDgpgBAShCOBXAlgJwgQWAGQgQwGdgB5AOwgB4AVAGigGkIQCoIAPYCUgExYGsmAewBmUKlAC8UASBFiAfJICwAKCjqoABWQBjPtToBRNjoA2ibpRlzaDJgXnzVGqADIoAb2cuNAbXpQyKR2zAC6ALQA-ABcsAgo6NwU2noGDI5uWniowMh4psm6+rbGZhaUjMx09I5OahoAvv72oaqqQZyowng60ACyXIgAkpwAtp7eucCmELFEqEEA5gDc3jqCo2CC5KTAMVCkiKMARhCoq-VmRfuHJ2cX6rrbc8ALpCuqDW0qoJBQAMKmIrEVD-DZbHbASRxJBoTA4fBEMiUAaHEYQUZ0ADkVz0WKgAB8oDjwdsuMAsXVVOtSEQoAB3ZDAAAWYM2ZN2sUBwNBpMh0K89XUUxmsQARJwiGKaN51Ot2ZDYgBWABMMqFgRp4qepDFn2+NLpjJZ3L0XKBehBbIh5IFsqgItmUAlECl6pcuL4yoALO6NDrtTS9Sovipqds6WdUIJUAB1JnMgByEATZ3NPOtHKhUkFLkd4slwGl9oDzp1wdD4dpUNIgkMqGjcYTACFBCz05beQrbTn7fnnYXixrPT6-XK+eTYirfSWtWWg-qwypDVCozH4yzWyzY8yuMiABKEWPR95UcBO018K0T3Z2jX9l1u+0jqBKmfDm-AcUEZmCRCmbgoFOA4jlOVAoF3dAhxcUsxXLRdvl+aA4FhdAyFMEBkTSSoWHYTgeH4IRRHEKRrGIxQJHtFJiiMExzEsCgyLEap7Ece13A8KB-ECYIcIiGJ7RcFCEggJJqOwtiNRcdxNGyXJ8goOB1lQJJSnoip7GqeQ6EQHgIGEIJRMklwmj4xDzygdDMPIS9r27W8pGEuErKw1FhjGbFPXxIkSXsikqWXCMazrBt1wTFzyFiCKIFsrsbQciZ7yZUUB1dIsxygF8lQAZnfGC5zghcQwNILWFCptNzbZkotIDDkVizN+V7JLpidR90ufC0vVfXKMvleKvx6jLYPg4ql1UAB6CaxGZZAWA6M5ul6BlkFMUwgOgRACFEh1BAdBY9Es2rrJirqsEa20Oj2-JTEERl3igPBgkEY4ACsIB0KFjWZICqvUdpdkWnpoEvNz0XGXMHWSp15iWB5Mq62JbjA+HS1h94LkrQLqwgwgtx+5q82hgs0ugjQsry8nPynSnHgK0asamqBEz2tdwNOHQ8C26B2F6AgWDAaNIByZBXUe9AoG2DCoG4Oabrunb6V3YJZfQT7pcIAhkEWUglke563o+qEgU6fIoCrOkxjADs+DBsZoWZPGqu+JmWbKxsZddMAmWgK3Hs+xAbpAXGADc9eOP6Oa57axAAZUl47pFrekWBZPAoT9ubHoBLq7Yxc3sctg6+CGXZBAwNa7qWfGarqmyursgboSt1QgA\n * @example\n * const myObject: RequireAtLeastOne<{a: string, b: string}> = {a: 'foo'}; // valid\n * const myObject2: RequireAtLeastOne<{a: string, b: string}> = {b: 'foo'}; // valid\n * const myObject3: RequireAtLeastOne<{a: string, b: string}> = {a: 'foo', b: 'bar'}; // valid\n *\n * const myObject4: RequireAtLeastOne<{a: string, b: string}> = {}; // invalid\n */\n export type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> &\n {\n [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;\n }[Keys];\n\n // helper to require specifically only one of the keys of an object\n // E.G.: type MyType = RequireOnlyOne<{a: string, b: string}>; // MyType = {a: string} | {b: string}\n /**\n * Helper to declare an object that has only one of the keys of the original object as required\n * @example\n * const myObject: RequireOnlyOne<{a: string, b: string}> = {a: 'foo'}; // valid\n * const myObject2: RequireOnlyOne<{a: string, b: string}> = {b: 'foo'}; // valid\n *\n * const myObject3: RequireOnlyOne<{a: string, b: string}> = {a: 'foo', b: 'bar'}; // invalid\n */\n export type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> &\n {\n [K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;\n }[Keys];\n\n /**\n * An Helper that given the type of an object, returns the type of the values of the object\n *\n * This is an useful alternative to typescripts enums, making your code as type safe as enums but without the typescript exclusive declaration and syntax\n *\n * Projects are free to decide wheter or not they wish to allow enums in their code base but we suggest being aware of the pitfalls of enums and double check the official documentation before making a decision\n *\n * https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums\n *\n * > The biggest argument in favour of this format over TypeScript's enum is that it keeps your codebase aligned with the state of JavaScript, and when/if enums are added to JavaScript then you can move to the additional syntax.\n *\n * https://github.com/tc39/proposal-type-annotations?tab=readme-ov-file#intentional-omissions\n * @example\n * type MyObject = {a: string, b: number};\n * type MyObjectValues = ObjectValues<MyObject>; // MyObjectValues = string | number\n * @example\n * const myEnumLikeObject = {\n * a: 'foo',\n * b: 'bar'\n * } as const;\n *\n * type myEnumLikeObjectValues = TypescriptHelpersT.ObjectValues<typeof myEnumLikeObject>; // myEnumLikeObjectValues = 'foo' | 'bar'\n * const foo: myEnumLikeObjectValues = 'foo'; // valid\n * const foo2: myEnumLikeObjectValues = 'bar'; // valid\n *\n * const foo3: myEnumLikeObjectValues = 'baz'; // invalid\n */\n export type ObjectValues<T> = T[keyof T];\n\n /**\n * A type that represents an object in which every key starts with \"data-\" and the value is a string, useful for declaring the data-* attributes of an HTML element\n * @example\n * const myObject: DataProps = { 'data-foo': 'bar' }; // valid\n *\n * const myObject2: DataProps = { 'aria-foo': 123 }; // invalid\n * const myObject3: DataProps = { 'foo': 'bar' }; // invalid\n */\n export type DataProps = {\n [key in `data-${string}`]: string;\n };\n /**\n * A type that represents an object in which every key starts with \"aria-\" and the value is a string, useful for declaring the aria-* attributes of an HTML element\n * @example\n * const myObject: AriaProps = { 'aria-foo': 'bar' }; // valid\n *\n * const myObject2: AriaProps = { 'data-foo': 123 }; // invalid\n * const myObject3: AriaProps = { 'foo': 'bar' }; // invalid\n */\n export type AriaProps = {\n [key in `aria-${string}`]: string;\n };\n /**\n * A type that represents an object in which every key starts with \"data-\" or \"aria-\" and the value is a string, useful for declaring the aria-* and data-* attributes of an HTML element\n * @example\n * const myObject: AriaAndDataProps = { 'aria-foo': 'bar' }; // valid\n * const myObject2: AriaAndDataProps = { 'data-foo': 'bar' }; // valid\n * const myObject3: AriaAndDataProps = { 'aria-foo': 'bar', 'data-foo': 'bar' }; // valid\n *\n * const myObject4: AriaAndDataProps = { 'foo': 'bar' }; // invalid\n */\n export type AriaAndDataProps = {\n [key in `data-${string}` | `aria-${string}`]: string;\n };\n\n /**\n * Type helper that excludes keys from one type that exist in another.\n * @example\n * type MyType = ExcludeKeys<{a: string, b: number}, {a: string}>; // MyType = {b: number}\n * type MyType2 = ExcludeKeys<{a: string, b: number}, {a: string, b: number}>; // MyType2 = {}\n * type MyType3 = ExcludeKeys<{a: string, b: number}, {c: string}>; // MyType3 = {a: string, b: number}\n */\n export type ExcludeKeys<T, U> = {\n [K in keyof T as K extends keyof U ? never : K]: T[K];\n };\n\n /** ***************************************************************************\n * Template Literals\n * Snake, Camel, Pascal, Kebab Case\n * https://stackoverflow.com/questions/60269936/typescript-convert-generic-object-from-snake-to-camel-case\n * https://www.typescriptlang.org/play?#code/C4TwDgpgBAygdgQwNYQCoHsDCCC2EA22AzhADwxQQAewEcAJkVEcAE4CWcA5gHxQC8AKCixKNOoygADACQBvTgDMIrKKgC+AfXlKVUAKrqpUAPzDp8jfOxh2wBPnYAvMvGRosuAsTL6ePIygALnMYQUFQSChsPHwMNxQfcjFaBiYWDm4+IREKalTJWQU4ZVUrYtKDQLMRItQUiSYbOwdnMlQ+EygAIk1u4J7u9XkAGXQAdxUAYwQSUg7huRiCeMRE2d8A4xDc8MjoZbj0AAVZmcIN5PzG5jZOXgFohFt7RxdyHgjwaFOic4xDkk8uI0rdMg9+AY4DMXq13jBPvsoL9-ugEhAgQ1QRl7tknrFVu4kvpoc8Wm9XP4vlF0RgUQ5MddsXcso9mq82uQ1h5AZcEZ9qdAANIQABGCFFhPWc2BBXSLIhoSxhR0JT0GgAtKrKoZjDULHINNo5CLxZK0dziVtgqE9t8oAA5R4AFgATHaoqgkABGb2PU0SqUYy7dAAWBHw6G6fAA9DGeuH8JHNON0Kx8PRuoK1D7Xf6xYGLUSQ4nIxrU6xM7H42GI+gU2mM1mkV7vQBmfNmoNJWtJ9DltP0DW0FjRqBxhN1hvp+iaEfAZv21vOzuF9E90v9itD+f9AA+UAA5Ip0P3xaxhxAWIfq5O+9PZ7uoAfuif6+e51eF9nWwBWVfmuulw4qyE4gVwP4+gAbAB3aXFIwDhhqCBwEQkwXuwRBanIDpGLe3SIRAmgoWhKiaJhmhuv0AAUSJOpCboAJQetAqC+o8tKeLEG51mOE69pGi6et6eaQpxvJzAJ9YVk2+GbgA6o2mY-u2HHcgCXgXJJm5zkQ06yeONabqgRCKTOQmsd6K5iepXHeCWU4yZmz49G+mjnnxRl1mZTYua+p4AEIIKwFlqN6-42e4GnccBCq3uBKkwZFKDRfZcwIeGxGoeh5F6fIuFSPhhEAILZSoACSRBUVAtH2vRUBMSxaiun6kKHHB2m8XJvE-q6on4isRbSmQUk+VWhl3smTmhagrodm1mkdSNxmmUpnmTfWwB6dNTWoG2rUDUc9JactXU-m2-XtScZwMg5fZjdG53zYddI3SdpBSSZD0Ci2zoHZxx08X2j2-f1ANvUDU1rYiS7Os94N-LdnX3lt+lVrtv4HcdqXvd0AASZ0tr+-XY3ZuME-d0M-r+z2kxJI0U5GX1Uz+UFY29S0fYzUYw56UEkxzQ3BpJ3PfaztOC0BIt1sz5k-fa5VwGAACuwCoPakJyOYRDcpoMwkJoKAgJo3pBFAcDKzgooqAANNruv60RRuaK6ZvgXb6hNQA8qrKtqxrUByFAADaQpQJwUBG+gihQIrfvq1EsywLZ9OkEKPAALpm3HqsJxAocZ1AnsxgAVOYSI+8A8cB1rIh18wlobCKICm+blvW6wADc5j1zrxYkM3rtgvc3ciJ7JcxuEpdl1AJdQMIc8AKIgkQ7DoHAZuYOvABuKjAObX4QPQUBgKw6CQKwwDsFeC-z7Pk9Ijn-uQA6h-H5r9vuHrGyGxAxut7XOufcUDfwNs7X0bsFQ9wbl-R2v9-5DwSmPO2IhgFETgc7RBCoPZNXEppHwr8WBH3mHieoTJJDoFFAAKwgFMfeXRAGh3DnASOf9o5qCgEnPBMU5hhwAGTDyyFnZOUUyYELfvMAunx1ADFQN7X2udviENoO-ERKUxEbGUcQp+ectH0B4EAA\n **************************************************************************** */\n\n\n export type KebabCaseString<S extends string> = S extends `${infer T}-${infer U}`\n ? `${Lowercase<T>}-${KebabCaseString<U>}`\n : S;\n export type SnakeCaseString<S extends string> = S extends `${infer T}_${infer U}`\n ? `${Lowercase<T>}_${SnakeCaseString<U>}`\n : S;\n /**\n * Converts a string from snake_case to camelCase\n * @example\n * type MyType = SnakeToCamelCase<'foo_bar'>; // MyType = 'fooBar'\n */\n export type SnakeToCamelCase<S extends string> = S extends `${infer T}_${infer U}`\n ? `${T}${Capitalize<SnakeToCamelCase<U>>}`\n : S;\n /**\n * Converts a string from snake_case to PascalCase\n * @example\n * type MyType = SnakeToPascalCase<'foo_bar'>; // MyType = 'FooBar'\n */\n export type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}`\n ? `${T extends Capitalize<T> ? '_' : ''}${Lowercase<T>}${CamelToSnakeCase<U>}`\n : S;\n /**\n * Converts a string from kebab-case to snake_case\n * @example\n * type MyType = KebabToSnakeCase<'foo-bar'>; // MyType = 'foo_bar'\n */\n export type KebabToSnakeCase<S extends string> = S extends `${infer T}-${infer U}`\n ? `${T}_${KebabToSnakeCase<U>}`\n : S;\n /**\n * Converts a string from snake_case to kebab-case\n * @example\n * type MyType = SnakeToKebabCase<'foo_bar'>; // MyType = 'foo-bar'\n */\n export type SnakeToKebabCase<S extends string> = S extends `${infer T}_${infer U}`\n ? `${T}-${SnakeToKebabCase<U>}`\n : S;\n /**\n * Converts a string from camelCase to PascalCase\n * @example\n * type MyType = CamelToPascalCase<'fooBar'>; // MyType = 'FooBar'\n */\n export type CamelToPascalCase<S extends string> = Capitalize<S>;\n /**\n * Converts a string from PascalCase to camelCase\n * @example\n * type MyType = PascalToCamelCase<'FooBar'>; // MyType = 'fooBar'\n */\n export type PascalToCamelCase<S extends string> = Uncapitalize<S>;\n /**\n * Converts a string from PascalCase to snake_case\n * @example\n * type MyType = PascalToSnakeCase<'FooBar'>; // MyType = 'foo_bar'\n */\n export type PascalToSnakeCase<S extends string> = CamelToSnakeCase<Uncapitalize<S>>;\n\n /**\n * Converts a string from snake_case to PascalCase\n * @example\n * type MyType = SnakeToPascalCase<'foo_bar'>; // MyType = 'FooBar'\n */\n export type SnakeToPascalCase<S extends string> = Capitalize<SnakeToCamelCase<S>>;\n\n\n /** ***************************************************************************\n * Template Literals\n * Dimsum specific (internal) helpers\n ****************************************************************************\n */\n export type RemoveDSPrefix<S extends string> = S extends `DS${infer T}` ? T : S;\n export type RemovedsPrefix<S extends string> = S extends `ds${infer T}` ? T : S;\n export type RemoveAnyDSPrefix<S extends string> = S extends `ds${infer T}` ? T : S extends `DS${infer U}` ? U : S;\n export type PropsForSlots<Name extends string, Slots extends Record<string, KebabCaseString<RemoveAnyDSPrefix<string>>>, SharedTypeForEachKey=unknown> = {\n [key in ObjectValues<Slots> as `ds${RemoveDSPrefix<Name>}${SnakeToPascalCase<KebabToSnakeCase<key>>}`]?: SharedTypeForEachKey\n }\n export type PropsForGlobalOnSlots<\n Name extends string,\n Slots extends Record<string, KebabCaseString<RemoveAnyDSPrefix<string>>>,\n > = {\n [key in ObjectValues<Slots> as `ds${RemoveDSPrefix<Name>}${SnakeToPascalCase<KebabToSnakeCase<key>>}`]?:\n | object\n | GenericFunc<unknown, object>\n }\n export type AriaAndDataPropsOrPropsGetter = AriaAndDataProps | (() => AriaAndDataProps);\n\n export type Hydraters<T, Args = unknown> = {\n [key in keyof T as key extends string ? `get${Capitalize<key>}` : key]: (\n ...args: Args extends Array<unknown> ? Args : Args[]\n ) => T[key];\n };\n}\n", "import * as React from 'react';\nexport { React };\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;ACAA,YAAuB;",
6
6
  "names": []
7
7
  }
@@ -330,6 +330,8 @@ export declare namespace TypescriptHelpersT {
330
330
  * https://stackoverflow.com/questions/60269936/typescript-convert-generic-object-from-snake-to-camel-case
331
331
  * https://www.typescriptlang.org/play?#code/C4TwDgpgBAygdgQwNYQCoHsDCCC2EA22AzhADwxQQAewEcAJkVEcAE4CWcA5gHxQC8AKCixKNOoygADACQBvTgDMIrKKgC+AfXlKVUAKrqpUAPzDp8jfOxh2wBPnYAvMvGRosuAsTL6ePIygALnMYQUFQSChsPHwMNxQfcjFaBiYWDm4+IREKalTJWQU4ZVUrYtKDQLMRItQUiSYbOwdnMlQ+EygAIk1u4J7u9XkAGXQAdxUAYwQSUg7huRiCeMRE2d8A4xDc8MjoZbj0AAVZmcIN5PzG5jZOXgFohFt7RxdyHgjwaFOic4xDkk8uI0rdMg9+AY4DMXq13jBPvsoL9-ugEhAgQ1QRl7tknrFVu4kvpoc8Wm9XP4vlF0RgUQ5MddsXcso9mq82uQ1h5AZcEZ9qdAANIQABGCFFhPWc2BBXSLIhoSxhR0JT0GgAtKrKoZjDULHINNo5CLxZK0dziVtgqE9t8oAA5R4AFgATHaoqgkABGb2PU0SqUYy7dAAWBHw6G6fAA9DGeuH8JHNON0Kx8PRuoK1D7Xf6xYGLUSQ4nIxrU6xM7H42GI+gU2mM1mkV7vQBmfNmoNJWtJ9DltP0DW0FjRqBxhN1hvp+iaEfAZv21vOzuF9E90v9itD+f9AA+UAA5Ip0P3xaxhxAWIfq5O+9PZ7uoAfuif6+e51eF9nWwBWVfmuulw4qyE4gVwP4+gAbAB3aXFIwDhhqCBwEQkwXuwRBanIDpGLe3SIRAmgoWhKiaJhmhuv0AAUSJOpCboAJQetAqC+o8tKeLEG51mOE69pGi6et6eaQpxvJzAJ9YVk2+GbgA6o2mY-u2HHcgCXgXJJm5zkQ06yeONabqgRCKTOQmsd6K5iepXHeCWU4yZmz49G+mjnnxRl1mZTYua+p4AEIIKwFlqN6-42e4GnccBCq3uBKkwZFKDRfZcwIeGxGoeh5F6fIuFSPhhEAILZSoACSRBUVAtH2vRUBMSxaiun6kKHHB2m8XJvE-q6on4isRbSmQUk+VWhl3smTmhagrodm1mkdSNxmmUpnmTfWwB6dNTWoG2rUDUc9JactXU-m2-XtScZwMg5fZjdG53zYddI3SdpBSSZD0Ci2zoHZxx08X2j2-f1ANvUDU1rYiS7Os94N-LdnX3lt+lVrtv4HcdqXvd0AASZ0tr+-XY3ZuME-d0M-r+z2kxJI0U5GX1Uz+UFY29S0fYzUYw56UEkxzQ3BpJ3PfaztOC0BIt1sz5k-fa5VwGAACuwCoPakJyOYRDcpoMwkJoKAgJo3pBFAcDKzgooqAANNruv60RRuaK6ZvgXb6hNQA8qrKtqxrUByFAADaQpQJwUBG+gihQIrfvq1EsywLZ9OkEKPAALpm3HqsJxAocZ1AnsxgAVOYSI+8A8cB1rIh18wlobCKICm+blvW6wADc5j1zrxYkM3rtgvc3ciJ7JcxuEpdl1AJdQMIc8AKIgkQ7DoHAZuYOvABuKjAObX4QPQUBgKw6CQKwwDsFeC-z7Pk9Ijn-uQA6h-H5r9vuHrGyGxAxut7XOufcUDfwNs7X0bsFQ9wbl-R2v9-5DwSmPO2IhgFETgc7RBCoPZNXEppHwr8WBH3mHieoTJJDoFFAAKwgFMfeXRAGh3DnASOf9o5qCgEnPBMU5hhwAGTDyyFnZOUUyYELfvMAunx1ADFQN7X2udviENoO-ERKUxEbGUcQp+ectH0B4EAA
332
332
  **************************************************************************** */
333
+ type KebabCaseString<S extends string> = S extends `${infer T}-${infer U}` ? `${Lowercase<T>}-${KebabCaseString<U>}` : S;
334
+ type SnakeCaseString<S extends string> = S extends `${infer T}_${infer U}` ? `${Lowercase<T>}_${SnakeCaseString<U>}` : S;
333
335
  /**
334
336
  * Converts a string from snake_case to camelCase
335
337
  * @example
@@ -384,8 +386,13 @@ export declare namespace TypescriptHelpersT {
384
386
  ****************************************************************************
385
387
  */
386
388
  type RemoveDSPrefix<S extends string> = S extends `DS${infer T}` ? T : S;
387
- type PropsForGlobalOnSlots<Name extends string, Slots extends Record<string, string>> = {
388
- [key in ObjectValues<Slots> as `ds${RemoveDSPrefix<Name>}${SnakeToPascalCase<KebabToSnakeCase<key>>}`]?: object | ((arg: object) => object);
389
+ type RemovedsPrefix<S extends string> = S extends `ds${infer T}` ? T : S;
390
+ type RemoveAnyDSPrefix<S extends string> = S extends `ds${infer T}` ? T : S extends `DS${infer U}` ? U : S;
391
+ type PropsForSlots<Name extends string, Slots extends Record<string, KebabCaseString<RemoveAnyDSPrefix<string>>>, SharedTypeForEachKey = unknown> = {
392
+ [key in ObjectValues<Slots> as `ds${RemoveDSPrefix<Name>}${SnakeToPascalCase<KebabToSnakeCase<key>>}`]?: SharedTypeForEachKey;
393
+ };
394
+ type PropsForGlobalOnSlots<Name extends string, Slots extends Record<string, KebabCaseString<RemoveAnyDSPrefix<string>>>> = {
395
+ [key in ObjectValues<Slots> as `ds${RemoveDSPrefix<Name>}${SnakeToPascalCase<KebabToSnakeCase<key>>}`]?: object | GenericFunc<unknown, object>;
389
396
  };
390
397
  type AriaAndDataPropsOrPropsGetter = AriaAndDataProps | (() => AriaAndDataProps);
391
398
  type Hydraters<T, Args = unknown> = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-typescript-helpers",
3
- "version": "3.54.0-next.4",
3
+ "version": "3.54.0-next.6",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Typescript helpers",
6
6
  "files": [
@@ -35,7 +35,7 @@
35
35
  "devDependencies": {
36
36
  "@elliemae/pui-cli": "9.0.0-next.65",
37
37
  "jest": "~29.7.0",
38
- "@elliemae/ds-monorepo-devops": "3.54.0-next.4"
38
+ "@elliemae/ds-monorepo-devops": "3.54.0-next.6"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public",