@itcase/ui-core 1.10.47 → 1.10.48

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.
Files changed (64) hide show
  1. package/dist/cjs/context/Notifications.interface.js +2 -1
  2. package/dist/cjs/context/Notifications.js +207 -1
  3. package/dist/cjs/context/UIContext.js +76 -1
  4. package/dist/cjs/context/UrlAssetPrefix.js +17 -1
  5. package/dist/cjs/context/index.js +24 -1
  6. package/dist/cjs/hoc/index.js +11 -1
  7. package/dist/cjs/hoc/urlWithAssetPrefix.js +78 -1
  8. package/dist/cjs/hooks/index.js +37 -1
  9. package/dist/cjs/hooks/useActiveClasses/index.js +9 -1
  10. package/dist/cjs/hooks/useActiveClasses/useActiveClasses.helpers.js +93 -1
  11. package/dist/cjs/hooks/useActiveClasses/useActiveClasses.interface.js +65 -1
  12. package/dist/cjs/hooks/useActiveClasses/useActiveClasses.js +60 -1
  13. package/dist/cjs/hooks/useAppearanceConfig/index.js +8 -1
  14. package/dist/cjs/hooks/useAppearanceConfig/useAppearanceConfig.js +30 -1
  15. package/dist/cjs/hooks/useDevicePropsGenerator/index.js +23 -1
  16. package/dist/cjs/hooks/useDevicePropsGenerator/useDevicePropsGenerator.interface.js +2 -1
  17. package/dist/cjs/hooks/useDevicePropsGenerator/useDevicePropsGenerator.js +236 -1
  18. package/dist/cjs/hooks/useDeviceTargetClass.js +64 -1
  19. package/dist/cjs/hooks/useMediaQueries/index.js +9 -1
  20. package/dist/cjs/hooks/useMediaQueries/useMediaQueries.js +124 -1
  21. package/dist/cjs/hooks/useStyles/index.js +23 -1
  22. package/dist/cjs/hooks/useStyles/styleAttributes.helpers.js +9 -1
  23. package/dist/cjs/hooks/useStyles/styleAttributes.interface.js +2 -1
  24. package/dist/cjs/hooks/useStyles/styleAttributes.js +177 -1
  25. package/dist/cjs/hooks/useStyles/useStyles.js +224 -1
  26. package/dist/cjs/hooks/useViewportFix.js +43 -1
  27. package/dist/cjs/utils/index.js +9 -1
  28. package/dist/cjs/utils/mergeAppearanceKeys.js +18 -1
  29. package/dist/cjs/utils/setViewportProperty.js +8 -1
  30. package/dist/context/Notifications.js +202 -1
  31. package/dist/context/UIContext.js +73 -1
  32. package/dist/context/UrlAssetPrefix.js +14 -1
  33. package/dist/context/index.js +11 -1
  34. package/dist/hoc/index.js +5 -1
  35. package/dist/hoc/urlWithAssetPrefix.js +76 -1
  36. package/dist/hooks/index.js +24 -1
  37. package/dist/hooks/useActiveClasses/index.js +3 -1
  38. package/dist/hooks/useActiveClasses/useActiveClasses.helpers.js +89 -1
  39. package/dist/hooks/useActiveClasses/useActiveClasses.interface.js +63 -1
  40. package/dist/hooks/useActiveClasses/useActiveClasses.js +58 -1
  41. package/dist/hooks/useAppearanceConfig/index.js +2 -1
  42. package/dist/hooks/useAppearanceConfig/useAppearanceConfig.js +28 -1
  43. package/dist/hooks/useDevicePropsGenerator/index.js +17 -1
  44. package/dist/hooks/useDevicePropsGenerator/useDevicePropsGenerator.js +234 -1
  45. package/dist/hooks/useDeviceTargetClass.js +62 -1
  46. package/dist/hooks/useMediaQueries/index.js +3 -1
  47. package/dist/hooks/useMediaQueries/useMediaQueries.js +122 -1
  48. package/dist/hooks/useStyles/index.js +16 -1
  49. package/dist/hooks/useStyles/styleAttributes.helpers.js +7 -1
  50. package/dist/hooks/useStyles/styleAttributes.js +173 -1
  51. package/dist/hooks/useStyles/useStyles.js +222 -1
  52. package/dist/hooks/useViewportFix.js +41 -1
  53. package/dist/types/context/Notifications.d.ts +8 -8
  54. package/dist/types/hoc/urlWithAssetPrefix.d.ts +2 -3
  55. package/dist/types/hooks/useActiveClasses/useActiveClasses.interface.d.ts +4 -4
  56. package/dist/types/hooks/useAppearanceConfig/useAppearanceConfig.d.ts +1 -1
  57. package/dist/types/hooks/useDevicePropsGenerator/useDevicePropsGenerator.d.ts +1 -1
  58. package/dist/types/hooks/useDeviceTargetClass.d.ts +2 -1
  59. package/dist/types/hooks/useMediaQueries/useMediaQueries.d.ts +2 -1
  60. package/dist/types/hooks/useStyles/styleAttributes.helpers.d.ts +1 -1
  61. package/dist/utils/index.js +2 -1
  62. package/dist/utils/mergeAppearanceKeys.js +16 -1
  63. package/dist/utils/setViewportProperty.js +6 -1
  64. package/package.json +2 -2
