@itcase/ui-core 1.10.47 → 1.10.49

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,177 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.default=["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"];
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var styleAttributes = [
6
+ /**
7
+ * Layout
8
+ */
9
+ 'alignContent',
10
+ 'alignItems',
11
+ 'alignSelf',
12
+ 'aspectRatio',
13
+ 'border',
14
+ 'borderBottomWidth',
15
+ 'borderLeftWidth',
16
+ 'borderRightWidth',
17
+ 'borderTopWidth',
18
+ 'borderWidth',
19
+ 'bottom',
20
+ 'display',
21
+ 'flex',
22
+ 'flexBasis',
23
+ 'flexDirection',
24
+ 'flexGrow',
25
+ 'flexShrink',
26
+ 'flexWrap',
27
+ 'gap',
28
+ 'rowGap',
29
+ 'columnGap',
30
+ 'columnWidth',
31
+ 'height',
32
+ 'justifyContent',
33
+ 'left',
34
+ 'margin',
35
+ 'marginBottom',
36
+ 'marginHorizontal',
37
+ 'marginLeft',
38
+ 'marginRight',
39
+ 'marginTop',
40
+ 'marginVertical',
41
+ 'maxHeight',
42
+ 'maxWidth',
43
+ 'minHeight',
44
+ 'minWidth',
45
+ 'overflow',
46
+ 'overflowY',
47
+ 'overflowX',
48
+ 'padding',
49
+ 'paddingBottom',
50
+ 'paddingEnd',
51
+ 'paddingHorizontal',
52
+ 'paddingLeft',
53
+ 'paddingRight',
54
+ 'paddingStart',
55
+ 'paddingTop',
56
+ 'paddingVertical',
57
+ 'position',
58
+ 'right',
59
+ 'top',
60
+ [
61
+ 'width',
62
+ {
63
+ validate: (value) => {
64
+ // Pass only number value for "width" style.
65
+ // If width have custom value, like "fill", we must set class by this value.
66
+ // "\d" - digit; "+" - 1 or more
67
+ return /\d+/.test(value);
68
+ },
69
+ },
70
+ ],
71
+ 'zIndex',
72
+ 'order',
73
+ /**
74
+ * Shadow
75
+ */
76
+ 'shadowColor',
77
+ 'shadowOffset',
78
+ 'shadowOpacity',
79
+ 'shadowRadius',
80
+ /**
81
+ * Transform
82
+ */
83
+ 'transform',
84
+ /**
85
+ * View
86
+ */
87
+ 'background',
88
+ 'backgroundColor',
89
+ 'borderBottomColor',
90
+ 'borderBottomEndRadius',
91
+ 'borderBottomLeftRadius',
92
+ 'borderBottomRightRadius',
93
+ 'borderBottomStartRadius',
94
+ 'borderColor',
95
+ 'borderCurve',
96
+ 'borderEndColor',
97
+ 'borderLeftColor',
98
+ 'borderRadius',
99
+ 'borderRightColor',
100
+ 'borderStartColor',
101
+ 'borderStyle',
102
+ 'borderTopColor',
103
+ 'borderTopEndRadius',
104
+ 'borderTopLeftRadius',
105
+ 'borderTopRightRadius',
106
+ 'borderTopStartRadius',
107
+ 'opacity',
108
+ 'cursor',
109
+ /**
110
+ * Text
111
+ */
112
+ 'color',
113
+ 'fontFamily',
114
+ 'fontSize',
115
+ 'fontStyle',
116
+ 'fontVariant',
117
+ 'fontWeight',
118
+ 'letterSpacing',
119
+ 'lineHeight',
120
+ 'textAlign',
121
+ 'textDecorationColor',
122
+ 'textDecorationLine',
123
+ 'textDecorationStyle',
124
+ 'textShadowColor',
125
+ 'textShadowOffset',
126
+ 'textShadowRadius',
127
+ 'textTransform',
128
+ 'verticalAlign',
129
+ 'writingMode',
130
+ 'whiteSpace',
131
+ /**
132
+ * Image
133
+ */
134
+ 'overlayColor',
135
+ 'resizeMode',
136
+ 'tintColor',
137
+ 'objectFit',
138
+ 'objectPosition',
139
+ /**
140
+ * Grid
141
+ */
142
+ 'gridTemplateColumns',
143
+ 'gridArea',
144
+ 'gridAutoColumns',
145
+ 'gridAutoFlow',
146
+ 'gridAutoRows',
147
+ 'gridTemplate',
148
+ 'gridTemplateAreas',
149
+ 'gridTemplateRows',
150
+ 'gridColumn',
151
+ 'gridColumnStart',
152
+ 'gridColumnEnd',
153
+ 'gridColumnGap',
154
+ 'gridRow',
155
+ 'gridRowStart',
156
+ 'gridRowEnd',
157
+ 'gridRowGap',
158
+ /**
159
+ * Filter
160
+ */
161
+ 'backdropFilter',
162
+ /**
163
+ * Transition
164
+ */
165
+ 'transition',
166
+ 'transitionBehavior',
167
+ 'transitionDelay',
168
+ 'transitionDuration',
169
+ 'transitionProperty',
170
+ 'transitionTimingFunction',
171
+ /**
172
+ * Control
173
+ */
174
+ 'pointerEvents',
175
+ ];
176
+
177
+ exports.default = styleAttributes;
@@ -1 +1,224 @@
1
- "use strict";var e=require("react"),t=require("lodash/camelCase"),r=require("lodash/maxBy"),i=require("lodash/upperFirst");require("../../context/Notifications.js");var s=require("../../context/UIContext.js");require("../../context/UrlAssetPrefix.js");var o=require("./styleAttributes.js"),n=require("./styleAttributes.helpers.js");require("react/jsx-runtime"),require("uuid"),require("@itcase/common"),require("../useMediaQueries/useMediaQueries.js"),require("react-responsive"),require("../../utils/setViewportProperty.js");const l=(e,t)=>t.reduce((e,t)=>e.endsWith(i(t))?e.replace(i(t),""):e,e),a=new Map,c=(e,t="")=>{const i=`${e}_${t}`;if(a.has(i))return a.get(i);const s=o.default.filter(r=>{if(Array.isArray(r)){const i=r[0],s=r[1]||{};return!!e.startsWith(i)&&(!s.validate||s.validate(t))}return e.startsWith(String(r))}),l=r(s,e=>n.getStyleAttributeKey(e).length),c=n.getStyleAttributeKey(l);return a.set(i,c),c};exports.useStyles=function(r){const{deviceCurrentMainType:o,deviceCurrentType:n,deviceTypesList:a}=s.useUserDeviceContext(),u=e.useMemo(()=>Object.entries(r).reduce((e,[t,r])=>(c(t,r)&&(e[t]=r),e),{}),[r]);return e.useMemo(()=>{const e={};for(const[s,d]of Object.entries(u)){let u=null;const p=c(s,d),f=s.toLowerCase().endsWith(n.toLowerCase()),y=l(s.replace(p,""),a),q=t(y)||"styles";if(e[q]||(e[q]={}),f)u=d;else{const t=`${p}${y}`,s=`${t}${i(o)}`,n=r[s]||r[t];let l=e[q][p];if(t.includes("Horizontal")){const t=p.replace("Horizontal","Left");l=e[q][t]}else if(t.includes("Vertical")){const t=p.replace("Vertical","Top");l=e[q][t]}l||(u=n)}if(u){if(/\D/.test(u)){if(/\d+\.?\d*m\s?(?![a-zA-Z]+)/.test(u)){const e=u.split(" ").map(e=>{const t=e.replace(/[a-z]/gi,"");return`${8*parseFloat(t)}px`},[]);u=e.join(" ")}}else{["flexGrow","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","opacity","order","zIndex"].includes(p)||(u=`${u}px`)}if(p.includes("Horizontal")){const t=p.replace("Horizontal","Right"),r=p.replace("Horizontal","Left"),i=u.split(" "),s=i[0],o=i[1]||i[0];e[q][t]=s,e[q][r]=o}else if(p.includes("Vertical")){const t=p.replace("Vertical","Top"),r=p.replace("Vertical","Bottom"),i=u.split(" "),s=i[0],o=i[1]||i[0];e[q][t]=s,e[q][r]=o}else e[q][p]=u}}return e},[o,n,...Object.values(u)])};
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var camelCase = require('lodash/camelCase');
5
+ var maxBy = require('lodash/maxBy');
6
+ var upperFirst = require('lodash/upperFirst');
7
+ require('../../context/Notifications.js');
8
+ var UIContext = require('../../context/UIContext.js');
9
+ require('../../context/UrlAssetPrefix.js');
10
+ var styleAttributes = require('./styleAttributes.js');
11
+ var styleAttributes_helpers = require('./styleAttributes.helpers.js');
12
+ require('react/jsx-runtime');
13
+ require('uuid');
14
+ require('@itcase/common');
15
+ require('../useMediaQueries/useMediaQueries.js');
16
+ require('react-responsive');
17
+ require('../../utils/setViewportProperty.js');
18
+
19
+ /*
20
+ * rule of prop key:
21
+ *
22
+ * first is style second is div target third is device
23
+ * paddingHorizontal GridInnerWrapper MobileNormal
24
+ *
25
+ * paddingHorizontalGridInnerWrapperMobileNormal: "10px"
26
+ */
27
+ function useStyles(props) {
28
+ const { deviceCurrentMainType, deviceCurrentType, deviceTypesList } = UIContext.useUserDeviceContext();
29
+ const propsStyleAttributes = React.useMemo(() => {
30
+ const styles = Object.entries(props).reduce((result, [propKey, propValue]) => {
31
+ const styleAttributeKey = getTargetStyleAttributeKey(propKey, propValue);
32
+ if (styleAttributeKey) {
33
+ result[propKey] = propValue;
34
+ }
35
+ return result;
36
+ }, {});
37
+ return styles;
38
+ // "props" object maybe big and frequently changing
39
+ }, [props]);
40
+ const collectedStyles = React.useMemo(() => {
41
+ const resultStylesGroups = {};
42
+ for (const [propKey, propValue] of Object.entries(propsStyleAttributes)) {
43
+ let value = null;
44
+ const styleAttributeKey = getTargetStyleAttributeKey(propKey, propValue);
45
+ const isStyleForCurrentDevice = propKey
46
+ .toLowerCase()
47
+ .endsWith(deviceCurrentType.toLowerCase());
48
+ // e.g. "GridWrapperInner"
49
+ const targetElementKey = removeDeviceType(propKey.replace(styleAttributeKey, ''), deviceTypesList);
50
+ const targetElementGroupKey = camelCase(targetElementKey) || 'styles';
51
+ if (!resultStylesGroups[targetElementGroupKey]) {
52
+ resultStylesGroups[targetElementGroupKey] = {};
53
+ }
54
+ if (isStyleForCurrentDevice) {
55
+ value = propValue;
56
+ }
57
+ else {
58
+ const propKeyWithOutDeviceType = `${styleAttributeKey}${targetElementKey}`;
59
+ const propKeyWithBaseDeviceType = `${propKeyWithOutDeviceType}${upperFirst(deviceCurrentMainType)}`;
60
+ const defaultValue = props[propKeyWithBaseDeviceType] || props[propKeyWithOutDeviceType];
61
+ let currentValue = resultStylesGroups[targetElementGroupKey][styleAttributeKey];
62
+ if (propKeyWithOutDeviceType.includes('Horizontal')) {
63
+ const keyLeft = styleAttributeKey.replace('Horizontal', 'Left');
64
+ currentValue =
65
+ resultStylesGroups[targetElementGroupKey][keyLeft];
66
+ }
67
+ else if (propKeyWithOutDeviceType.includes('Vertical')) {
68
+ const keyTop = styleAttributeKey.replace('Vertical', 'Top');
69
+ currentValue =
70
+ resultStylesGroups[targetElementGroupKey][keyTop];
71
+ }
72
+ if (!currentValue) {
73
+ value = defaultValue;
74
+ }
75
+ }
76
+ if (value) {
77
+ // Check not digit symbols. Chars means some unit ("px", "em", "rem" or custom "m")
78
+ const isValueHasUnit = /\D/.test(value);
79
+ // If value has some unit
80
+ if (isValueHasUnit) {
81
+ // Check value on our custom "m"(module) unit
82
+ /** Pattern for:
83
+ * 1m
84
+ * 1.5m
85
+ * 1m 1m 1.5m
86
+ * 0 0 1m 1m
87
+ */
88
+ const isValueHasModuleUnit = /\d+\.?\d*m\s?(?![a-zA-Z]+)/.test(value);
89
+ // If value has module unit
90
+ if (isValueHasModuleUnit) {
91
+ /** Order for shorthand properties:
92
+ * top
93
+ * right
94
+ * bottom
95
+ * left
96
+ * or:
97
+ * top
98
+ * right and left
99
+ * bottom
100
+ * or:
101
+ * top and bottom
102
+ * right and left
103
+ */
104
+ const valuePxPartsList = value
105
+ .split(' ')
106
+ .map((valuePart) => {
107
+ const valueModule = valuePart.replace(/[a-z]/gi, '');
108
+ const valuePx = parseFloat(valueModule) * 8;
109
+ return `${valuePx}px`;
110
+ }, []);
111
+ value = valuePxPartsList.join(' ');
112
+ }
113
+ }
114
+ else {
115
+ // Some properties doesn't have any units
116
+ const ignorePX = [
117
+ 'flexGrow',
118
+ 'gridColumn',
119
+ 'gridColumnEnd',
120
+ 'gridColumnStart',
121
+ 'gridRow',
122
+ 'gridRowEnd',
123
+ 'gridRowStart',
124
+ 'opacity',
125
+ 'order',
126
+ 'zIndex',
127
+ ].includes(styleAttributeKey);
128
+ if (!ignorePX) {
129
+ // Add px to non-unit value
130
+ value = `${value}px`;
131
+ }
132
+ }
133
+ if (styleAttributeKey.includes('Horizontal')) {
134
+ const keyRight = styleAttributeKey.replace('Horizontal', 'Right');
135
+ const keyLeft = styleAttributeKey.replace('Horizontal', 'Left');
136
+ const valuePartsList = value.split(' ');
137
+ const valueRight = valuePartsList[0];
138
+ const valueLeft = valuePartsList[1] || valuePartsList[0];
139
+ resultStylesGroups[targetElementGroupKey][keyRight] = valueRight;
140
+ resultStylesGroups[targetElementGroupKey][keyLeft] = valueLeft;
141
+ }
142
+ else if (styleAttributeKey.includes('Vertical')) {
143
+ const keyTop = styleAttributeKey.replace('Vertical', 'Top');
144
+ const keyBottom = styleAttributeKey.replace('Vertical', 'Bottom');
145
+ const valuePartsList = value.split(' ');
146
+ const valueTop = valuePartsList[0];
147
+ const valueBottom = valuePartsList[1] || valuePartsList[0];
148
+ resultStylesGroups[targetElementGroupKey][keyTop] = valueTop;
149
+ resultStylesGroups[targetElementGroupKey][keyBottom] = valueBottom;
150
+ }
151
+ else {
152
+ resultStylesGroups[targetElementGroupKey][styleAttributeKey] = value;
153
+ }
154
+ }
155
+ }
156
+ return resultStylesGroups;
157
+ // eslint-disable-next-line react-hooks/exhaustive-deps
158
+ }, [
159
+ deviceCurrentMainType,
160
+ deviceCurrentType,
161
+ ...Object.values(propsStyleAttributes),
162
+ ]);
163
+ return collectedStyles;
164
+ }
165
+ const removeDeviceType = (originalKey, deviceTypesList) => {
166
+ // Remove "mobile"/"tablet"/"desktop"
167
+ const withOutDeviceType = deviceTypesList.reduce((cleanKey, deviceType) => {
168
+ if (cleanKey.endsWith(upperFirst(deviceType))) {
169
+ return cleanKey.replace(upperFirst(deviceType), '');
170
+ }
171
+ return cleanKey;
172
+ }, originalKey);
173
+ return withOutDeviceType;
174
+ };
175
+ const targetStyleAttributeKeyCache = new Map();
176
+ // This function is pure and it does a lot of useless work.
177
+ // We can achieve huge cache hit rate by memoizing it.
178
+ const getTargetStyleAttributeKey = (styleKey, styleValue = '') => {
179
+ const cacheKey = `${styleKey}_${styleValue}`;
180
+ if (targetStyleAttributeKeyCache.has(cacheKey)) {
181
+ return targetStyleAttributeKeyCache.get(cacheKey);
182
+ }
183
+ // Collect list of possible styles for propKey. e.g:
184
+ // "borderLeftWidthWrapperInnerMobileNormal" to ["border", "borderLeftWidth"]
185
+ const possibleStyleAttributesList = styleAttributes.default.filter((styleAttribute) => {
186
+ // Attribute can be array with key on first position and params on second
187
+ if (Array.isArray(styleAttribute)) {
188
+ // First item always attribute key (e.g. border, width, etc)
189
+ const styleAttributeKey = styleAttribute[0];
190
+ // Second item always params with some settings or methods
191
+ const styleAttributeParams = styleAttribute[1] || {};
192
+ // If is target attribute key
193
+ if (styleKey.startsWith(styleAttributeKey)) {
194
+ // If target attribute params has validate method
195
+ if (styleAttributeParams.validate) {
196
+ // Return validation result for target attribute
197
+ return styleAttributeParams.validate(styleValue);
198
+ }
199
+ else {
200
+ // Or always add to list
201
+ return true;
202
+ }
203
+ }
204
+ else {
205
+ // Else ignore
206
+ return false;
207
+ }
208
+ }
209
+ else {
210
+ // If is target attribute
211
+ return styleKey.startsWith(String(styleAttribute));
212
+ }
213
+ });
214
+ // Get longest style key (e.g. "borderLeftWidth")
215
+ const targetStyleAttribute = maxBy(possibleStyleAttributesList, (styleAttribute) => {
216
+ const key = styleAttributes_helpers.getStyleAttributeKey(styleAttribute);
217
+ return key.length;
218
+ });
219
+ const styleAttributeKey = styleAttributes_helpers.getStyleAttributeKey(targetStyleAttribute);
220
+ targetStyleAttributeKeyCache.set(cacheKey, styleAttributeKey);
221
+ return styleAttributeKey;
222
+ };
223
+
224
+ exports.useStyles = useStyles;
@@ -1 +1,43 @@
1
- "use strict";var e=require("react");exports.useViewportFix=function(){e.useEffect(()=>{const e=()=>{const e=.01*window.innerHeight;document.documentElement.style.setProperty("--vh",`${e}px`)};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[])};
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ function useViewportFix() {
6
+ React.useEffect(() => {
7
+ // https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
8
+ const setViewportProperty = () => {
9
+ // "vh" unit is equal to 1% of the height of the initial containing block
10
+ // https://www.w3.org/R/css-values-3/#viewport-relative-lengths
11
+ const vh = window.innerHeight * 0.01;
12
+ /** NOTE:
13
+ * In JavaScript, you can always get the value of the current viewport
14
+ * by using the global variable window.innerHeight. This value takes
15
+ * the browser’s interface into account and is updated when its
16
+ * visibility changes. The trick is to store the viewport value
17
+ * in a CSS variable and apply that to the element instead of the vh unit.
18
+ * Let’s say our CSS custom variable is --vh for this example.
19
+ * That means we will want to apply it in our CSS like this:
20
+ * ```
21
+ * .my-element {
22
+ * height: 100vh; (Fallback for browsers that do not support Custom Properties)
23
+ * height: calc(var(--vh, 1vh) * 100);
24
+ * }
25
+ * ```
26
+ * We told JavaScript to grab the height of the viewport and then
27
+ * drilled it down into 1/100th of that total so we have a value
28
+ * to assign as our viewport height unit value.
29
+ * Then we politely asked JS to create the CSS variable "--vh" at the ":root":
30
+ */
31
+ document.documentElement.style.setProperty('--vh', `${vh}px`);
32
+ };
33
+ // Update the value of "--vh" after render
34
+ setViewportProperty();
35
+ // Update the value of "--vh" by listening to the window resize event
36
+ window.addEventListener('resize', setViewportProperty);
37
+ return () => {
38
+ window.removeEventListener('resize', setViewportProperty);
39
+ };
40
+ }, []);
41
+ }
42
+
43
+ exports.useViewportFix = useViewportFix;
@@ -1 +1,9 @@
1
- "use strict";var e=require("./mergeAppearanceKeys.js"),r=require("./setViewportProperty.js");exports.mergeAppearanceKeys=e.mergeAppearanceKeys,exports.setViewportProperty=r.setViewportProperty;
1
+ 'use strict';
2
+
3
+ var mergeAppearanceKeys = require('./mergeAppearanceKeys.js');
4
+ var setViewportProperty = require('./setViewportProperty.js');
5
+
6
+
7
+
8
+ exports.mergeAppearanceKeys = mergeAppearanceKeys.mergeAppearanceKeys;
9
+ exports.setViewportProperty = setViewportProperty.setViewportProperty;
@@ -1 +1,18 @@
1
- "use strict";exports.mergeAppearanceKeys=(...e)=>{const r=e.map(e=>e?.trim()).filter(Boolean);if(r.length<2)return r[0]??"";return Array.from(new Set(r)).join(" ")};
1
+ 'use strict';
2
+
3
+ /**
4
+ * @example
5
+ * mergeAppearanceKeys(' ', '1', undefined, '2', '1') === '1 2'
6
+ */
7
+ const mergeAppearanceKeys = (...appearances) => {
8
+ const trimmedAppearances = appearances
9
+ .map((appearance) => appearance?.trim())
10
+ .filter(Boolean);
11
+ if (trimmedAppearances.length < 2) {
12
+ return trimmedAppearances[0] ?? '';
13
+ }
14
+ const uniqueAppearances = Array.from(new Set(trimmedAppearances));
15
+ return uniqueAppearances.join(' ');
16
+ };
17
+
18
+ exports.mergeAppearanceKeys = mergeAppearanceKeys;
@@ -1 +1,8 @@
1
- "use strict";exports.setViewportProperty=()=>{const e=.01*window.innerHeight;document.documentElement.style.setProperty("--vh",`${e}px`)};
1
+ 'use strict';
2
+
3
+ const setViewportProperty = () => {
4
+ const vh = window.innerHeight * 0.01;
5
+ document.documentElement.style.setProperty('--vh', `${vh}px`);
6
+ };
7
+
8
+ exports.setViewportProperty = setViewportProperty;