@itcase/ui-core 1.10.44 → 1.10.47

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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) ITCase
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,3 +1,4 @@
1
+ export type { DeviceBreakpoint, WithDeviceProps, WithDeviceVariants, } from '../types';
1
2
  export * from './useActiveClasses';
2
3
  export * from './useAppearanceConfig';
3
4
  export * from './useDevicePropsGenerator';
@@ -0,0 +1,5 @@
1
+ export type ExactlyOne<K extends PropertyKey, V> = {
2
+ [P in K]: Partial<Record<Exclude<K, P>, never>> & {
3
+ [Q in P]: V;
4
+ };
5
+ }[K];
@@ -1 +1,5 @@
1
- export * from './utils';
1
+ export * from './exactlyOne';
2
+ export * from './kebabCase';
3
+ export * from './requireAtLeastOneProp';
4
+ export * from './withClassKeys';
5
+ export * from './withDeviceProps';
@@ -0,0 +1 @@
1
+ export type KebabCase<S> = S extends string ? S extends `${infer F}${infer R}` ? R extends Uncapitalize<R> ? `${Lowercase<F>}${KebabCase<R>}` : `${Lowercase<F>}-${KebabCase<Uncapitalize<R>>}` : Lowercase<S> : never;
@@ -1,12 +1,3 @@
1
- export type ExactlyOne<K extends PropertyKey, V> = {
2
- [P in K]: Partial<Record<Exclude<K, P>, never>> & {
3
- [Q in P]: V;
4
- };
5
- }[K];
6
- export type WithClassKeys<T> = T & {
7
- [K in keyof T & string as `${K}Class`]: NonNullable<T[K]> extends string ? KebabCase<T[K]> | undefined : string | undefined;
8
- };
9
- export type KebabCase<S> = S extends string ? S extends `${infer F}${infer R}` ? R extends Uncapitalize<R> ? `${Lowercase<F>}${KebabCase<R>}` : `${Lowercase<F>}-${KebabCase<Uncapitalize<R>>}` : Lowercase<S> : never;
10
1
  /**
11
2
  * Проверяет, что у типа `P` есть хотя бы один ключ из списка `Keys`.
12
3
  *
@@ -0,0 +1,4 @@
1
+ import type { KebabCase } from './kebabCase';
2
+ export type WithClassKeys<T> = T & {
3
+ [K in keyof T & string as `${K}Class`]: NonNullable<T[K]> extends string ? KebabCase<T[K]> | undefined : string | undefined;
4
+ };
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Device suffixes that `useStyles` / `useDevicePropsGenerator` resolve at runtime.
3
+ */
4
+ export type DeviceBreakpoint = 'Desktop' | 'Mobile' | 'Tablet';
5
+ /**
6
+ * Adds `Mobile` / `Tablet` / `Desktop` variants for keys of `T`, keeping the base keys.
7
+ * Pass responsive props into the wrapper; keep the rest outside.
8
+ *
9
+ * @example
10
+ * type Props = WithDeviceProps<{
11
+ * flow?: string
12
+ * fill?: FillProps
13
+ * }> & {
14
+ * dataTestId?: string // no Mobile/Tablet/Desktop
15
+ * }
16
+ * // flow | flowMobile | flowTablet | flowDesktop | fill | ... | dataTestId
17
+ */
18
+ export type WithDeviceProps<T> = T & WithDeviceVariants<T>;
19
+ /**
20
+ * Only `Mobile` / `Tablet` / `Desktop` keys — without the base props.
21
+ * Use when the base type comes from elsewhere (e.g. `StyleAttributes`)
22
+ * and device variants use a different token type.
23
+ *
24
+ * @example
25
+ * type Props = StyleAttributes & WithDeviceVariants<{
26
+ * alignSelf?: AlignProps
27
+ * }>
28
+ * // alignSelf from StyleAttributes (CSS)
29
+ * // alignSelfMobile | alignSelfTablet | alignSelfDesktop as AlignProps
30
+ */
31
+ export type WithDeviceVariants<T> = {
32
+ [K in keyof T & string as `${K}${DeviceBreakpoint}`]?: T[K];
33
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/ui-core",
3
- "version": "1.10.44",
3
+ "version": "1.10.47",
4
4
  "description": "UI shared components",
5
5
  "keywords": [
6
6
  "Modal",
@@ -64,7 +64,7 @@
64
64
  "dependencies": {
65
65
  "@emotion/is-prop-valid": "^1.4.0",
66
66
  "@itcase/common": "^1.2.47",
67
- "@itcase/storybook-config": "^1.2.78",
67
+ "@itcase/storybook-config": "^1.2.79",
68
68
  "clsx": "^2.1.1",
69
69
  "lodash": "^4.18.1",
70
70
  "react": "^18.3.1",
@@ -76,7 +76,7 @@
76
76
  "@babel/core": "^8.0.1",
77
77
  "@babel/preset-react": "^8.0.1",
78
78
  "@itcase/types-core": "^1.1.74",
79
- "@itcase/types-ui": "^1.1.86",
79
+ "@itcase/types-ui": "^1.1.89",
80
80
  "@rollup/plugin-alias": "^6.0.0",
81
81
  "@rollup/plugin-babel": "^7.1.0",
82
82
  "@rollup/plugin-commonjs": "^29.0.3",
@@ -96,5 +96,5 @@
96
96
  "rollup-plugin-peer-deps-external": "^2.2.4",
97
97
  "rollup-preserve-directives": "^1.1.3"
98
98
  },
99
- "gitHead": "3a0689728e87da68aee490168736f9c79ae52b05"
99
+ "gitHead": "09306c0d4781521c6c7059638852274291cd06a7"
100
100
  }