@@ -1 +1,173 @@
1
- var o=["alignContent","alignItems","alignSelf","aspectRatio","border","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","borderWidth","bottom","display","flex","flexBasis","flexDirection","flexGrow","flexShrink","flexWrap","gap","rowGap","columnGap","columnWidth","height","justifyContent","left","margin","marginBottom","marginHorizontal","marginLeft","marginRight","marginTop","marginVertical","maxHeight","maxWidth","minHeight","minWidth","overflow","overflowY","overflowX","padding","paddingBottom","paddingEnd","paddingHorizontal","paddingLeft","paddingRight","paddingStart","paddingTop","paddingVertical","position","right","top",["width",{validate:o=>/\d+/.test(o)}],"zIndex","order","shadowColor","shadowOffset","shadowOpacity","shadowRadius","transform","background","backgroundColor","borderBottomColor","borderBottomEndRadius","borderBottomLeftRadius","borderBottomRightRadius","borderBottomStartRadius","borderColor","borderCurve","borderEndColor","borderLeftColor","borderRadius","borderRightColor","borderStartColor","borderStyle","borderTopColor","borderTopEndRadius","borderTopLeftRadius","borderTopRightRadius","borderTopStartRadius","opacity","cursor","color","fontFamily","fontSize","fontStyle","fontVariant","fontWeight","letterSpacing","lineHeight","textAlign","textDecorationColor","textDecorationLine","textDecorationStyle","textShadowColor","textShadowOffset","textShadowRadius","textTransform","verticalAlign","writingMode","whiteSpace","overlayColor","resizeMode","tintColor","objectFit","objectPosition","gridTemplateColumns","gridArea","gridAutoColumns","gridAutoFlow","gridAutoRows","gridTemplate","gridTemplateAreas","gridTemplateRows","gridColumn","gridColumnStart","gridColumnEnd","gridColumnGap","gridRow","gridRowStart","gridRowEnd","gridRowGap","backdropFilter","transition","transitionBehavior","transitionDelay","transitionDuration","transitionProperty","transitionTimingFunction","pointerEvents"];export{o as default};
1
+ var styleAttributes = [
2
+ /**
3
+ * Layout
4
+ */
5
+ 'alignContent',
6
+ 'alignItems',
7
+ 'alignSelf',
8
+ 'aspectRatio',
9
+ 'border',
10
+ 'borderBottomWidth',
11
+ 'borderLeftWidth',
12
+ 'borderRightWidth',
13
+ 'borderTopWidth',
14
+ 'borderWidth',
15
+ 'bottom',
16
+ 'display',
17
+ 'flex',
18
+ 'flexBasis',
19
+ 'flexDirection',
20
+ 'flexGrow',
21
+ 'flexShrink',
22
+ 'flexWrap',
23
+ 'gap',
24
+ 'rowGap',
25
+ 'columnGap',
26
+ 'columnWidth',
27
+ 'height',
28
+ 'justifyContent',
29
+ 'left',
30
+ 'margin',
31
+ 'marginBottom',
32
+ 'marginHorizontal',
33
+ 'marginLeft',
34
+ 'marginRight',
35
+ 'marginTop',
36
+ 'marginVertical',
37
+ 'maxHeight',
38
+ 'maxWidth',
39
+ 'minHeight',
40
+ 'minWidth',
41
+ 'overflow',
42
+ 'overflowY',
43
+ 'overflowX',
44
+ 'padding',
45
+ 'paddingBottom',
46
+ 'paddingEnd',
47
+ 'paddingHorizontal',
48
+ 'paddingLeft',
49
+ 'paddingRight',
50
+ 'paddingStart',
51
+ 'paddingTop',
52
+ 'paddingVertical',
53
+ 'position',
54
+ 'right',
55
+ 'top',
56
+ [
57
+ 'width',
58
+ {
59
+ validate: (value) => {
60
+ // Pass only number value for "width" style.
61
+ // If width have custom value, like "fill", we must set class by this value.
62
+ // "\d" - digit; "+" - 1 or more
63
+ return /\d+/.test(value);
64
+ },
65
+ },
66
+ ],
67
+ 'zIndex',
68
+ 'order',
69
+ /**
70
+ * Shadow
71
+ */
72
+ 'shadowColor',
73
+ 'shadowOffset',
74
+ 'shadowOpacity',
75
+ 'shadowRadius',
76
+ /**
77
+ * Transform
78
+ */
79
+ 'transform',
80
+ /**
81
+ * View
82
+ */
83
+ 'background',
84
+ 'backgroundColor',
85
+ 'borderBottomColor',
86
+ 'borderBottomEndRadius',
87
+ 'borderBottomLeftRadius',
88
+ 'borderBottomRightRadius',
89
+ 'borderBottomStartRadius',
90
+ 'borderColor',
91
+ 'borderCurve',
92
+ 'borderEndColor',
93
+ 'borderLeftColor',
94
+ 'borderRadius',
95
+ 'borderRightColor',
96
+ 'borderStartColor',
97
+ 'borderStyle',
98
+ 'borderTopColor',
99
+ 'borderTopEndRadius',
100
+ 'borderTopLeftRadius',
101
+ 'borderTopRightRadius',
102
+ 'borderTopStartRadius',
103
+ 'opacity',
104
+ 'cursor',
105
+ /**
106
+ * Text
107
+ */
108
+ 'color',
109
+ 'fontFamily',
110
+ 'fontSize',
111
+ 'fontStyle',
112
+ 'fontVariant',
113
+ 'fontWeight',
114
+ 'letterSpacing',
115
+ 'lineHeight',
116
+ 'textAlign',
117
+ 'textDecorationColor',
118
+ 'textDecorationLine',
119
+ 'textDecorationStyle',
120
+ 'textShadowColor',
121
+ 'textShadowOffset',
122
+ 'textShadowRadius',
123
+ 'textTransform',
124
+ 'verticalAlign',
125
+ 'writingMode',
126
+ 'whiteSpace',
127
+ /**
128
+ * Image
129
+ */
130
+ 'overlayColor',
131
+ 'resizeMode',
132
+ 'tintColor',
133
+ 'objectFit',
134
+ 'objectPosition',
135
+ /**
136
+ * Grid
137
+ */
138
+ 'gridTemplateColumns',
139
+ 'gridArea',
140
+ 'gridAutoColumns',
141
+ 'gridAutoFlow',
142
+ 'gridAutoRows',
143
+ 'gridTemplate',
144
+ 'gridTemplateAreas',
145
+ 'gridTemplateRows',
146
+ 'gridColumn',
147
+ 'gridColumnStart',
148
+ 'gridColumnEnd',
149
+ 'gridColumnGap',
150
+ 'gridRow',
151
+ 'gridRowStart',
152
+ 'gridRowEnd',
153
+ 'gridRowGap',
154
+ /**
155
+ * Filter
156
+ */
157
+ 'backdropFilter',
158
+ /**
159
+ * Transition
160
+ */
161
+ 'transition',
162
+ 'transitionBehavior',
163
+ 'transitionDelay',
164
+ 'transitionDuration',
165
+ 'transitionProperty',
166
+ 'transitionTimingFunction',
167
+ /**
168
+ * Control
169
+ */
170
+ 'pointerEvents',
171
+ ];
172
+
173
+ export { styleAttributes as default };
@@ -1 +1,222 @@
1
- import{useMemo as e}from"react";import t from"lodash/camelCase";import r from"lodash/maxBy";import i from"lodash/upperFirst";import"../../context/Notifications.js";import{useUserDeviceContext as o}from"../../context/UIContext.js";import"../../context/UrlAssetPrefix.js";import s from"./styleAttributes.js";import{getStyleAttributeKey as n}from"./styleAttributes.helpers.js";import"react/jsx-runtime";import"uuid";import"@itcase/common";import"../useMediaQueries/useMediaQueries.js";import"react-responsive";import"../../utils/setViewportProperty.js";function l(r){const{deviceCurrentMainType:s,deviceCurrentType:n,deviceTypesList:l}=o(),c=e(()=>Object.entries(r).reduce((e,[t,r])=>(p(t,r)&&(e[t]=r),e),{}),[r]);return e(()=>{const e={};for(const[o,m]of Object.entries(c)){let c=null;const u=p(o,m),d=o.toLowerCase().endsWith(n.toLowerCase()),f=a(o.replace(u,""),l),j=t(f)||"styles";if(e[j]||(e[j]={}),d)c=m;else{const t=`${u}${f}`,o=`${t}${i(s)}`,n=r[o]||r[t];let l=e[j][u];if(t.includes("Horizontal")){const t=u.replace("Horizontal","Left");l=e[j][t]}else if(t.includes("Vertical")){const t=u.replace("Vertical","Top");l=e[j][t]}l||(c=n)}if(c){if(/\D/.test(c)){if(/\d+\.?\d*m\s?(?![a-zA-Z]+)/.test(c)){const e=c.split(" ").map(e=>{const t=e.replace(/[a-z]/gi,"");return`${8*parseFloat(t)}px`},[]);c=e.join(" ")}}else{["flexGrow","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","opacity","order","zIndex"].includes(u)||(c=`${c}px`)}if(u.includes("Horizontal")){const t=u.replace("Horizontal","Right"),r=u.replace("Horizontal","Left"),i=c.split(" "),o=i[0],s=i[1]||i[0];e[j][t]=o,e[j][r]=s}else if(u.includes("Vertical")){const t=u.replace("Vertical","Top"),r=u.replace("Vertical","Bottom"),i=c.split(" "),o=i[0],s=i[1]||i[0];e[j][t]=o,e[j][r]=s}else e[j][u]=c}}return e},[s,n,...Object.values(c)])}const a=(e,t)=>t.reduce((e,t)=>e.endsWith(i(t))?e.replace(i(t),""):e,e),c=new Map,p=(e,t="")=>{const i=`${e}_${t}`;if(c.has(i))return c.get(i);const o=s.filter(r=>{if(Array.isArray(r)){const i=r[0],o=r[1]||{};return!!e.startsWith(i)&&(!o.validate||o.validate(t))}return e.startsWith(String(r))}),l=r(o,e=>n(e).length),a=n(l);return c.set(i,a),a};export{l as useStyles};
1
+ import { useMemo } from 'react';
2
+ import camelCase from 'lodash/camelCase';
3
+ import maxBy from 'lodash/maxBy';
4
+ import upperFirst from 'lodash/upperFirst';
5
+ import '../../context/Notifications.js';
6
+ import { useUserDeviceContext } from '../../context/UIContext.js';
7
+ import '../../context/UrlAssetPrefix.js';
8
+ import styleAttributes from './styleAttributes.js';
9
+ import { getStyleAttributeKey } from './styleAttributes.helpers.js';
10
+ import 'react/jsx-runtime';
11
+ import 'uuid';
12
+ import '@itcase/common';
13
+ import '../useMediaQueries/useMediaQueries.js';
14
+ import 'react-responsive';
15
+ import '../../utils/setViewportProperty.js';
16
+
17
+ /*
18
+ * rule of prop key:
19
+ *
20
+ * first is style second is div target third is device
21
+ * paddingHorizontal GridInnerWrapper MobileNormal
22
+ *
23
+ * paddingHorizontalGridInnerWrapperMobileNormal: "10px"
24
+ */
25
+ function useStyles(props) {
26
+ const { deviceCurrentMainType, deviceCurrentType, deviceTypesList } = useUserDeviceContext();
27
+ const propsStyleAttributes = useMemo(() => {
28
+ const styles = Object.entries(props).reduce((result, [propKey, propValue]) => {
29
+ const styleAttributeKey = getTargetStyleAttributeKey(propKey, propValue);
30
+ if (styleAttributeKey) {
31
+ result[propKey] = propValue;
32
+ }
33
+ return result;
34
+ }, {});
35
+ return styles;
36
+ // "props" object maybe big and frequently changing
37
+ }, [props]);
38
+ const collectedStyles = useMemo(() => {
39
+ const resultStylesGroups = {};
40
+ for (const [propKey, propValue] of Object.entries(propsStyleAttributes)) {
41
+ let value = null;
42
+ const styleAttributeKey = getTargetStyleAttributeKey(propKey, propValue);
43
+ const isStyleForCurrentDevice = propKey
44
+ .toLowerCase()
45
+ .endsWith(deviceCurrentType.toLowerCase());
46
+ // e.g. "GridWrapperInner"
47
+ const targetElementKey = removeDeviceType(propKey.replace(styleAttributeKey, ''), deviceTypesList);
48
+ const targetElementGroupKey = camelCase(targetElementKey) || 'styles';
49
+ if (!resultStylesGroups[targetElementGroupKey]) {
50
+ resultStylesGroups[targetElementGroupKey] = {};
51
+ }
52
+ if (isStyleForCurrentDevice) {
53
+ value = propValue;
54
+ }
55
+ else {
56
+ const propKeyWithOutDeviceType = `${styleAttributeKey}${targetElementKey}`;
57
+ const propKeyWithBaseDeviceType = `${propKeyWithOutDeviceType}${upperFirst(deviceCurrentMainType)}`;
58
+ const defaultValue = props[propKeyWithBaseDeviceType] || props[propKeyWithOutDeviceType];
59
+ let currentValue = resultStylesGroups[targetElementGroupKey][styleAttributeKey];
60
+ if (propKeyWithOutDeviceType.includes('Horizontal')) {
61
+ const keyLeft = styleAttributeKey.replace('Horizontal', 'Left');
62
+ currentValue =
63
+ resultStylesGroups[targetElementGroupKey][keyLeft];
64
+ }
65
+ else if (propKeyWithOutDeviceType.includes('Vertical')) {
66
+ const keyTop = styleAttributeKey.replace('Vertical', 'Top');
67
+ currentValue =
68
+ resultStylesGroups[targetElementGroupKey][keyTop];
69
+ }
70
+ if (!currentValue) {
71
+ value = defaultValue;
72
+ }
73
+ }
74
+ if (value) {
75
+ // Check not digit symbols. Chars means some unit ("px", "em", "rem" or custom "m")
76
+ const isValueHasUnit = /\D/.test(value);
77
+ // If value has some unit
78
+ if (isValueHasUnit) {
79
+ // Check value on our custom "m"(module) unit
80
+ /** Pattern for:
81
+ * 1m
82
+ * 1.5m
83
+ * 1m 1m 1.5m
84
+ * 0 0 1m 1m
85
+ */
86
+ const isValueHasModuleUnit = /\d+\.?\d*m\s?(?![a-zA-Z]+)/.test(value);
87
+ // If value has module unit
88
+ if (isValueHasModuleUnit) {
89
+ /** Order for shorthand properties:
90
+ * top
91
+ * right
92
+ * bottom
93
+ * left
94
+ * or:
95
+ * top
96
+ * right and left
97
+ * bottom
98
+ * or:
99
+ * top and bottom
100
+ * right and left
101
+ */
102
+ const valuePxPartsList = value
103
+ .split(' ')
104
+ .map((valuePart) => {
105
+ const valueModule = valuePart.replace(/[a-z]/gi, '');
106
+ const valuePx = parseFloat(valueModule) * 8;
107
+ return `${valuePx}px`;
108
+ }, []);
109
+ value = valuePxPartsList.join(' ');
110
+ }
111
+ }
112
+ else {
113
+ // Some properties doesn't have any units
114
+ const ignorePX = [
115
+ 'flexGrow',
116
+ 'gridColumn',
117
+ 'gridColumnEnd',
118
+ 'gridColumnStart',
119
+ 'gridRow',
120
+ 'gridRowEnd',
121
+ 'gridRowStart',
122
+ 'opacity',
123
+ 'order',
124
+ 'zIndex',
125
+ ].includes(styleAttributeKey);
126
+ if (!ignorePX) {
127
+ // Add px to non-unit value
128
+ value = `${value}px`;
129
+ }
130
+ }
131
+ if (styleAttributeKey.includes('Horizontal')) {
132
+ const keyRight = styleAttributeKey.replace('Horizontal', 'Right');
133
+ const keyLeft = styleAttributeKey.replace('Horizontal', 'Left');
134
+ const valuePartsList = value.split(' ');
135
+ const valueRight = valuePartsList[0];
136
+ const valueLeft = valuePartsList[1] || valuePartsList[0];
137
+ resultStylesGroups[targetElementGroupKey][keyRight] = valueRight;
138
+ resultStylesGroups[targetElementGroupKey][keyLeft] = valueLeft;
139
+ }
140
+ else if (styleAttributeKey.includes('Vertical')) {
141
+ const keyTop = styleAttributeKey.replace('Vertical', 'Top');
142
+ const keyBottom = styleAttributeKey.replace('Vertical', 'Bottom');
143
+ const valuePartsList = value.split(' ');
144
+ const valueTop = valuePartsList[0];
145
+ const valueBottom = valuePartsList[1] || valuePartsList[0];
146
+ resultStylesGroups[targetElementGroupKey][keyTop] = valueTop;
147
+ resultStylesGroups[targetElementGroupKey][keyBottom] = valueBottom;
148
+ }
149
+ else {
150
+ resultStylesGroups[targetElementGroupKey][styleAttributeKey] = value;
151
+ }
152
+ }
153
+ }
154
+ return resultStylesGroups;
155
+ // eslint-disable-next-line react-hooks/exhaustive-deps
156
+ }, [
157
+ deviceCurrentMainType,
158
+ deviceCurrentType,
159
+ ...Object.values(propsStyleAttributes),
160
+ ]);
161
+ return collectedStyles;
162
+ }
163
+ const removeDeviceType = (originalKey, deviceTypesList) => {
164
+ // Remove "mobile"/"tablet"/"desktop"
165
+ const withOutDeviceType = deviceTypesList.reduce((cleanKey, deviceType) => {
166
+ if (cleanKey.endsWith(upperFirst(deviceType))) {
167
+ return cleanKey.replace(upperFirst(deviceType), '');
168
+ }
169
+ return cleanKey;
170
+ }, originalKey);
171
+ return withOutDeviceType;
172
+ };
173
+ const targetStyleAttributeKeyCache = new Map();
174
+ // This function is pure and it does a lot of useless work.
175
+ // We can achieve huge cache hit rate by memoizing it.
176
+ const getTargetStyleAttributeKey = (styleKey, styleValue = '') => {
177
+ const cacheKey = `${styleKey}_${styleValue}`;
178
+ if (targetStyleAttributeKeyCache.has(cacheKey)) {
179
+ return targetStyleAttributeKeyCache.get(cacheKey);
180
+ }
181
+ // Collect list of possible styles for propKey. e.g:
182
+ // "borderLeftWidthWrapperInnerMobileNormal" to ["border", "borderLeftWidth"]
183
+ const possibleStyleAttributesList = styleAttributes.filter((styleAttribute) => {
184
+ // Attribute can be array with key on first position and params on second
185
+ if (Array.isArray(styleAttribute)) {
186
+ // First item always attribute key (e.g. border, width, etc)
187
+ const styleAttributeKey = styleAttribute[0];
188
+ // Second item always params with some settings or methods
189
+ const styleAttributeParams = styleAttribute[1] || {};
190
+ // If is target attribute key
191
+ if (styleKey.startsWith(styleAttributeKey)) {
192
+ // If target attribute params has validate method
193
+ if (styleAttributeParams.validate) {
194
+ // Return validation result for target attribute
195
+ return styleAttributeParams.validate(styleValue);
196
+ }
197
+ else {
198
+ // Or always add to list
199
+ return true;
200
+ }
201
+ }
202
+ else {
203
+ // Else ignore
204
+ return false;
205
+ }
206
+ }
207
+ else {
208
+ // If is target attribute
209
+ return styleKey.startsWith(String(styleAttribute));
210
+ }
211
+ });
212
+ // Get longest style key (e.g. "borderLeftWidth")
213
+ const targetStyleAttribute = maxBy(possibleStyleAttributesList, (styleAttribute) => {
214
+ const key = getStyleAttributeKey(styleAttribute);
215
+ return key.length;
216
+ });
217
+ const styleAttributeKey = getStyleAttributeKey(targetStyleAttribute);
218
+ targetStyleAttributeKeyCache.set(cacheKey, styleAttributeKey);
219
+ return styleAttributeKey;
220
+ };
221
+
222
+ export { useStyles };
@@ -1 +1,41 @@
1
- import{useEffect as e}from"react";function t(){e(()=>{const e=()=>{const e=.01*window.innerHeight;document.documentElement.style.setProperty("--vh",`${e}px`)};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[])}export{t as useViewportFix};
1
+ import { useEffect } from 'react';
2
+
3
+ function useViewportFix() {
4
+ useEffect(() => {
5
+ // https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
6
+ const setViewportProperty = () => {
7
+ // "vh" unit is equal to 1% of the height of the initial containing block
8
+ // https://www.w3.org/R/css-values-3/#viewport-relative-lengths
9
+ const vh = window.innerHeight * 0.01;
10
+ /** NOTE:
11
+ * In JavaScript, you can always get the value of the current viewport
12
+ * by using the global variable window.innerHeight. This value takes
13
+ * the browser’s interface into account and is updated when its
14
+ * visibility changes. The trick is to store the viewport value
15
+ * in a CSS variable and apply that to the element instead of the vh unit.
16
+ * Let’s say our CSS custom variable is --vh for this example.
17
+ * That means we will want to apply it in our CSS like this:
18
+ * ```
19
+ * .my-element {
20
+ * height: 100vh; (Fallback for browsers that do not support Custom Properties)
21
+ * height: calc(var(--vh, 1vh) * 100);
22
+ * }
23
+ * ```
24
+ * We told JavaScript to grab the height of the viewport and then
25
+ * drilled it down into 1/100th of that total so we have a value
26
+ * to assign as our viewport height unit value.
27
+ * Then we politely asked JS to create the CSS variable "--vh" at the ":root":
28
+ */
29
+ document.documentElement.style.setProperty('--vh', `${vh}px`);
30
+ };
31
+ // Update the value of "--vh" after render
32
+ setViewportProperty();
33
+ // Update the value of "--vh" by listening to the window resize event
34
+ window.addEventListener('resize', setViewportProperty);
35
+ return () => {
36
+ window.removeEventListener('resize', setViewportProperty);
37
+ };
38
+ }, []);
39
+ }
40
+
41
+ export { useViewportFix };
@@ -7,16 +7,16 @@ declare function useNotificationsAPI(): {
7
7
  removeNotification: (targetId?: GeneratedId) => void;
8
8
  showNotification: (notification: string | CreatedNotification, onClose?: SimpleCallback) => void;
9
9
  notificationStatuses: {
10
- readonly error: "error";
11
- readonly info: "info";
12
- readonly success: "success";
13
- readonly warning: "warning";
10
+ readonly error: 'error';
11
+ readonly info: 'info';
12
+ readonly success: 'success';
13
+ readonly warning: 'warning';
14
14
  };
15
15
  };
16
16
  declare const statusToAppearanceList: {
17
- readonly error: "errorPrimary sizeS solid rounded";
18
- readonly info: "infoPrimary sizeS solid rounded";
19
- readonly success: "successPrimary sizeS solid rounded";
20
- readonly warning: "warningPrimary sizeS solid rounded";
17
+ readonly error: 'errorPrimary sizeS solid rounded';
18
+ readonly info: 'infoPrimary sizeS solid rounded';
19
+ readonly success: 'successPrimary sizeS solid rounded';
20
+ readonly warning: 'warningPrimary sizeS solid rounded';
21
21
  };
22
22
  export { NotificationsProvider, statusToAppearanceList, useNotifications, useNotificationsAPI, };
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import type { ComponentType, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react';
3
2
  import { RequireAtLeastOneProp, RequireAtLeastOnePropError } from '../types';
4
3
  type UrlPropKeys = (typeof urlPropsList)[number];
@@ -6,7 +5,7 @@ type OnePropCheckError = [
6
5
  'urlWithAssetPrefix: компонент должен содержать хотя бы один из пропсов',
7
6
  UrlPropKeys
8
7
  ];
9
- declare const urlPropsList: readonly ["src", "imageSrc", "svgSrc", "placeholderUrl"];
8
+ declare const urlPropsList: readonly ['src', 'imageSrc', 'svgSrc', 'placeholderUrl'];
10
9
  /**
11
10
  * HOC, который добавляет assetPrefix к URL-пропсам.
12
11
  *
@@ -24,5 +23,5 @@ declare const urlPropsList: readonly ["src", "imageSrc", "svgSrc", "placeholderU
24
23
  * const B = (props: { id: string }) => <div />;
25
24
  * urlWithAssetPrefix(B); // ❌ TS ошибка (нет url-пропов)
26
25
  */
27
- declare const urlWithAssetPrefix: <P extends Record<string, any>, T = unknown, OnePropCheck extends RequireAtLeastOneProp<P, UrlPropKeys> = RequireAtLeastOneProp<P, UrlPropKeys>>(WrappedComponent: ComponentType<P> | ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>, ..._error: RequireAtLeastOnePropError<OnePropCheck, OnePropCheckError>) => React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>>;
26
+ declare const urlWithAssetPrefix: <P extends Record<string, any>, T = unknown, OnePropCheck extends RequireAtLeastOneProp<P, UrlPropKeys> = RequireAtLeastOneProp<P, UrlPropKeys>>(WrappedComponent: ComponentType<P> | ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>, ..._error: RequireAtLeastOnePropError<OnePropCheck, OnePropCheckError>) => ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
28
27
  export { urlWithAssetPrefix };
@@ -1,20 +1,20 @@
1
- declare const suffix: readonly ["Button", "Checkbox", "Radio", "Checkmark", "Avatar", "AvatarStack", "Badge", "Breadcrumbs", "Cell", "Chips", "Choice", "Code", "CookiesWarning", "Dadata", "DatePeriod", "Divider", "Dot", "Drawer", "Dropdown", "DropdownItem", "Flex", "Grid", "Group", "HeroTitle", "HTMLContent", "Icon", "Image", "Input", "InputPassword", "Label", "Link", "List", "Loader", "Logo", "MenuItem", "Modal", "ModalSheetBottom", "Notification", "Overlay", "Pagination", "RangeSlider", "Response", "ScrollBar", "ScrollOnDrag", "ScrollToView", "Search", "Segmented", "Select", "SvgContent", "Swiper", "Switch", "Tab", "Text", "Textarea", "Tile", "Title", "Tooltip", "Video", "Warning"];
1
+ declare const suffix: readonly ['Button', 'Checkbox', 'Radio', 'Checkmark', 'Avatar', 'AvatarStack', 'Badge', 'Breadcrumbs', 'Cell', 'Chips', 'Choice', 'Code', 'CookiesWarning', 'Dadata', 'DatePeriod', 'Divider', 'Dot', 'Drawer', 'Dropdown', 'DropdownItem', 'Flex', 'Grid', 'Group', 'HeroTitle', 'HTMLContent', 'Icon', 'Image', 'Input', 'InputPassword', 'Label', 'Link', 'List', 'Loader', 'Logo', 'MenuItem', 'Modal', 'ModalSheetBottom', 'Notification', 'Overlay', 'Pagination', 'RangeSlider', 'Response', 'ScrollBar', 'ScrollOnDrag', 'ScrollToView', 'Search', 'Segmented', 'Select', 'SvgContent', 'Swiper', 'Switch', 'Tab', 'Text', 'Textarea', 'Tile', 'Title', 'Tooltip', 'Video', 'Warning'];
2
2
  type SuffixComponents = (typeof suffix)[number];
3
3
  type SpecialSuffix<T extends string> = T extends 'HTMLContent' ? 'htmlContent' : Uncapitalize<T>;
4
4
  type SuffixKeys = SpecialSuffix<SuffixComponents>;
5
5
  interface PropsGenerator {
6
6
  [key: string]: any | number | string | undefined;
7
- getProp?: (propKey: string) => number | string | undefined;
7
+ getProp?: (propKey: string) => unknown;
8
8
  }
9
9
  interface UseActiveClassesReturn {
10
10
  rootClasses: string;
11
11
  suffixClasses: Record<SuffixKeys, string>;
12
12
  }
13
13
  interface UseActiveClasses {
14
- propsGenerator: PropsGenerator;
15
- suffixes?: SuffixComponents[];
16
14
  isActive?: boolean;
17
15
  isDisabled?: boolean;
16
+ propsGenerator: PropsGenerator;
17
+ suffixes?: SuffixComponents[];
18
18
  }
19
19
  interface RulesConfig {
20
20
  key: string;
@@ -1,5 +1,5 @@
1
1
  import { AppearanceConfig } from '../useDevicePropsGenerator';
2
- declare const useAppearanceConfig: <Keys extends string, Config extends Record<"disabled" | "disabledPrimary" | Keys, AppearanceConfig>>(appearance: string | undefined, componentConfig: {
2
+ declare const useAppearanceConfig: <Keys extends string, Config extends Record<'disabled' | 'disabledPrimary' | Keys, AppearanceConfig>>(appearance: string | undefined, componentConfig: {
3
3
  appearance?: Partial<Config>;
4
4
  }, isDisabled?: boolean) => AppearanceConfig;
5
5
  export { useAppearanceConfig };
@@ -1,7 +1,7 @@
1
1
  import { KebabCase, WithClassKeys } from '../../types';
2
2
  import type { AppearanceConfig, ComponentProps, GeneratorGetClassParams as GP } from './useDevicePropsGenerator.interface';
3
3
  declare function useDevicePropsGenerator<Props extends ComponentProps>(componentProps: Props, appearanceConfig?: AppearanceConfig): Props & {
4
- getProp(propKey: string): number | string | undefined;
4
+ getProp(propKey: string): unknown;
5
5
  getClassName<K extends Extract<keyof Props, string>, P extends GP | undefined = undefined>(propKey: K, params?: P): ReturnGetClassName<Props, K, P>;
6
6
  } & WithClassKeys<Props>;
7
7
  type ReturnGetClassName<Props, K extends keyof Props, Params = undefined> = Params extends undefined ? NonNullable<Props[K]> extends string ? KebabCase<NonNullable<Props[K]>> : string : Props[K];
@@ -2,4 +2,5 @@
2
2
  * Hook is still used in "itcase-forms".
3
3
  * Need replace with "useDevicePropsGenerator" and delete this.
4
4
  */
5
- export function useDeviceTargetClass(componentProps: any, hookProps: any): string;
5
+ declare function useDeviceTargetClass(componentProps: any, hookProps: any): string;
6
+ export { useDeviceTargetClass };
@@ -1,7 +1,8 @@
1
- export function useMediaQueries(userDevice?: {}): {
1
+ declare function useMediaQueries(userDevice?: {}): {
2
2
  isMobile: any;
3
3
  isMobileHuge: any;
4
4
  isTablet: any;
5
5
  isDesktop: any;
6
6
  isDesktopMega: boolean;
7
7
  };
8
+ export { useMediaQueries };
@@ -1,3 +1,3 @@
1
1
  import { StyleAttributeOrValidator } from './styleAttributes.interface';
2
- declare const getStyleAttributeKey: (targetStyleAttribute: StyleAttributeOrValidator) => 0 | "fill" | "fixed" | import("./styleAttributes.interface").StyleAttributes | "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | (string & {}) | "auto" | "fit-content" | "max-content" | "min-content" | "-moz-fit-content" | "-moz-max-content" | "-moz-min-content" | "-webkit-fit-content" | "hug" | "-webkit-max-content" | "intrinsic" | "min-intrinsic";
2
+ declare const getStyleAttributeKey: (targetStyleAttribute: StyleAttributeOrValidator) => "-moz-fit-content" | "-moz-initial" | "-moz-max-content" | "-moz-min-content" | "-webkit-fit-content" | "-webkit-max-content" | "auto" | "fill" | "fit-content" | "fixed" | "hug" | "inherit" | "initial" | "intrinsic" | "max-content" | "min-content" | "min-intrinsic" | "revert" | "revert-layer" | "unset" | 0 | import("./styleAttributes.interface").StyleAttributes | (string & {});
3
3
  export { getStyleAttributeKey };
@@ -1 +1,2 @@
1
- export{mergeAppearanceKeys}from"./mergeAppearanceKeys.js";export{setViewportProperty}from"./setViewportProperty.js";
1
+ export { mergeAppearanceKeys } from './mergeAppearanceKeys.js';
2
+ export { setViewportProperty } from './setViewportProperty.js';
@@ -1 +1,16 @@
1
- const r=(...r)=>{const t=r.map(r=>r?.trim()).filter(Boolean);if(t.length<2)return t[0]??"";return Array.from(new Set(t)).join(" ")};export{r as mergeAppearanceKeys};
1
+ /**
2
+ * @example
3
+ * mergeAppearanceKeys(' ', '1', undefined, '2', '1') === '1 2'
4
+ */
5
+ const mergeAppearanceKeys = (...appearances) => {
6
+ const trimmedAppearances = appearances
7
+ .map((appearance) => appearance?.trim())
8
+ .filter(Boolean);
9
+ if (trimmedAppearances.length < 2) {
10
+ return trimmedAppearances[0] ?? '';
11
+ }
12
+ const uniqueAppearances = Array.from(new Set(trimmedAppearances));
13
+ return uniqueAppearances.join(' ');
14
+ };
15
+
16
+ export { mergeAppearanceKeys };
@@ -1 +1,6 @@
1
- const e=()=>{const e=.01*window.innerHeight;document.documentElement.style.setProperty("--vh",`${e}px`)};export{e as setViewportProperty};
1
+ const setViewportProperty = () => {
2
+ const vh = window.innerHeight * 0.01;
3
+ document.documentElement.style.setProperty('--vh', `${vh}px`);
4
+ };
5
+
6
+ export { setViewportProperty };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/ui-core",
3
- "version": "1.10.47",
3
+ "version": "1.10.48",
4
4
  "description": "UI shared components",
5
5
  "keywords": [
6
6
  "Modal",
@@ -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": "09306c0d4781521c6c7059638852274291cd06a7"
99
+ "gitHead": "1f665db854bceb66e6b86b17a4a6a82c79d4523b"
100
100
  }