@aic-kits/react 0.16.8 → 0.17.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.
@@ -33,6 +33,7 @@ export type ResponsiveValue<T> = Omit<Partial<Record<ResponsiveKey, T>>, 'xs'> &
33
33
  * @public
34
34
  */
35
35
  export type WithResponsiveValue<T> = T | ResponsiveValue<T>;
36
+ export type NonResponsiveValue<T> = T extends WithResponsiveValue<infer U> ? U : T;
36
37
  /**
37
38
  * A higher-order type that converts a record of values to a record of responsive values.
38
39
  * @public
@@ -55,6 +56,34 @@ export declare const isResponsiveValue: <T>(value: WithResponsiveValue<T>) => va
55
56
  * @returns The transformed value.
56
57
  */
57
58
  export declare const transformResponsiveValue: <SourceType, TargetType>(value: WithResponsiveValue<SourceType>, transform: (value: SourceType) => TargetType) => WithResponsiveValue<TargetType>;
59
+ /**
60
+ * Transposes a record of responsive values.
61
+ * @public
62
+ * @param obj - The object to transpose.
63
+ * @returns The transposed object.
64
+ * @example
65
+ * ```ts
66
+ * const obj = {
67
+ * xs: {
68
+ * fontSize: 10,
69
+ * },
70
+ * sm: {
71
+ * fontSize: 20,
72
+ * },
73
+ * };
74
+ * const transposedObj = transposeObject(obj);
75
+ * // { fontSize: { xs: 10, sm: 20 } }
76
+ * ```
77
+ */
78
+ export declare const transposeObject: <SourceValueType extends Record<string, Record<string, unknown>>, TargetValueType extends Record<string, Record<string, unknown>>>(obj: SourceValueType) => TargetValueType;
79
+ /**
80
+ * Infer responsive values from a record of values.
81
+ * @public
82
+ * @param values - The values to infer responsive values from.
83
+ * @param transform - The transform function.
84
+ * @returns The inferred responsive values.
85
+ */
86
+ export declare const inferResponsiveValues: <SourceTransformValuesType, TargetTransformValuesType, SourceValuesType extends { [K in keyof SourceTransformValuesType]: WithResponsiveValue<SourceTransformValuesType[K]>; } = { [K in keyof SourceTransformValuesType]: WithResponsiveValue<SourceTransformValuesType[K]>; }, TargetValuesType extends { [K in keyof TargetTransformValuesType]: { [P in ResponsiveKey]: TargetTransformValuesType[K]; }; } = { [K in keyof TargetTransformValuesType]: { [P in ResponsiveKey]: TargetTransformValuesType[K]; }; }>(values: SourceValuesType, infer: (values: SourceTransformValuesType) => TargetTransformValuesType) => TargetValuesType;
58
87
  /**
59
88
  * Gets the responsive value for a given breakpoint.
60
89
  * @public
@@ -68,8 +97,37 @@ export declare const getResponsiveValue: <T>(value: WithResponsiveValue<T>, brea
68
97
  * @public
69
98
  * @param responsiveValue - The responsive value to populate.
70
99
  * @returns The populated responsive value.
100
+ * @example
101
+ * ```ts
102
+ * const responsiveValue = {
103
+ * xs: 10,
104
+ * md: 30,
105
+ * xl: 50,
106
+ * };
107
+ * const populatedResponsiveValue = populateResponsiveValue(responsiveValue);
108
+ * // { xs: 10, sm: 10, md: 30, lg: 30, xl: 50 }
109
+ * ```
110
+ */
111
+ export declare const populateResponsiveValue: <T>(responsiveValue: WithResponsiveValue<T>) => Record<ResponsiveKey, T>;
112
+ /**
113
+ * Reduces a responsive value to a single value.
114
+ * @public
115
+ * @param responsiveValue - The responsive value to reduce.
116
+ * @returns The reduced responsive value.
117
+ * @example
118
+ * ```ts
119
+ * const responsiveValue = {
120
+ * xs: 10,
121
+ * sm: 10,
122
+ * md: 30,
123
+ * lg: 30,
124
+ * xl: 50,
125
+ * };
126
+ * const reducedResponsiveValue = reduceResponsiveValue(responsiveValue);
127
+ * // { xs: 10, md: 30, xl: 50 }
128
+ * ```
71
129
  */
72
- export declare const populateResponsiveValue: <T extends object>(responsiveValue: WithResponsiveValue<T>) => Record<ResponsiveKey, T>;
130
+ export declare const reduceResponsiveValue: <T>(responsiveValue: Record<ResponsiveKey, T>) => WithResponsiveValue<T>;
73
131
  /**
74
132
  * Generates responsive styles for a given object.
75
133
  * @public
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aic-kits/react",
3
- "version": "0.16.8",
3
+ "version": "0.17.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -46,5 +46,5 @@
46
46
  "vite-plugin-dts": "^4.3.0",
47
47
  "vitest": "^2.1.8"
48
48
  },
49
- "gitHead": "57f3c32c4a2f81beb6f4fb4ec32f85dfeabc53c3"
49
+ "gitHead": "f93460af34343f41c04e85c478f7a20104b86db7"
50
50
  }