@semcore/base-components 17.0.0-prerelease.27 → 17.0.0-prerelease.29

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/CHANGELOG.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
- ## [17.0.0] - 2026-02-23
5
+ ## [17.0.0] - 2026-02-27
6
6
 
7
7
  ### BREAK
8
8
 
@@ -11,89 +11,105 @@ CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangel
11
11
  - **outside-click**: Removed using `getNodeByRef`. Use `React.RefObject` instead.
12
12
  - **scroll-area**: Removed using `getNodeByRef`. Use `React.RefObject` instead.
13
13
 
14
- ### Added
15
-
16
- - `inset` property for the Box component.
17
-
18
- ### Changed
19
-
20
- - `Hint` now has slicker and more compact styles.
21
-
22
14
  ## [16.4.2] - 2025-12-01
23
15
 
24
16
  ### Fixed
25
17
 
26
- - **popper**: The "Popper" with focus or hover interaction opens after moving to the
18
+ - The "Popper" with focus or hover interaction opens after moving to the
27
19
  trigger from the popper using the Tab key.
28
20
 
29
21
  ## [16.4.1] - 2025-10-17
30
22
 
31
23
  ### Fixed
32
24
 
33
- - **scroll-area**: Mouse interaction with elements inside a `ScrollArea.Container` when the container has focus-visible.
25
+ - Mouse interaction with elements inside a `ScrollArea.Container` when the container has focus-visible.
34
26
 
35
27
  ## [16.4.0] - 2025-10-03
36
28
 
37
29
  ### Changed
38
30
 
39
- - **flex-box**: Styles for `:focus-visible`.
40
- - **flex-box**: Border-radius for invalid pattern in InvalidStateBox.
31
+ - Styles for `:focus-visible` in Box and ScrollArea.
32
+ - Border-radius for invalid pattern in InvalidStateBox.
41
33
 
42
34
  ## [16.3.0] - 2025-09-20
43
35
 
44
36
  ### Added
45
37
 
46
- - **flex-box**: Ability to use two tags in `tag` property. First for some logic like `Ellipsis` or `Select.Trigger` and second for real `html` tag.
38
+ - Ability to use two tags in `tag` property. First for some logic like `Ellipsis` or `Select.Trigger` and second for real `html` tag.
47
39
 
48
40
  ## [16.2.4] - 2025-09-12
49
41
 
50
42
  ### Changed
51
43
 
52
- - **popper**: Don't open popper `onFocus` if last interaction was with mouse.
44
+ - Don't open popper `onFocus` if last interaction was with mouse.
45
+
46
+ ## [16.2.3] - 2025-09-17
47
+
48
+ ### Changed
49
+
50
+ - Version patch update due to children dependencies update (`@semcore/core` [16.2.0 ~> 16.3.0]).
51
+
52
+ ## [16.2.2] - 2025-09-05
53
+
54
+ ### Changed
55
+
56
+ - Version patch update due to children dependencies update (`@semcore/core` [16.1.1 ~> 16.2.0]).
53
57
 
54
58
  ## [16.2.1] - 2025-08-29
55
59
 
56
60
  ### Changed
57
61
 
58
- - **popper**: Type description for `PopperPopperProps`/`PopperProps`/`ScrollAreaProps`/`ScrollBarProps`/`BoxProps`.
62
+ - Type description for `PopperPopperProps`/`PopperProps`/`ScrollAreaProps`/`ScrollBarProps`/`BoxProps`.
59
63
 
60
64
  ## [16.2.0] - 2025-08-08
61
65
 
62
66
  ### Added
63
67
 
64
- - **flex-box**: `text-align` CSS property to `Box` component.
68
+ - `text-align` CSS property to `Box` component.
69
+
70
+ ## [16.1.2] - 2025-07-23
71
+
72
+ ### Changed
73
+
74
+ - Version patch update due to children dependencies update (`@semcore/core` [16.0.3 ~> 16.0.4]).
75
+
76
+ ## [16.1.1] - 2025-07-04
77
+
78
+ ### Changed
79
+
80
+ - Version patch update due to children dependencies update (`@semcore/core` [16.0.1 ~> 16.0.3]).
65
81
 
66
82
  ## [16.1.0] - 2025-06-20
67
83
 
68
84
  ### Added
69
85
 
70
- - **scroll-area**: New properties - `shadowSize` and `shadowTheme` for customize Shadows.
86
+ - New properties - `shadowSize` and `shadowTheme` for customize Shadows.
71
87
 
72
88
  ## [16.0.2] - 2025-06-12
73
89
 
74
90
  ### Added
75
91
 
76
- - **scroll-area**: ResizeObserver for the `Wrapper` component in the `ScrollArea`.
92
+ - ResizeObserver for the `Wrapper` component in the `ScrollArea`.
77
93
 
78
94
  ### Changed
79
95
 
80
- - **popper**: `keyboardFocus` to `focus` event for popper triggers with `hover` interaction.
96
+ - `keyboardFocus` to `focus` event for popper triggers with `hover` interaction.
81
97
 
82
98
  ## [16.0.1] - 2025-05-26
83
99
 
84
100
  ### Fixed
85
101
 
86
- - **animation**: `Delay` doesn't work for the `Collapse` component.
102
+ - `Delay` doesn't work for the `Collapse` component.
87
103
 
88
104
  ## [16.0.0] - 2025-05-19
89
105
 
90
106
  ### Added
91
107
 
92
108
  - Package with base components.
93
- - **flex-box**: `outline` for all Box'es with `:focus-visible`.
94
- - **scroll-area**: `topOffset` and `bottomOffset` to Bars.
95
- - **portal**: `nodeToMount` property.
109
+ - `outline` for all Box'es with `:focus-visible`.
110
+ - `topOffset` and `bottomOffset` to Bars in ScrollArea.
111
+ - `nodeToMount` property to `Portal`.
96
112
 
97
113
  ### Fixed
98
114
 
99
- - **popper**: `keydown` event was propagated from Popper.
115
+ - `keydown` event was propagated from `Popper`.
@@ -5,12 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = useBox;
8
- exports.removeUndefinedKeys = removeUndefinedKeys;
9
8
  var _core = require("@semcore/core");
9
+ var _indentStyles = require("@semcore/core/lib/utils/indentStyles");
10
10
  var _propsForElement = _interopRequireDefault(require("@semcore/core/lib/utils/propsForElement"));
11
11
  var _classnames = _interopRequireDefault(require("classnames"));
12
12
  var _react = _interopRequireDefault(require("react"));
13
- var _utils = require("../utils");
14
13
  /*!__reshadow-styles__:"../style/use-box.shadow.css"*/
15
14
  const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SBox_1suvb_gg_._inAfterOutline_false_1suvb_gg_:focus-visible,.___SBox_1suvb_gg_._inAfterOutline_true_1suvb_gg_:focus-visible::after{z-index:1;outline-color:var(--intergalactic-keyboard-focus-outline, #008ff8);outline-style:solid;outline-width:2px;outline-offset:2px;transition-duration:calc(var(--intergalactic-duration-extra-fast, 100)*1ms);transition-timing-function:ease-in-out;transition-property:outline-color,outline-width,outline-offset}.___SBox_1suvb_gg_._inAfterOutline_false_1suvb_gg_.__invertOutline_1suvb_gg_:focus-visible,.___SBox_1suvb_gg_._inAfterOutline_true_1suvb_gg_.__invertOutline_1suvb_gg_:focus-visible::after{outline-color:var(--intergalactic-keyboard-focus-invert-outline, rgba(255, 255, 255, 0.8))}.___SBox_1suvb_gg_._inAfterOutline_true_1suvb_gg_:focus-visible::after{position:absolute;display:block;content:\"\";top:0;right:0;bottom:0;left:0;top:var(0);right:var(0);bottom:var(0);left:var(0)}.___SBoxInnerOutline_1suvb_gg_._inAfterOutline_false_1suvb_gg_:focus-visible,.___SBoxInnerOutline_1suvb_gg_._inAfterOutline_true_1suvb_gg_:focus-visible::after{outline-offset:-2px}.___SBoxSizing_1suvb_gg_{box-sizing:border-box}.___SBoxInline_1suvb_gg_{display:inline-block}", /*__inner_css_end__*/"1suvb_gg_"),
16
15
  /*__reshadow_css_end__*/
@@ -23,56 +22,35 @@ const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_star
23
22
  "__SBox": "___SBox_1suvb_gg_",
24
23
  "_invertOutline": "__invertOutline_1suvb_gg_"
25
24
  });
26
- function removeUndefinedKeys(obj) {
27
- return Object.entries(obj).reduce((acc, [key, value]) => {
28
- if (value !== undefined) {
29
- acc[key] = value;
30
- }
31
- return acc;
32
- }, {});
33
- }
34
- function getSize(size) {
35
- if (typeof size !== 'number') {
36
- return size;
37
- }
38
- if (size < 1) {
39
- return `${100 * size}%`;
40
- }
41
- if (size >= 1) {
42
- return `${size}px`;
43
- }
44
- }
45
-
46
25
  /** @deprecated */
47
-
48
26
  function calculateIndentStyles(props, scaleIndent) {
49
- return removeUndefinedKeys({
27
+ return (0, _indentStyles.removeUndefinedKeys)({
50
28
  display: props['display'],
51
- width: getSize(props['w']),
52
- height: getSize(props['h']),
53
- minWidth: getSize(props['wMin']),
54
- maxWidth: getSize(props['wMax']),
55
- minHeight: getSize(props['hMin']),
56
- maxHeight: getSize(props['hMax']),
29
+ width: (0, _indentStyles.getSize)(props['w']),
30
+ height: (0, _indentStyles.getSize)(props['h']),
31
+ minWidth: (0, _indentStyles.getSize)(props['wMin']),
32
+ maxWidth: (0, _indentStyles.getSize)(props['wMax']),
33
+ minHeight: (0, _indentStyles.getSize)(props['hMin']),
34
+ maxHeight: (0, _indentStyles.getSize)(props['hMax']),
57
35
  position: props['position'],
58
- top: getSize(props['top']),
59
- left: getSize(props['left']),
60
- bottom: getSize(props['bottom']),
61
- right: getSize(props['right']),
36
+ top: (0, _indentStyles.getSize)(props['top']),
37
+ left: (0, _indentStyles.getSize)(props['left']),
38
+ bottom: (0, _indentStyles.getSize)(props['bottom']),
39
+ right: (0, _indentStyles.getSize)(props['right']),
62
40
  inset: props.inset,
63
41
  flex: props.flex,
64
42
  zIndex: props.zIndex,
65
43
  textAlign: props.textAlign,
66
- margin: (0, _utils.getAutoOrScaleIndent)(props['m'], scaleIndent),
67
- marginTop: (0, _utils.getAutoOrScaleIndent)(props['mt'], scaleIndent) || (0, _utils.getAutoOrScaleIndent)(props['my'], scaleIndent),
68
- marginBottom: (0, _utils.getAutoOrScaleIndent)(props['mb'], scaleIndent) || (0, _utils.getAutoOrScaleIndent)(props['my'], scaleIndent),
69
- marginLeft: (0, _utils.getAutoOrScaleIndent)(props['ml'], scaleIndent) || (0, _utils.getAutoOrScaleIndent)(props['mx'], scaleIndent),
70
- marginRight: (0, _utils.getAutoOrScaleIndent)(props['mr'], scaleIndent) || (0, _utils.getAutoOrScaleIndent)(props['mx'], scaleIndent),
71
- padding: (0, _utils.getAutoOrScaleIndent)(props['p'], scaleIndent),
72
- paddingTop: (0, _utils.getAutoOrScaleIndent)(props['pt'], scaleIndent) || (0, _utils.getAutoOrScaleIndent)(props['py'], scaleIndent),
73
- paddingBottom: (0, _utils.getAutoOrScaleIndent)(props['pb'], scaleIndent) || (0, _utils.getAutoOrScaleIndent)(props['py'], scaleIndent),
74
- paddingLeft: (0, _utils.getAutoOrScaleIndent)(props['pl'], scaleIndent) || (0, _utils.getAutoOrScaleIndent)(props['px'], scaleIndent),
75
- paddingRight: (0, _utils.getAutoOrScaleIndent)(props['pr'], scaleIndent) || (0, _utils.getAutoOrScaleIndent)(props['px'], scaleIndent)
44
+ margin: (0, _indentStyles.getAutoOrScaleIndent)(props['m'], scaleIndent),
45
+ marginTop: (0, _indentStyles.getAutoOrScaleIndent)(props['mt'], scaleIndent) || (0, _indentStyles.getAutoOrScaleIndent)(props['my'], scaleIndent),
46
+ marginBottom: (0, _indentStyles.getAutoOrScaleIndent)(props['mb'], scaleIndent) || (0, _indentStyles.getAutoOrScaleIndent)(props['my'], scaleIndent),
47
+ marginLeft: (0, _indentStyles.getAutoOrScaleIndent)(props['ml'], scaleIndent) || (0, _indentStyles.getAutoOrScaleIndent)(props['mx'], scaleIndent),
48
+ marginRight: (0, _indentStyles.getAutoOrScaleIndent)(props['mr'], scaleIndent) || (0, _indentStyles.getAutoOrScaleIndent)(props['mx'], scaleIndent),
49
+ padding: (0, _indentStyles.getAutoOrScaleIndent)(props['p'], scaleIndent),
50
+ paddingTop: (0, _indentStyles.getAutoOrScaleIndent)(props['pt'], scaleIndent) || (0, _indentStyles.getAutoOrScaleIndent)(props['py'], scaleIndent),
51
+ paddingBottom: (0, _indentStyles.getAutoOrScaleIndent)(props['pb'], scaleIndent) || (0, _indentStyles.getAutoOrScaleIndent)(props['py'], scaleIndent),
52
+ paddingLeft: (0, _indentStyles.getAutoOrScaleIndent)(props['pl'], scaleIndent) || (0, _indentStyles.getAutoOrScaleIndent)(props['px'], scaleIndent),
53
+ paddingRight: (0, _indentStyles.getAutoOrScaleIndent)(props['pr'], scaleIndent) || (0, _indentStyles.getAutoOrScaleIndent)(props['px'], scaleIndent)
76
54
  });
77
55
  }
78
56
  function useBox(props, ref) {
@@ -1 +1 @@
1
- {"version":3,"file":"useBox.js","names":["_core","require","_propsForElement","_interopRequireDefault","_classnames","_react","_utils","style","sstyled","insert","removeUndefinedKeys","obj","Object","entries","reduce","acc","key","value","undefined","getSize","size","calculateIndentStyles","props","scaleIndent","display","width","height","minWidth","maxWidth","minHeight","maxHeight","position","top","left","bottom","right","inset","flex","zIndex","textAlign","margin","getAutoOrScaleIndent","marginTop","marginBottom","marginLeft","marginRight","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","useBox","ref","tag","Tag","className","styleProp","boxSizing","inline","innerOutline","invertOutline","inAfterOutline","w","h","wMin","wMax","hMin","hMax","m","mt","mb","my","ml","mr","mx","p","pt","pb","py","pl","pr","px","css","other","indentStyles","React","useMemo","styles","Fragment","children","cn","SBoxSizing","SBoxInline","SBoxInnerOutline","assign","propsForElement"],"sources":["../../../../../src/components/flex-box/Box/useBox.tsx"],"sourcesContent":["import { sstyled, type UnknownProperties, type IStyledProps } from '@semcore/core';\nimport propsForElement from '@semcore/core/lib/utils/propsForElement';\nimport cn from 'classnames';\nimport type { Properties, Property } from 'csstype';\nimport React from 'react';\n\nimport style from '../style/use-box.shadow.css';\nimport { getAutoOrScaleIndent } from '../utils';\n\nexport function removeUndefinedKeys<T extends {}>(obj: T) {\n return Object.entries(obj).reduce((acc: any, [key, value]) => {\n if (value !== undefined) {\n acc[key] = value;\n }\n return acc;\n }, {});\n}\n\nfunction getSize(size: any) {\n if (typeof size !== 'number') {\n return size;\n }\n if (size < 1) {\n return `${100 * size}%`;\n }\n if (size >= 1) {\n return `${size}px`;\n }\n}\n\nexport type BoxProps = IStyledProps & {\n /**\n * CSS `display` property\n */\n display?: Property.Display;\n\n /** Sets the `inline-block` property */\n inline?: boolean;\n\n /** CSS `box-sizing: border-box` property */\n boxSizing?: boolean | 'border-box';\n\n /** CSS `flex` property */\n flex?: Property.Flex<string>;\n\n /** CSS `margin` property */\n m?: number | string;\n\n /** CSS `margin-top` property */\n mt?: number | string;\n\n /** CSS `margin-right` property */\n mr?: number | string;\n\n /** CSS `margin-bottom` property */\n mb?: number | string;\n\n /** CSS `margin-left` property */\n ml?: number | string;\n\n /** CSS `margin-left` and `margin-right` property */\n mx?: number | string;\n\n /** CSS `margin-top` and `margin-bottom` property */\n my?: number | string;\n\n /** CSS `padding` property */\n p?: number | string;\n\n /** CSS `padding-top` property */\n pt?: number | string;\n\n /** CSS `padding-right` property */\n pr?: number | string;\n\n /** CSS `padding-bottom` property */\n pb?: number | string;\n\n /** CSS `padding-left` property */\n pl?: number | string;\n\n /** CSS `padding-left` and `padding-right` property */\n px?: number | string;\n\n /** CSS `padding-top` and `padding-bottom` property */\n py?: number | string;\n\n /**\n * CSS `width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n w?: number | string;\n\n /**\n * CSS `min-width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n wMin?: number | string;\n\n /**\n * CSS `max-width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n wMax?: number | string;\n\n /**\n * CSS `height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n h?: number | string;\n\n /**\n * CSS `min-height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n hMin?: number | string;\n\n /**\n * CSS `max-height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n hMax?: number | string;\n\n /**\n * Multiplier of all indents. For example, if you specify a margin-top equal to 3 (mt = {3}), it will be 12px (3 * 4 = 12).\n * @default 4\n */\n scaleIndent?: number;\n\n /**\n * Flag for render outline inside box\n * @default false\n */\n innerOutline?: boolean;\n\n /**\n * Flag for render inverted outline\n * @default false\n */\n invertOutline?: boolean;\n\n /**\n * Flag for render outline in the ::after element\n * @default false\n */\n inAfterOutline?: boolean;\n /** CSS `position` property */\n position?: Property.Position;\n /** CSS `top` property */\n top?: number | string;\n /** CSS `left` property */\n left?: number | string;\n /** CSS `bottom` property */\n bottom?: number | string;\n /** CSS `right` property */\n right?: number | string;\n /** CSS `inset` property */\n inset?: string;\n /** CSS `z-index` property */\n zIndex?: number;\n /** CSS `text-align` property */\n textAlign?: Property.TextAlign;\n /** Box content */\n children?: React.ReactNode;\n};\n\n/** @deprecated */\nexport interface IBoxProps extends BoxProps, UnknownProperties {\n /**\n * HTML tag name for the displayed item\n * @default div\n */\n tag?: React.ElementType | string;\n}\n\nfunction calculateIndentStyles(props: BoxProps, scaleIndent: number) {\n return removeUndefinedKeys({\n display: props['display'],\n width: getSize(props['w']),\n height: getSize(props['h']),\n minWidth: getSize(props['wMin']),\n maxWidth: getSize(props['wMax']),\n minHeight: getSize(props['hMin']),\n maxHeight: getSize(props['hMax']),\n position: props['position'],\n top: getSize(props['top']),\n left: getSize(props['left']),\n bottom: getSize(props['bottom']),\n right: getSize(props['right']),\n inset: props.inset,\n flex: props.flex,\n zIndex: props.zIndex,\n textAlign: props.textAlign,\n\n margin: getAutoOrScaleIndent(props['m'], scaleIndent),\n marginTop:\n getAutoOrScaleIndent(props['mt'], scaleIndent) ||\n getAutoOrScaleIndent(props['my'], scaleIndent),\n marginBottom:\n getAutoOrScaleIndent(props['mb'], scaleIndent) ||\n getAutoOrScaleIndent(props['my'], scaleIndent),\n marginLeft:\n getAutoOrScaleIndent(props['ml'], scaleIndent) ||\n getAutoOrScaleIndent(props['mx'], scaleIndent),\n marginRight:\n getAutoOrScaleIndent(props['mr'], scaleIndent) ||\n getAutoOrScaleIndent(props['mx'], scaleIndent),\n\n padding: getAutoOrScaleIndent(props['p'], scaleIndent),\n paddingTop:\n getAutoOrScaleIndent(props['pt'], scaleIndent) ||\n getAutoOrScaleIndent(props['py'], scaleIndent),\n paddingBottom:\n getAutoOrScaleIndent(props['pb'], scaleIndent) ||\n getAutoOrScaleIndent(props['py'], scaleIndent),\n paddingLeft:\n getAutoOrScaleIndent(props['pl'], scaleIndent) ||\n getAutoOrScaleIndent(props['px'], scaleIndent),\n paddingRight:\n getAutoOrScaleIndent(props['pr'], scaleIndent) ||\n getAutoOrScaleIndent(props['px'], scaleIndent),\n });\n}\n\nexport default function useBox<T extends BoxProps>(\n props: T,\n ref: React.Ref<HTMLElement>,\n): [React.ElementType | string, any] {\n const {\n tag: Tag = 'div',\n className,\n style: styleProp,\n scaleIndent = 4,\n display,\n boxSizing,\n inline,\n innerOutline,\n invertOutline,\n inAfterOutline,\n flex,\n w,\n h,\n wMin,\n wMax,\n hMin,\n hMax,\n m,\n mt,\n mb,\n my,\n ml,\n mr,\n mx,\n p,\n pt,\n pb,\n py,\n pl,\n pr,\n px,\n css,\n position,\n top,\n left,\n bottom,\n right,\n inset,\n zIndex,\n ...other\n } = props as any;\n\n const indentStyles: Properties = React.useMemo(() => {\n return calculateIndentStyles(props, scaleIndent);\n }, [\n scaleIndent,\n display,\n w,\n h,\n wMin,\n wMax,\n hMin,\n hMax,\n flex,\n m,\n mt,\n mb,\n my,\n ml,\n mr,\n mx,\n p,\n pt,\n pb,\n py,\n pl,\n pr,\n px,\n position,\n top,\n left,\n bottom,\n right,\n inset,\n zIndex,\n ]);\n\n const styles = sstyled(style);\n\n if (Tag === React.Fragment) return [React.Fragment, { children: props.children }];\n\n return [\n Tag,\n {\n ref,\n 'className':\n cn(\n styles.cn('SBox', {\n SBoxSizing: boxSizing,\n SBoxInline: inline,\n SBoxInnerOutline: innerOutline,\n inAfterOutline: inAfterOutline === true ? 'true' : 'false',\n invertOutline,\n }).className,\n className,\n ) || undefined,\n 'style': Object.assign({}, styleProp, css, indentStyles),\n 'data-ui-name': 'Box',\n ...propsForElement(other, Tag),\n },\n ];\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF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IACF,CAAC,CAAC,CAACL,SAAS,EACZA,SACF,CAAC,IAAIrC,SAAS;IAChB,OAAO,EAAEN,MAAM,CAACkF,MAAM,CAAC,CAAC,CAAC,EAAEtC,SAAS,EAAE0B,GAAG,EAAEE,YAAY,CAAC;IACxD,cAAc,EAAE,KAAK;IACrB,GAAG,IAAAW,wBAAe,EAACZ,KAAK,EAAE7B,GAAG;EAC/B,CAAC,CACF;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useBox.js","names":["_core","require","_indentStyles","_propsForElement","_interopRequireDefault","_classnames","_react","style","sstyled","insert","calculateIndentStyles","props","scaleIndent","removeUndefinedKeys","display","width","getSize","height","minWidth","maxWidth","minHeight","maxHeight","position","top","left","bottom","right","inset","flex","zIndex","textAlign","margin","getAutoOrScaleIndent","marginTop","marginBottom","marginLeft","marginRight","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","useBox","ref","tag","Tag","className","styleProp","boxSizing","inline","innerOutline","invertOutline","inAfterOutline","w","h","wMin","wMax","hMin","hMax","m","mt","mb","my","ml","mr","mx","p","pt","pb","py","pl","pr","px","css","other","indentStyles","React","useMemo","styles","Fragment","children","cn","SBoxSizing","SBoxInline","SBoxInnerOutline","undefined","Object","assign","propsForElement"],"sources":["../../../../../src/components/flex-box/Box/useBox.tsx"],"sourcesContent":["import { sstyled, type UnknownProperties, type IStyledProps } from '@semcore/core';\nimport { getAutoOrScaleIndent, removeUndefinedKeys, getSize } from '@semcore/core/lib/utils/indentStyles';\nimport propsForElement from '@semcore/core/lib/utils/propsForElement';\nimport cn from 'classnames';\nimport type { Properties, Property } from 'csstype';\nimport React from 'react';\n\nimport style from '../style/use-box.shadow.css';\n\nexport type BoxProps = IStyledProps & {\n /**\n * CSS `display` property\n */\n display?: Property.Display;\n\n /** Sets the `inline-block` property */\n inline?: boolean;\n\n /** CSS `box-sizing: border-box` property */\n boxSizing?: boolean | 'border-box';\n\n /** CSS `flex` property */\n flex?: Property.Flex<string>;\n\n /** CSS `margin` property */\n m?: number | string;\n\n /** CSS `margin-top` property */\n mt?: number | string;\n\n /** CSS `margin-right` property */\n mr?: number | string;\n\n /** CSS `margin-bottom` property */\n mb?: number | string;\n\n /** CSS `margin-left` property */\n ml?: number | string;\n\n /** CSS `margin-left` and `margin-right` property */\n mx?: number | string;\n\n /** CSS `margin-top` and `margin-bottom` property */\n my?: number | string;\n\n /** CSS `padding` property */\n p?: number | string;\n\n /** CSS `padding-top` property */\n pt?: number | string;\n\n /** CSS `padding-right` property */\n pr?: number | string;\n\n /** CSS `padding-bottom` property */\n pb?: number | string;\n\n /** CSS `padding-left` property */\n pl?: number | string;\n\n /** CSS `padding-left` and `padding-right` property */\n px?: number | string;\n\n /** CSS `padding-top` and `padding-bottom` property */\n py?: number | string;\n\n /**\n * CSS `width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n w?: number | string;\n\n /**\n * CSS `min-width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n wMin?: number | string;\n\n /**\n * CSS `max-width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n wMax?: number | string;\n\n /**\n * CSS `height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n h?: number | string;\n\n /**\n * CSS `min-height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n hMin?: number | string;\n\n /**\n * CSS `max-height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n hMax?: number | string;\n\n /**\n * Multiplier of all indents. For example, if you specify a margin-top equal to 3 (mt = {3}), it will be 12px (3 * 4 = 12).\n * @default 4\n */\n scaleIndent?: number;\n\n /**\n * Flag for render outline inside box\n * @default false\n */\n innerOutline?: boolean;\n\n /**\n * Flag for render inverted outline\n * @default false\n */\n invertOutline?: boolean;\n\n /**\n * Flag for render outline in the ::after element\n * @default false\n */\n inAfterOutline?: boolean;\n /** CSS `position` property */\n position?: Property.Position;\n /** CSS `top` property */\n top?: number | string;\n /** CSS `left` property */\n left?: number | string;\n /** CSS `bottom` property */\n bottom?: number | string;\n /** CSS `right` property */\n right?: number | string;\n /** CSS `inset` property */\n inset?: string;\n /** CSS `z-index` property */\n zIndex?: number;\n /** CSS `text-align` property */\n textAlign?: Property.TextAlign;\n /** Box content */\n children?: React.ReactNode;\n};\n\n/** @deprecated */\nexport interface IBoxProps extends BoxProps, UnknownProperties {\n /**\n * HTML tag name for the displayed item\n * @default div\n */\n tag?: React.ElementType | string;\n}\n\nfunction calculateIndentStyles(props: BoxProps, scaleIndent: number) {\n return removeUndefinedKeys({\n display: props['display'],\n width: getSize(props['w']),\n height: getSize(props['h']),\n minWidth: getSize(props['wMin']),\n maxWidth: getSize(props['wMax']),\n minHeight: getSize(props['hMin']),\n maxHeight: getSize(props['hMax']),\n position: props['position'],\n top: getSize(props['top']),\n left: getSize(props['left']),\n bottom: getSize(props['bottom']),\n right: getSize(props['right']),\n inset: props.inset,\n flex: props.flex,\n zIndex: props.zIndex,\n textAlign: props.textAlign,\n\n margin: getAutoOrScaleIndent(props['m'], scaleIndent),\n marginTop:\n getAutoOrScaleIndent(props['mt'], scaleIndent) ||\n getAutoOrScaleIndent(props['my'], scaleIndent),\n marginBottom:\n getAutoOrScaleIndent(props['mb'], scaleIndent) ||\n getAutoOrScaleIndent(props['my'], scaleIndent),\n marginLeft:\n getAutoOrScaleIndent(props['ml'], scaleIndent) ||\n getAutoOrScaleIndent(props['mx'], scaleIndent),\n marginRight:\n getAutoOrScaleIndent(props['mr'], scaleIndent) ||\n getAutoOrScaleIndent(props['mx'], scaleIndent),\n\n padding: getAutoOrScaleIndent(props['p'], scaleIndent),\n paddingTop:\n getAutoOrScaleIndent(props['pt'], scaleIndent) ||\n getAutoOrScaleIndent(props['py'], scaleIndent),\n paddingBottom:\n getAutoOrScaleIndent(props['pb'], scaleIndent) ||\n getAutoOrScaleIndent(props['py'], scaleIndent),\n paddingLeft:\n getAutoOrScaleIndent(props['pl'], scaleIndent) ||\n getAutoOrScaleIndent(props['px'], scaleIndent),\n paddingRight:\n getAutoOrScaleIndent(props['pr'], scaleIndent) ||\n getAutoOrScaleIndent(props['px'], scaleIndent),\n });\n}\n\nexport default function useBox<T extends BoxProps>(\n props: T,\n ref: React.Ref<HTMLElement>,\n): [React.ElementType | string, any] {\n const {\n tag: Tag = 'div',\n className,\n style: styleProp,\n scaleIndent = 4,\n display,\n boxSizing,\n inline,\n innerOutline,\n invertOutline,\n inAfterOutline,\n flex,\n w,\n h,\n wMin,\n wMax,\n hMin,\n hMax,\n m,\n mt,\n mb,\n my,\n ml,\n mr,\n mx,\n p,\n pt,\n pb,\n py,\n pl,\n pr,\n px,\n css,\n position,\n top,\n left,\n bottom,\n right,\n inset,\n zIndex,\n ...other\n } = props as any;\n\n const indentStyles: Properties = React.useMemo(() => {\n return calculateIndentStyles(props, scaleIndent);\n }, [\n scaleIndent,\n display,\n w,\n h,\n wMin,\n wMax,\n hMin,\n hMax,\n flex,\n m,\n mt,\n mb,\n my,\n ml,\n mr,\n mx,\n p,\n pt,\n pb,\n py,\n pl,\n pr,\n px,\n position,\n top,\n left,\n bottom,\n right,\n inset,\n zIndex,\n ]);\n\n const styles = sstyled(style);\n\n if (Tag === React.Fragment) return [React.Fragment, { children: props.children }];\n\n return [\n Tag,\n {\n ref,\n 'className':\n cn(\n styles.cn('SBox', {\n SBoxSizing: boxSizing,\n SBoxInline: inline,\n SBoxInnerOutline: innerOutline,\n inAfterOutline: inAfterOutline === true ? 'true' : 'false',\n invertOutline,\n }).className,\n className,\n ) || undefined,\n 'style': Object.assign({}, styleProp, css, indentStyles),\n 'data-ui-name': 'Box',\n ...propsForElement(other, Tag),\n },\n ];\n}\n"],"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DC,CAAC,EACDC,IAAI,EACJC,IAAI,EACJC,IAAI,EACJC,IAAI,EACJ9B,IAAI,EACJ+B,CAAC,EACDC,EAAE,EACFC,EAAE,EACFC,EAAE,EACFC,EAAE,EACFC,EAAE,EACFC,EAAE,EACFC,CAAC,EACDC,EAAE,EACFC,EAAE,EACFC,EAAE,EACFC,EAAE,EACFC,EAAE,EACFC,EAAE,EACFlD,QAAQ,EACRC,GAAG,EACHC,IAAI,EACJC,MAAM,EACNC,KAAK,EACLC,KAAK,EACLE,MAAM,CACP,CAAC;EAEF,MAAMiD,MAAM,GAAG,IAAAtE,aAAO,EAACD,KAAK,CAAC;EAE7B,IAAIsC,GAAG,KAAK+B,cAAK,CAACG,QAAQ,EAAE,OAAO,CAACH,cAAK,CAACG,QAAQ,EAAE;IAAEC,QAAQ,EAAErE,KAAK,CAACqE;EAAS,CAAC,CAAC;EAEjF,OAAO,CACLnC,GAAG,EACH;IACEF,GAAG;IACH,WAAW,EACT,IAAAsC,mBAAE,EACAH,MAAM,CAACG,EAAE,CAAC,MAAM,EAAE;MAChBC,UAAU,EAAElC,SAAS;MACrBmC,UAAU,EAAElC,MAAM;MAClBmC,gBAAgB,EAAElC,YAAY;MAC9BE,cAAc,EAAEA,cAAc,KAAK,IAAI,GAAG,MAAM,GAAG,OAAO;MAC1DD;IACF,CAAC,CAAC,CAACL,SAAS,EACZA,SACF,CAAC,IAAIuC,SAAS;IAChB,OAAO,EAAEC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAExC,SAAS,EAAE0B,GAAG,EAAEE,YAAY,CAAC;IACxD,cAAc,EAAE,KAAK;IACrB,GAAG,IAAAa,wBAAe,EAACd,KAAK,EAAE7B,GAAG;EAC/B,CAAC,CACF;AACH","ignoreList":[]}
@@ -1,16 +1,15 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = useFlex;
9
8
  var _core = require("@semcore/core");
9
+ var _indentStyles = require("@semcore/core/lib/utils/indentStyles");
10
10
  var _classnames = _interopRequireDefault(require("classnames"));
11
11
  var _react = _interopRequireDefault(require("react"));
12
- var _useBox = _interopRequireWildcard(require("../Box/useBox"));
13
- var _utils = require("../utils");
12
+ var _useBox = _interopRequireDefault(require("../Box/useBox"));
14
13
  /*!__reshadow-styles__:"../style/use-flex.shadow.css"*/
15
14
  const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SFlex_fqcaq_gg_{display:flex}.___SFlex_fqcaq_gg_.__inline_fqcaq_gg_{display:inline-flex}", /*__inner_css_end__*/"fqcaq_gg_"),
16
15
  /*__reshadow_css_end__*/
@@ -24,14 +23,14 @@ function calculateFlexStyles(props) {
24
23
  column: 'column-reverse'
25
24
  };
26
25
  const scaleIndent = props.scaleIndent ?? 4;
27
- return (0, _useBox.removeUndefinedKeys)({
26
+ return (0, _indentStyles.removeUndefinedKeys)({
28
27
  alignItems: props.alignItems,
29
28
  alignContent: props.alignContent,
30
29
  justifyContent: props.justifyContent,
31
30
  flexWrap: props.flexWrap ? `wrap${props.reverse ? '-reverse' : ''}` : undefined,
32
31
  flexDirection: props.reverse && DirectionReverse[props.direction] || props.direction,
33
- rowGap: (0, _utils.getAutoOrScaleIndent)(props.rowGap || props.gap, scaleIndent),
34
- columnGap: (0, _utils.getAutoOrScaleIndent)(props.columnGap || props.gap, scaleIndent)
32
+ rowGap: (0, _indentStyles.getAutoOrScaleIndent)(props.rowGap || props.gap, scaleIndent),
33
+ columnGap: (0, _indentStyles.getAutoOrScaleIndent)(props.columnGap || props.gap, scaleIndent)
35
34
  });
36
35
  }
37
36
  function useFlex(props, ref) {
@@ -1 +1 @@
1
- {"version":3,"file":"useFlex.js","names":["_core","require","_classnames","_interopRequireDefault","_react","_useBox","_interopRequireWildcard","_utils","style","sstyled","insert","calculateFlexStyles","props","DirectionReverse","row","column","scaleIndent","removeUndefinedKeys","alignItems","alignContent","justifyContent","flexWrap","reverse","undefined","flexDirection","direction","rowGap","getAutoOrScaleIndent","gap","columnGap","useFlex","ref","Tag","className","styleProp","other","useBox","inline","flexStyles","React","useMemo","styles","Fragment","children","cn","Object","assign"],"sources":["../../../../../src/components/flex-box/Flex/useFlex.tsx"],"sourcesContent":["import { sstyled } from '@semcore/core';\nimport cn from 'classnames';\nimport type { Property, Properties } from 'csstype';\nimport React from 'react';\n\nimport useBox, { type BoxProps, removeUndefinedKeys } from '../Box/useBox';\nimport style from '../style/use-flex.shadow.css';\nimport { getAutoOrScaleIndent } from '../utils';\n\nexport type FlexProps = BoxProps & {\n /**\n * It manages the `inline-flex` property\n */\n inline?: boolean;\n /**\n * Adds the `reverse` property to `flex-direction`\n */\n reverse?: boolean;\n /**\n * It manages the `flex-wrap` property\n */\n flexWrap?: boolean;\n /**\n * It manages the `flex-direction` property\n */\n direction?: Property.FlexDirection;\n /**\n * It manages the `align-items` property\n */\n alignItems?: Property.AlignItems;\n /**\n * It manages the `align-content` property\n */\n alignContent?: Property.AlignContent;\n /**\n * CSS `justify-content` property\n */\n justifyContent?: Property.JustifyContent;\n /**\n * CSS `gap` property\n */\n gap?: Property.Gap<number>;\n /**\n * CSS `gap` property\n */\n rowGap?: Property.RowGap<number>;\n /**\n * CSS `gap` property\n */\n columnGap?: Property.ColumnGap<number>;\n\n /**\n * Multiplier of all indents. For example, if you specify a margin-top equal to 3 (mt = {3}), it will be 12px (3 * 4 = 12).\n * @default 4\n */\n scaleIndent?: number;\n};\n\nfunction calculateFlexStyles(props: any) {\n const DirectionReverse: Record<string, string> = {\n row: 'row-reverse',\n column: 'column-reverse',\n };\n\n const scaleIndent = props.scaleIndent ?? 4;\n\n return removeUndefinedKeys({\n alignItems: props.alignItems,\n alignContent: props.alignContent,\n justifyContent: props.justifyContent,\n flexWrap: props.flexWrap ? `wrap${props.reverse ? '-reverse' : ''}` : undefined,\n flexDirection: (props.reverse && DirectionReverse[props.direction]) || props.direction,\n rowGap: getAutoOrScaleIndent(props.rowGap || props.gap, scaleIndent),\n columnGap: getAutoOrScaleIndent(props.columnGap || props.gap, scaleIndent),\n });\n}\n\nexport default function useFlex<T extends FlexProps>(\n props: T,\n ref: React.Ref<HTMLElement>,\n): [React.ElementType | string, any] {\n const [Tag, { className, style: styleProp, ...other }] = useBox(\n {\n 'data-ui-name': 'Flex',\n ...props,\n 'inline': false,\n },\n ref,\n );\n const {\n inline,\n flexWrap,\n direction,\n reverse,\n alignItems,\n alignContent,\n justifyContent,\n gap,\n rowGap,\n columnGap,\n scaleIndent,\n } = props;\n\n const flexStyles: Properties = React.useMemo(() => {\n return calculateFlexStyles(props);\n }, [\n flexWrap,\n direction,\n reverse,\n alignItems,\n alignContent,\n justifyContent,\n gap,\n rowGap,\n columnGap,\n scaleIndent,\n ]);\n\n const styles = sstyled(style);\n\n if (Tag === React.Fragment) return [React.Fragment, { children: props.children }];\n\n return [\n Tag,\n {\n className:\n cn(\n styles.cn('SFlex', {\n inline: inline,\n }).className,\n className,\n ) || undefined,\n style: Object.assign({}, styleProp, flexStyles),\n ...other,\n },\n ];\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,OAAA,GAAAC,uBAAA,CAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AAAgD;AAAA,MAAAO,KAAA,8BAAAR,KAAA,CAAAS,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;AAAA;AAmDhD,SAASC,mBAAmBA,CAACC,KAAU,EAAE;EACvC,MAAMC,gBAAwC,GAAG;IAC/CC,GAAG,EAAE,aAAa;IAClBC,MAAM,EAAE;EACV,CAAC;EAED,MAAMC,WAAW,GAAGJ,KA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AAO,EACPJ,UAAU,EACVC,YAAY,EACZC,cAAc,EACdQ,GAAG,EACHF,MAAM,EACNG,SAAS,EACTb,WAAW,CACZ,CAAC;EAEF,MAAMyB,MAAM,GAAG,IAAAhC,aAAO,EAACD,KAAK,CAAC;EAE7B,IAAIwB,GAAG,KAAKO,cAAK,CAACG,QAAQ,EAAE,OAAO,CAACH,cAAK,CAACG,QAAQ,EAAE;IAAEC,QAAQ,EAAE/B,KAAK,CAAC+B;EAAS,CAAC,CAAC;EAEjF,OAAO,CACLX,GAAG,EACH;IACEC,SAAS,EACP,IAAAW,mBAAE,EACAH,MAAM,CAACG,EAAE,CAAC,OAAO,EAAE;MACjBP,MAAM,EAAEA;IACV,CAAC,CAAC,CAACJ,SAAS,EACZA,SACF,CAAC,IAAIV,SAAS;IAChBf,KAAK,EAAEqC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEZ,SAAS,EAAEI,UAAU,CAAC;IAC/C,GAAGH;EACL,CAAC,CACF;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useFlex.js","names":["_core","require","_indentStyles","_classnames","_interopRequireDefault","_react","_useBox","style","sstyled","insert","calculateFlexStyles","props","DirectionReverse","row","column","scaleIndent","removeUndefinedKeys","alignItems","alignContent","justifyContent","flexWrap","reverse","undefined","flexDirection","direction","rowGap","getAutoOrScaleIndent","gap","columnGap","useFlex","ref","Tag","className","styleProp","other","useBox","inline","flexStyles","React","useMemo","styles","Fragment","children","cn","Object","assign"],"sources":["../../../../../src/components/flex-box/Flex/useFlex.tsx"],"sourcesContent":["import { sstyled } from '@semcore/core';\nimport { getAutoOrScaleIndent, removeUndefinedKeys } from '@semcore/core/lib/utils/indentStyles';\nimport cn from 'classnames';\nimport type { Property, Properties } from 'csstype';\nimport React from 'react';\n\nimport useBox, { type BoxProps } from '../Box/useBox';\nimport style from '../style/use-flex.shadow.css';\n\nexport type FlexProps = BoxProps & {\n /**\n * It manages the `inline-flex` property\n */\n inline?: boolean;\n /**\n * Adds the `reverse` property to `flex-direction`\n */\n reverse?: boolean;\n /**\n * It manages the `flex-wrap` property\n */\n flexWrap?: boolean;\n /**\n * It manages the `flex-direction` property\n */\n direction?: Property.FlexDirection;\n /**\n * It manages the `align-items` property\n */\n alignItems?: Property.AlignItems;\n /**\n * It manages the `align-content` property\n */\n alignContent?: Property.AlignContent;\n /**\n * CSS `justify-content` property\n */\n justifyContent?: Property.JustifyContent;\n /**\n * CSS `gap` property\n */\n gap?: Property.Gap<number>;\n /**\n * CSS `gap` property\n */\n rowGap?: Property.RowGap<number>;\n /**\n * CSS `gap` property\n */\n columnGap?: Property.ColumnGap<number>;\n\n /**\n * Multiplier of all indents. For example, if you specify a margin-top equal to 3 (mt = {3}), it will be 12px (3 * 4 = 12).\n * @default 4\n */\n scaleIndent?: number;\n};\n\nfunction calculateFlexStyles(props: any) {\n const DirectionReverse: Record<string, string> = {\n row: 'row-reverse',\n column: 'column-reverse',\n };\n\n const scaleIndent = props.scaleIndent ?? 4;\n\n return removeUndefinedKeys({\n alignItems: props.alignItems,\n alignContent: props.alignContent,\n justifyContent: props.justifyContent,\n flexWrap: props.flexWrap ? `wrap${props.reverse ? '-reverse' : ''}` : undefined,\n flexDirection: (props.reverse && DirectionReverse[props.direction]) || props.direction,\n rowGap: getAutoOrScaleIndent(props.rowGap || props.gap, scaleIndent),\n columnGap: getAutoOrScaleIndent(props.columnGap || props.gap, scaleIndent),\n });\n}\n\nexport default function useFlex<T extends FlexProps>(\n props: T,\n ref: React.Ref<HTMLElement>,\n): [React.ElementType | string, any] {\n const [Tag, { className, style: styleProp, ...other }] = useBox(\n {\n 'data-ui-name': 'Flex',\n ...props,\n 'inline': false,\n },\n ref,\n );\n const {\n inline,\n flexWrap,\n direction,\n reverse,\n alignItems,\n alignContent,\n justifyContent,\n gap,\n rowGap,\n columnGap,\n scaleIndent,\n } = props;\n\n const flexStyles: Properties = React.useMemo(() => {\n return calculateFlexStyles(props);\n }, [\n flexWrap,\n direction,\n reverse,\n alignItems,\n alignContent,\n justifyContent,\n gap,\n rowGap,\n columnGap,\n scaleIndent,\n ]);\n\n const styles = sstyled(style);\n\n if (Tag === React.Fragment) return [React.Fragment, { children: props.children }];\n\n return [\n Tag,\n {\n className:\n cn(\n styles.cn('SFlex', {\n inline: inline,\n }).className,\n className,\n ) || undefined,\n style: Object.assign({}, styleProp, flexStyles),\n ...other,\n },\n ];\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,IAAAK,OAAA,GAAAF,sBAAA,CAAAH,OAAA;AAAsD;AAAA,MAAAM,KAAA,8BAAAP,KAAA,CAAAQ,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;AAAA;AAoDtD,SAASC,mBAAmBA,CAACC,KAAU,EAAE;EACvC,MAAMC,gBAAwC,GAAG;IAC/CC,GAAG,EAAE,aAAa;IAClBC,MAAM,EAAE;EACV,CAAC;EAED,MAAMC,WAAW,GAAGJ,KAAK,CAACI,WAAW,IAAI,CAAC;EAE1C,OAAO,IAAAC,iCAAmB,EAAC;IACzBC,UAAU,EAAEN,KAAK,CAACM,UAAU;IAC5BC,YAAY,EAAEP,KAAK,CAACO,YAAY;IAChCC,cAAc,EAAER,KAAK,CAACQ,cAAc;IACpCC,QAAQ,EAAET,KAAK,CAACS,QAAQ,GAAG,OAAOT,KAAK,CAACU,OAAO,GAAG,UAAU,GAAG,EAAE,EAAE,GAAGC,SAAS;IAC/EC,aAAa,EAAGZ,KAAK,CAACU,OAAO,IAAIT,gBAAgB,CAACD,KAAK,CAACa,SAAS,CAAC,IAAKb,KAAK,CAACa,SAAS;IACtFC,MAAM,EAAE,IAAAC,kCAAoB,EAACf,KAAK,CAACc,MAAM,IAAId,KAAK,CAACgB,GAAG,EAAEZ,WAAW,CAAC;IAC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C,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEZ,SAAS,EAAEI,UAAU,CAAC;IAC/C,GAAGH;EACL,CAAC,CACF;AACH","ignoreList":[]}
@@ -1,5 +1,6 @@
1
1
  import { sstyled as _sstyled } from "@semcore/core";
2
2
  import { sstyled } from '@semcore/core';
3
+ import { getAutoOrScaleIndent, removeUndefinedKeys, getSize } from '@semcore/core/lib/utils/indentStyles';
3
4
  import propsForElement from '@semcore/core/lib/utils/propsForElement';
4
5
  import cn from 'classnames';
5
6
  import React from 'react';
@@ -15,29 +16,7 @@ const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/
15
16
  "__SBox": "___SBox_1suvb_gg_",
16
17
  "_invertOutline": "__invertOutline_1suvb_gg_"
17
18
  });
18
- import { getAutoOrScaleIndent } from '../utils';
19
- export function removeUndefinedKeys(obj) {
20
- return Object.entries(obj).reduce((acc, [key, value]) => {
21
- if (value !== undefined) {
22
- acc[key] = value;
23
- }
24
- return acc;
25
- }, {});
26
- }
27
- function getSize(size) {
28
- if (typeof size !== 'number') {
29
- return size;
30
- }
31
- if (size < 1) {
32
- return `${100 * size}%`;
33
- }
34
- if (size >= 1) {
35
- return `${size}px`;
36
- }
37
- }
38
-
39
19
  /** @deprecated */
40
-
41
20
  function calculateIndentStyles(props, scaleIndent) {
42
21
  return removeUndefinedKeys({
43
22
  display: props['display'],
@@ -1 +1 @@
1
- {"version":3,"file":"useBox.js","names":["sstyled","propsForElement","cn","React","style","_sstyled","insert","getAutoOrScaleIndent","removeUndefinedKeys","obj","Object","entries","reduce","acc","key","value","undefined","getSize","size","calculateIndentStyles","props","scaleIndent","display","width","height","minWidth","maxWidth","minHeight","maxHeight","position","top","left","bottom","right","inset","flex","zIndex","textAlign","margin","marginTop","marginBottom","marginLeft","marginRight","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","useBox","ref","tag","Tag","className","styleProp","boxSizing","inline","innerOutline","invertOutline","inAfterOutline","w","h","wMin","wMax","hMin","hMax","m","mt","mb","my","ml","mr","mx","p","pt","pb","py","pl","pr","px","css","other","indentStyles","useMemo","styles","Fragment","children","SBoxSizing","SBoxInline","SBoxInnerOutline","assign"],"sources":["../../../../../src/components/flex-box/Box/useBox.tsx"],"sourcesContent":["import { sstyled, type UnknownProperties, type IStyledProps } from '@semcore/core';\nimport propsForElement from '@semcore/core/lib/utils/propsForElement';\nimport cn from 'classnames';\nimport type { Properties, Property } from 'csstype';\nimport React from 'react';\n\nimport style from '../style/use-box.shadow.css';\nimport { getAutoOrScaleIndent } from '../utils';\n\nexport function removeUndefinedKeys<T extends {}>(obj: T) {\n return Object.entries(obj).reduce((acc: any, [key, value]) => {\n if (value !== undefined) {\n acc[key] = value;\n }\n return acc;\n }, {});\n}\n\nfunction getSize(size: any) {\n if (typeof size !== 'number') {\n return size;\n }\n if (size < 1) {\n return `${100 * size}%`;\n }\n if (size >= 1) {\n return `${size}px`;\n }\n}\n\nexport type BoxProps = IStyledProps & {\n /**\n * CSS `display` property\n */\n display?: Property.Display;\n\n /** Sets the `inline-block` property */\n inline?: boolean;\n\n /** CSS `box-sizing: border-box` property */\n boxSizing?: boolean | 'border-box';\n\n /** CSS `flex` property */\n flex?: Property.Flex<string>;\n\n /** CSS `margin` property */\n m?: number | string;\n\n /** CSS `margin-top` property */\n mt?: number | string;\n\n /** CSS `margin-right` property */\n mr?: number | string;\n\n /** CSS `margin-bottom` property */\n mb?: number | string;\n\n /** CSS `margin-left` property */\n ml?: number | string;\n\n /** CSS `margin-left` and `margin-right` property */\n mx?: number | string;\n\n /** CSS `margin-top` and `margin-bottom` property */\n my?: number | string;\n\n /** CSS `padding` property */\n p?: number | string;\n\n /** CSS `padding-top` property */\n pt?: number | string;\n\n /** CSS `padding-right` property */\n pr?: number | string;\n\n /** CSS `padding-bottom` property */\n pb?: number | string;\n\n /** CSS `padding-left` property */\n pl?: number | string;\n\n /** CSS `padding-left` and `padding-right` property */\n px?: number | string;\n\n /** CSS `padding-top` and `padding-bottom` property */\n py?: number | string;\n\n /**\n * CSS `width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n w?: number | string;\n\n /**\n * CSS `min-width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n wMin?: number | string;\n\n /**\n * CSS `max-width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n wMax?: number | string;\n\n /**\n * CSS `height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n h?: number | string;\n\n /**\n * CSS `min-height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n hMin?: number | string;\n\n /**\n * CSS `max-height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n hMax?: number | string;\n\n /**\n * Multiplier of all indents. For example, if you specify a margin-top equal to 3 (mt = {3}), it will be 12px (3 * 4 = 12).\n * @default 4\n */\n scaleIndent?: number;\n\n /**\n * Flag for render outline inside box\n * @default false\n */\n innerOutline?: boolean;\n\n /**\n * Flag for render inverted outline\n * @default false\n */\n invertOutline?: boolean;\n\n /**\n * Flag for render outline in the ::after element\n * @default false\n */\n inAfterOutline?: boolean;\n /** CSS `position` property */\n position?: Property.Position;\n /** CSS `top` property */\n top?: number | string;\n /** CSS `left` property */\n left?: number | string;\n /** CSS `bottom` property */\n bottom?: number | string;\n /** CSS `right` property */\n right?: number | string;\n /** CSS `inset` property */\n inset?: string;\n /** CSS `z-index` property */\n zIndex?: number;\n /** CSS `text-align` property */\n textAlign?: Property.TextAlign;\n /** Box content */\n children?: React.ReactNode;\n};\n\n/** @deprecated */\nexport interface IBoxProps extends BoxProps, UnknownProperties {\n /**\n * HTML tag name for the displayed item\n * @default div\n */\n tag?: React.ElementType | string;\n}\n\nfunction calculateIndentStyles(props: BoxProps, scaleIndent: number) {\n return removeUndefinedKeys({\n display: props['display'],\n width: getSize(props['w']),\n height: getSize(props['h']),\n minWidth: getSize(props['wMin']),\n maxWidth: getSize(props['wMax']),\n minHeight: getSize(props['hMin']),\n maxHeight: getSize(props['hMax']),\n position: props['position'],\n top: getSize(props['top']),\n left: getSize(props['left']),\n bottom: getSize(props['bottom']),\n right: getSize(props['right']),\n inset: props.inset,\n flex: props.flex,\n zIndex: props.zIndex,\n textAlign: props.textAlign,\n\n margin: getAutoOrScaleIndent(props['m'], scaleIndent),\n marginTop:\n getAutoOrScaleIndent(props['mt'], scaleIndent) ||\n getAutoOrScaleIndent(props['my'], scaleIndent),\n marginBottom:\n getAutoOrScaleIndent(props['mb'], scaleIndent) ||\n getAutoOrScaleIndent(props['my'], scaleIndent),\n marginLeft:\n getAutoOrScaleIndent(props['ml'], scaleIndent) ||\n getAutoOrScaleIndent(props['mx'], scaleIndent),\n marginRight:\n getAutoOrScaleIndent(props['mr'], scaleIndent) ||\n getAutoOrScaleIndent(props['mx'], scaleIndent),\n\n padding: getAutoOrScaleIndent(props['p'], scaleIndent),\n paddingTop:\n getAutoOrScaleIndent(props['pt'], scaleIndent) ||\n getAutoOrScaleIndent(props['py'], scaleIndent),\n paddingBottom:\n getAutoOrScaleIndent(props['pb'], scaleIndent) ||\n getAutoOrScaleIndent(props['py'], scaleIndent),\n paddingLeft:\n getAutoOrScaleIndent(props['pl'], scaleIndent) ||\n getAutoOrScaleIndent(props['px'], scaleIndent),\n paddingRight:\n getAutoOrScaleIndent(props['pr'], scaleIndent) ||\n getAutoOrScaleIndent(props['px'], scaleIndent),\n });\n}\n\nexport default function useBox<T extends BoxProps>(\n props: T,\n ref: React.Ref<HTMLElement>,\n): [React.ElementType | string, any] {\n const {\n tag: Tag = 'div',\n className,\n style: styleProp,\n scaleIndent = 4,\n display,\n boxSizing,\n inline,\n innerOutline,\n invertOutline,\n inAfterOutline,\n flex,\n w,\n h,\n wMin,\n wMax,\n hMin,\n hMax,\n m,\n mt,\n mb,\n my,\n ml,\n mr,\n mx,\n p,\n pt,\n pb,\n py,\n pl,\n pr,\n px,\n css,\n position,\n top,\n left,\n bottom,\n right,\n inset,\n zIndex,\n ...other\n } = props as any;\n\n const indentStyles: Properties = React.useMemo(() => {\n return calculateIndentStyles(props, scaleIndent);\n }, [\n scaleIndent,\n display,\n w,\n h,\n wMin,\n wMax,\n hMin,\n hMax,\n flex,\n m,\n mt,\n mb,\n my,\n ml,\n mr,\n mx,\n p,\n pt,\n pb,\n py,\n pl,\n pr,\n px,\n position,\n top,\n left,\n bottom,\n right,\n inset,\n zIndex,\n ]);\n\n const styles = sstyled(style);\n\n if (Tag === React.Fragment) return [React.Fragment, { children: props.children }];\n\n return [\n Tag,\n {\n ref,\n 'className':\n cn(\n styles.cn('SBox', {\n SBoxSizing: boxSizing,\n SBoxInline: inline,\n SBoxInnerOutline: innerOutline,\n inAfterOutline: inAfterOutline === true ? 'true' : 'false',\n invertOutline,\n }).className,\n className,\n ) || undefined,\n 'style': Object.assign({}, styleProp, css, indentStyles),\n 'data-ui-name': 'Box',\n ...propsForElement(other, Tag),\n },\n ];\n}\n"],"mappings":";AAAA,SAASA,OAAO,QAAmD,eAAe;AAClF,OAAOC,eAAe,MAAM,yCAAyC;AACrE,OAAOC,EAAE,MAAM,YAAY;AAE3B,OAAOC,KAAK,MAAM,OAAO;AAAC;AAAA,MAAAC,KAAA,8BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAG1B,SAASC,oBAAoB,QAAQ,UAAU;AAE/C,OAAO,SAASC,mBAAmBA,CAAeC,GAAM,EAAE;EACxD,OAAOC,MAAM,CAACC,OAAO,CAACF,GAAG,CAAC,CAACG,MAAM,CAAC,CAACC,GAAQ,EAAE,CAACC,GAAG,EAAEC,KAAK,CAAC,KA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E,EACFC,EAAE,EACFC,EAAE,EACFC,EAAE,EACFC,CAAC,EACDC,EAAE,EACFC,EAAE,EACFC,EAAE,EACFC,EAAE,EACFC,EAAE,EACFC,EAAE,EACFjD,QAAQ,EACRC,GAAG,EACHC,IAAI,EACJC,MAAM,EACNC,KAAK,EACLC,KAAK,EACLE,MAAM,CACP,CAAC;EAEF,MAAM+C,MAAM,GAAGnF,OAAO,CAACI,KAAK,CAAC;EAE7B,IAAI+C,GAAG,KAAKhD,KAAK,CAACiF,QAAQ,EAAE,OAAO,CAACjF,KAAK,CAACiF,QAAQ,EAAE;IAAEC,QAAQ,EAAEjE,KAAK,CAACiE;EAAS,CAAC,CAAC;EAEjF,OAAO,CACLlC,GAAG,EACH;IACEF,GAAG;IACH,WAAW,EACT/C,EAAE,CACAiF,MAAM,CAACjF,EAAE,CAAC,MAAM,EAAE;MAChBoF,UAAU,EAAEhC,SAAS;MACrBiC,UAAU,EAAEhC,MAAM;MAClBiC,gBAAgB,EAAEhC,YAAY;MAC9BE,cAAc,EAAEA,cAAc,KAAK,IAAI,GAAG,MAAM,GAAG,OAAO;MAC1DD;IACF,CAAC,CAAC,CAACL,SAAS,EACZA,SACF,CAAC,IAAIpC,SAAS;IAChB,OAAO,EAAEN,MAAM,CAAC+E,MAAM,CAAC,CAAC,CAAC,EAAEpC,SAAS,EAAE0B,GAAG,EAAEE,YAAY,CAAC;IACxD,cAAc,EAAE,KAAK;IACrB,GAAGhF,eAAe,CAAC+E,KAAK,EAAE7B,GAAG;EAC/B,CAAC,CACF;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useBox.js","names":["sstyled","getAutoOrScaleIndent","removeUndefinedKeys","getSize","propsForElement","cn","React","style","_sstyled","insert","calculateIndentStyles","props","scaleIndent","display","width","height","minWidth","maxWidth","minHeight","maxHeight","position","top","left","bottom","right","inset","flex","zIndex","textAlign","margin","marginTop","marginBottom","marginLeft","marginRight","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","useBox","ref","tag","Tag","className","styleProp","boxSizing","inline","innerOutline","invertOutline","inAfterOutline","w","h","wMin","wMax","hMin","hMax","m","mt","mb","my","ml","mr","mx","p","pt","pb","py","pl","pr","px","css","other","indentStyles","useMemo","styles","Fragment","children","SBoxSizing","SBoxInline","SBoxInnerOutline","undefined","Object","assign"],"sources":["../../../../../src/components/flex-box/Box/useBox.tsx"],"sourcesContent":["import { sstyled, type UnknownProperties, type IStyledProps } from '@semcore/core';\nimport { getAutoOrScaleIndent, removeUndefinedKeys, getSize } from '@semcore/core/lib/utils/indentStyles';\nimport propsForElement from '@semcore/core/lib/utils/propsForElement';\nimport cn from 'classnames';\nimport type { Properties, Property } from 'csstype';\nimport React from 'react';\n\nimport style from '../style/use-box.shadow.css';\n\nexport type BoxProps = IStyledProps & {\n /**\n * CSS `display` property\n */\n display?: Property.Display;\n\n /** Sets the `inline-block` property */\n inline?: boolean;\n\n /** CSS `box-sizing: border-box` property */\n boxSizing?: boolean | 'border-box';\n\n /** CSS `flex` property */\n flex?: Property.Flex<string>;\n\n /** CSS `margin` property */\n m?: number | string;\n\n /** CSS `margin-top` property */\n mt?: number | string;\n\n /** CSS `margin-right` property */\n mr?: number | string;\n\n /** CSS `margin-bottom` property */\n mb?: number | string;\n\n /** CSS `margin-left` property */\n ml?: number | string;\n\n /** CSS `margin-left` and `margin-right` property */\n mx?: number | string;\n\n /** CSS `margin-top` and `margin-bottom` property */\n my?: number | string;\n\n /** CSS `padding` property */\n p?: number | string;\n\n /** CSS `padding-top` property */\n pt?: number | string;\n\n /** CSS `padding-right` property */\n pr?: number | string;\n\n /** CSS `padding-bottom` property */\n pb?: number | string;\n\n /** CSS `padding-left` property */\n pl?: number | string;\n\n /** CSS `padding-left` and `padding-right` property */\n px?: number | string;\n\n /** CSS `padding-top` and `padding-bottom` property */\n py?: number | string;\n\n /**\n * CSS `width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n w?: number | string;\n\n /**\n * CSS `min-width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n wMin?: number | string;\n\n /**\n * CSS `max-width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n wMax?: number | string;\n\n /**\n * CSS `height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n h?: number | string;\n\n /**\n * CSS `min-height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n hMin?: number | string;\n\n /**\n * CSS `max-height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n hMax?: number | string;\n\n /**\n * Multiplier of all indents. For example, if you specify a margin-top equal to 3 (mt = {3}), it will be 12px (3 * 4 = 12).\n * @default 4\n */\n scaleIndent?: number;\n\n /**\n * Flag for render outline inside box\n * @default false\n */\n innerOutline?: boolean;\n\n /**\n * Flag for render inverted outline\n * @default false\n */\n invertOutline?: boolean;\n\n /**\n * Flag for render outline in the ::after element\n * @default false\n */\n inAfterOutline?: boolean;\n /** CSS `position` property */\n position?: Property.Position;\n /** CSS `top` property */\n top?: number | string;\n /** CSS `left` property */\n left?: number | string;\n /** CSS `bottom` property */\n bottom?: number | string;\n /** CSS `right` property */\n right?: number | string;\n /** CSS `inset` property */\n inset?: string;\n /** CSS `z-index` property */\n zIndex?: number;\n /** CSS `text-align` property */\n textAlign?: Property.TextAlign;\n /** Box content */\n children?: React.ReactNode;\n};\n\n/** @deprecated */\nexport interface IBoxProps extends BoxProps, UnknownProperties {\n /**\n * HTML tag name for the displayed item\n * @default div\n */\n tag?: React.ElementType | string;\n}\n\nfunction calculateIndentStyles(props: BoxProps, scaleIndent: number) {\n return removeUndefinedKeys({\n display: props['display'],\n width: getSize(props['w']),\n height: getSize(props['h']),\n minWidth: getSize(props['wMin']),\n maxWidth: getSize(props['wMax']),\n minHeight: getSize(props['hMin']),\n maxHeight: getSize(props['hMax']),\n position: props['position'],\n top: getSize(props['top']),\n left: getSize(props['left']),\n bottom: getSize(props['bottom']),\n right: getSize(props['right']),\n inset: props.inset,\n flex: props.flex,\n zIndex: props.zIndex,\n textAlign: props.textAlign,\n\n margin: getAutoOrScaleIndent(props['m'], scaleIndent),\n marginTop:\n getAutoOrScaleIndent(props['mt'], scaleIndent) ||\n getAutoOrScaleIndent(props['my'], scaleIndent),\n marginBottom:\n getAutoOrScaleIndent(props['mb'], scaleIndent) ||\n getAutoOrScaleIndent(props['my'], scaleIndent),\n marginLeft:\n getAutoOrScaleIndent(props['ml'], scaleIndent) ||\n getAutoOrScaleIndent(props['mx'], scaleIndent),\n marginRight:\n getAutoOrScaleIndent(props['mr'], scaleIndent) ||\n getAutoOrScaleIndent(props['mx'], scaleIndent),\n\n padding: getAutoOrScaleIndent(props['p'], scaleIndent),\n paddingTop:\n getAutoOrScaleIndent(props['pt'], scaleIndent) ||\n getAutoOrScaleIndent(props['py'], scaleIndent),\n paddingBottom:\n getAutoOrScaleIndent(props['pb'], scaleIndent) ||\n getAutoOrScaleIndent(props['py'], scaleIndent),\n paddingLeft:\n getAutoOrScaleIndent(props['pl'], scaleIndent) ||\n getAutoOrScaleIndent(props['px'], scaleIndent),\n paddingRight:\n getAutoOrScaleIndent(props['pr'], scaleIndent) ||\n getAutoOrScaleIndent(props['px'], scaleIndent),\n });\n}\n\nexport default function useBox<T extends BoxProps>(\n props: T,\n ref: React.Ref<HTMLElement>,\n): [React.ElementType | string, any] {\n const {\n tag: Tag = 'div',\n className,\n style: styleProp,\n scaleIndent = 4,\n display,\n boxSizing,\n inline,\n innerOutline,\n invertOutline,\n inAfterOutline,\n flex,\n w,\n h,\n wMin,\n wMax,\n hMin,\n hMax,\n m,\n mt,\n mb,\n my,\n ml,\n mr,\n mx,\n p,\n pt,\n pb,\n py,\n pl,\n pr,\n px,\n css,\n position,\n top,\n left,\n bottom,\n right,\n inset,\n zIndex,\n ...other\n } = props as any;\n\n const indentStyles: Properties = React.useMemo(() => {\n return calculateIndentStyles(props, scaleIndent);\n }, [\n scaleIndent,\n display,\n w,\n h,\n wMin,\n wMax,\n hMin,\n hMax,\n flex,\n m,\n mt,\n mb,\n my,\n ml,\n mr,\n mx,\n p,\n pt,\n pb,\n py,\n pl,\n pr,\n px,\n position,\n top,\n left,\n bottom,\n right,\n inset,\n zIndex,\n ]);\n\n const styles = sstyled(style);\n\n if (Tag === React.Fragment) return [React.Fragment, { children: props.children }];\n\n return [\n Tag,\n {\n ref,\n 'className':\n cn(\n styles.cn('SBox', {\n SBoxSizing: boxSizing,\n SBoxInline: inline,\n SBoxInnerOutline: innerOutline,\n inAfterOutline: inAfterOutline === true ? 'true' : 'false',\n invertOutline,\n }).className,\n className,\n ) || undefined,\n 'style': Object.assign({}, styleProp, css, indentStyles),\n 'data-ui-name': 'Box',\n ...propsForElement(other, Tag),\n },\n ];\n}\n"],"mappings":";AAAA,SAASA,OAAO,QAAmD,eAAe;AAClF,SAASC,oBAAoB,EAAEC,mBAAmB,EAAEC,OAAO,QAAQ,sCAAsC;AACzG,OAAOC,eAAe,MAAM,yCAAyC;AACrE,OAAOC,EAAE,MAAM,YAAY;AAE3B,OAAOC,KAAK,MAAM,OAAO;AAAC;AAAA,MAAAC,KAAA,8BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAkJ1B;AASA,SAASC,qBAAqBA,CAACC,KAAe,EAAEC,WAAmB,EAAE;EACnE,OAAOV,mBAAmB,CAAC;IACzBW,OAAO,EAAEF,KAAK,CAAC,SAAS,CAAC;IACzBG,KAAK,EAAEX,OAAO,CAACQ,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1BI,MAAM,EAAEZ,OAAO,CAACQ,KAAK,CAAC,GAAG,CAAC,CAAC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,OAAO;MAC1DD;IACF,CAAC,CAAC,CAACL,SAAS,EACZA,SACF,CAAC,IAAIqC,SAAS;IAChB,OAAO,EAAEC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEtC,SAAS,EAAE0B,GAAG,EAAEE,YAAY,CAAC;IACxD,cAAc,EAAE,KAAK;IACrB,GAAGpE,eAAe,CAACmE,KAAK,EAAE7B,GAAG;EAC/B,CAAC,CACF;AACH","ignoreList":[]}
@@ -1,8 +1,9 @@
1
1
  import { sstyled as _sstyled } from "@semcore/core";
2
2
  import { sstyled } from '@semcore/core';
3
+ import { getAutoOrScaleIndent, removeUndefinedKeys } from '@semcore/core/lib/utils/indentStyles';
3
4
  import cn from 'classnames';
4
5
  import React from 'react';
5
- import useBox, { removeUndefinedKeys } from '../Box/useBox';
6
+ import useBox from '../Box/useBox';
6
7
  /*!__reshadow-styles__:"../style/use-flex.shadow.css"*/
7
8
  const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SFlex_fqcaq_gg_{display:flex}.___SFlex_fqcaq_gg_.__inline_fqcaq_gg_{display:inline-flex}", /*__inner_css_end__*/"fqcaq_gg_"),
8
9
  /*__reshadow_css_end__*/
@@ -10,7 +11,6 @@ const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/
10
11
  "__SFlex": "___SFlex_fqcaq_gg_",
11
12
  "_inline": "__inline_fqcaq_gg_"
12
13
  });
13
- import { getAutoOrScaleIndent } from '../utils';
14
14
  function calculateFlexStyles(props) {
15
15
  const DirectionReverse = {
16
16
  row: 'row-reverse',
@@ -1 +1 @@
1
- {"version":3,"file":"useFlex.js","names":["sstyled","cn","React","useBox","removeUndefinedKeys","style","_sstyled","insert","getAutoOrScaleIndent","calculateFlexStyles","props","DirectionReverse","row","column","scaleIndent","alignItems","alignContent","justifyContent","flexWrap","reverse","undefined","flexDirection","direction","rowGap","gap","columnGap","useFlex","ref","Tag","className","styleProp","other","inline","flexStyles","useMemo","styles","Fragment","children","Object","assign"],"sources":["../../../../../src/components/flex-box/Flex/useFlex.tsx"],"sourcesContent":["import { sstyled } from '@semcore/core';\nimport cn from 'classnames';\nimport type { Property, Properties } from 'csstype';\nimport React from 'react';\n\nimport useBox, { type BoxProps, removeUndefinedKeys } from '../Box/useBox';\nimport style from '../style/use-flex.shadow.css';\nimport { getAutoOrScaleIndent } from '../utils';\n\nexport type FlexProps = BoxProps & {\n /**\n * It manages the `inline-flex` property\n */\n inline?: boolean;\n /**\n * Adds the `reverse` property to `flex-direction`\n */\n reverse?: boolean;\n /**\n * It manages the `flex-wrap` property\n */\n flexWrap?: boolean;\n /**\n * It manages the `flex-direction` property\n */\n direction?: Property.FlexDirection;\n /**\n * It manages the `align-items` property\n */\n alignItems?: Property.AlignItems;\n /**\n * It manages the `align-content` property\n */\n alignContent?: Property.AlignContent;\n /**\n * CSS `justify-content` property\n */\n justifyContent?: Property.JustifyContent;\n /**\n * CSS `gap` property\n */\n gap?: Property.Gap<number>;\n /**\n * CSS `gap` property\n */\n rowGap?: Property.RowGap<number>;\n /**\n * CSS `gap` property\n */\n columnGap?: Property.ColumnGap<number>;\n\n /**\n * Multiplier of all indents. For example, if you specify a margin-top equal to 3 (mt = {3}), it will be 12px (3 * 4 = 12).\n * @default 4\n */\n scaleIndent?: number;\n};\n\nfunction calculateFlexStyles(props: any) {\n const DirectionReverse: Record<string, string> = {\n row: 'row-reverse',\n column: 'column-reverse',\n };\n\n const scaleIndent = props.scaleIndent ?? 4;\n\n return removeUndefinedKeys({\n alignItems: props.alignItems,\n alignContent: props.alignContent,\n justifyContent: props.justifyContent,\n flexWrap: props.flexWrap ? `wrap${props.reverse ? '-reverse' : ''}` : undefined,\n flexDirection: (props.reverse && DirectionReverse[props.direction]) || props.direction,\n rowGap: getAutoOrScaleIndent(props.rowGap || props.gap, scaleIndent),\n columnGap: getAutoOrScaleIndent(props.columnGap || props.gap, scaleIndent),\n });\n}\n\nexport default function useFlex<T extends FlexProps>(\n props: T,\n ref: React.Ref<HTMLElement>,\n): [React.ElementType | string, any] {\n const [Tag, { className, style: styleProp, ...other }] = useBox(\n {\n 'data-ui-name': 'Flex',\n ...props,\n 'inline': false,\n },\n ref,\n );\n const {\n inline,\n flexWrap,\n direction,\n reverse,\n alignItems,\n alignContent,\n justifyContent,\n gap,\n rowGap,\n columnGap,\n scaleIndent,\n } = props;\n\n const flexStyles: Properties = React.useMemo(() => {\n return calculateFlexStyles(props);\n }, [\n flexWrap,\n direction,\n reverse,\n alignItems,\n alignContent,\n justifyContent,\n gap,\n rowGap,\n columnGap,\n scaleIndent,\n ]);\n\n const styles = sstyled(style);\n\n if (Tag === React.Fragment) return [React.Fragment, { children: props.children }];\n\n return [\n Tag,\n {\n className:\n cn(\n styles.cn('SFlex', {\n inline: inline,\n }).className,\n className,\n ) || undefined,\n style: Object.assign({}, styleProp, flexStyles),\n ...other,\n },\n ];\n}\n"],"mappings":";AAAA,SAASA,OAAO,QAAQ,eAAe;AACvC,OAAOC,EAAE,MAAM,YAAY;AAE3B,OAAOC,KAAK,MAAM,OAAO;AAEzB,OAAOC,MAAM,IAAmBC,mBAAmB,QAAQ,eAAe;AAAC;AAAA,MAAAC,KAAA,8BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;AAAA;AAE3E,SAASC,oBAAoB,QAAQ,UAAU;AAmD/C,SAASC,mBAAmBA,CAACC,KAAU,EAAE;EACvC,MAAMC,gBAAwC,GAAG;IAC/CC,GAAG,EAAE,aAAa;IAClBC,MAAM,EAAE;EACV,CAAC;EAED,MAAMC,WAAW,GAAGJ,KAAK,CAACI,WAAW,IAAI,CAAC;EAE1C,OAAOV,mBAAmB,CAAC;IACzBW,UAAU,EAAEL,KAAK,CAACK,UAAU;IAC5BC,YAAY,EAAEN,KAAK,CAACM,YAAY;IAChCC,cAAc,EAAEP,KAAK,CAACO,cAAc;IACpCC,QAAQ,EAAER,KAAK,CAACQ,QAAQ,GAAG,OAAOR,KAAK,CAACS,OAAO,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AAE3B,KAAK,CAAC2B;EAAS,CAAC,CAAC;EAEjF,OAAO,CACLT,GAAG,EACH;IACEC,SAAS,EACP5B,EAAE,CACAkC,MAAM,CAAClC,EAAE,CAAC,OAAO,EAAE;MACjB+B,MAAM,EAAEA;IACV,CAAC,CAAC,CAACH,SAAS,EACZA,SACF,CAAC,IAAIT,SAAS;IAChBf,KAAK,EAAEiC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAET,SAAS,EAAEG,UAAU,CAAC;IAC/C,GAAGF;EACL,CAAC,CACF;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useFlex.js","names":["sstyled","getAutoOrScaleIndent","removeUndefinedKeys","cn","React","useBox","style","_sstyled","insert","calculateFlexStyles","props","DirectionReverse","row","column","scaleIndent","alignItems","alignContent","justifyContent","flexWrap","reverse","undefined","flexDirection","direction","rowGap","gap","columnGap","useFlex","ref","Tag","className","styleProp","other","inline","flexStyles","useMemo","styles","Fragment","children","Object","assign"],"sources":["../../../../../src/components/flex-box/Flex/useFlex.tsx"],"sourcesContent":["import { sstyled } from '@semcore/core';\nimport { getAutoOrScaleIndent, removeUndefinedKeys } from '@semcore/core/lib/utils/indentStyles';\nimport cn from 'classnames';\nimport type { Property, Properties } from 'csstype';\nimport React from 'react';\n\nimport useBox, { type BoxProps } from '../Box/useBox';\nimport style from '../style/use-flex.shadow.css';\n\nexport type FlexProps = BoxProps & {\n /**\n * It manages the `inline-flex` property\n */\n inline?: boolean;\n /**\n * Adds the `reverse` property to `flex-direction`\n */\n reverse?: boolean;\n /**\n * It manages the `flex-wrap` property\n */\n flexWrap?: boolean;\n /**\n * It manages the `flex-direction` property\n */\n direction?: Property.FlexDirection;\n /**\n * It manages the `align-items` property\n */\n alignItems?: Property.AlignItems;\n /**\n * It manages the `align-content` property\n */\n alignContent?: Property.AlignContent;\n /**\n * CSS `justify-content` property\n */\n justifyContent?: Property.JustifyContent;\n /**\n * CSS `gap` property\n */\n gap?: Property.Gap<number>;\n /**\n * CSS `gap` property\n */\n rowGap?: Property.RowGap<number>;\n /**\n * CSS `gap` property\n */\n columnGap?: Property.ColumnGap<number>;\n\n /**\n * Multiplier of all indents. For example, if you specify a margin-top equal to 3 (mt = {3}), it will be 12px (3 * 4 = 12).\n * @default 4\n */\n scaleIndent?: number;\n};\n\nfunction calculateFlexStyles(props: any) {\n const DirectionReverse: Record<string, string> = {\n row: 'row-reverse',\n column: 'column-reverse',\n };\n\n const scaleIndent = props.scaleIndent ?? 4;\n\n return removeUndefinedKeys({\n alignItems: props.alignItems,\n alignContent: props.alignContent,\n justifyContent: props.justifyContent,\n flexWrap: props.flexWrap ? `wrap${props.reverse ? '-reverse' : ''}` : undefined,\n flexDirection: (props.reverse && DirectionReverse[props.direction]) || props.direction,\n rowGap: getAutoOrScaleIndent(props.rowGap || props.gap, scaleIndent),\n columnGap: getAutoOrScaleIndent(props.columnGap || props.gap, scaleIndent),\n });\n}\n\nexport default function useFlex<T extends FlexProps>(\n props: T,\n ref: React.Ref<HTMLElement>,\n): [React.ElementType | string, any] {\n const [Tag, { className, style: styleProp, ...other }] = useBox(\n {\n 'data-ui-name': 'Flex',\n ...props,\n 'inline': false,\n },\n ref,\n );\n const {\n inline,\n flexWrap,\n direction,\n reverse,\n alignItems,\n alignContent,\n justifyContent,\n gap,\n rowGap,\n columnGap,\n scaleIndent,\n } = props;\n\n const flexStyles: Properties = React.useMemo(() => {\n return calculateFlexStyles(props);\n }, [\n flexWrap,\n direction,\n reverse,\n alignItems,\n alignContent,\n justifyContent,\n gap,\n rowGap,\n columnGap,\n scaleIndent,\n ]);\n\n const styles = sstyled(style);\n\n if (Tag === React.Fragment) return [React.Fragment, { children: props.children }];\n\n return [\n Tag,\n {\n className:\n cn(\n styles.cn('SFlex', {\n inline: inline,\n }).className,\n className,\n ) || undefined,\n style: Object.assign({}, styleProp, flexStyles),\n ...other,\n },\n ];\n}\n"],"mappings":";AAAA,SAASA,OAAO,QAAQ,eAAe;AACvC,SAASC,oBAAoB,EAA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,CAAC,EACDiB,GACF,CAAC;EACD,MAAM;IACJK,MAAM;IACNd,QAAQ;IACRI,SAAS;IACTH,OAAO;IACPJ,UAAU;IACVC,YAAY;IACZC,cAAc;IACdO,GAAG;IACHD,MAAM;IACNE,SAAS;IACTX;EACF,CAAC,GAAGJ,KAAK;EAET,MAAMuB,UAAsB,GAAG7B,KAAK,CAAC8B,OAAO,CAAC,MAAM;IACjD,OAAOzB,mBAAmB,CAACC,KAAK,CAAC;EACnC,CAAC,EAAE,CACDQ,QAAQ,EACRI,SAAS,EACTH,OAAO,EACPJ,UAAU,EACVC,YAAY,EACZC,cAAc,EACdO,GAAG,EACHD,MAAM,EACNE,SAAS,EACTX,WAAW,CACZ,CAAC;EAEF,MAAMqB,MAAM,GAAGnC,OAAO,CAACM,KAAK,CAAC;EAE7B,IAAIsB,GAAG,KAAKxB,KAAK,CAACgC,QAAQ,EAAE,OAAO,CAAChC,KAAK,CAACgC,QAAQ,EAAE;IAAEC,QAAQ,EAAE3B,KAAK,CAAC2B;EAAS,CAAC,CAAC;EAEjF,OAAO,CACLT,GAAG,EACH;IACEC,SAAS,EACP1B,EAAE,CACAgC,MAAM,CAAChC,EAAE,CAAC,OAAO,EAAE;MACjB6B,MAAM,EAAEA;IACV,CAAC,CAAC,CAACH,SAAS,EACZA,SACF,CAAC,IAAIT,SAAS;IAChBd,KAAK,EAAEgC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAET,SAAS,EAAEG,UAAU,CAAC;IAC/C,GAAGF;EACL,CAAC,CACF;AACH","ignoreList":[]}
@@ -1,8 +1,8 @@
1
1
  import { sstyled } from "@semcore/core";
2
+ import { removeUndefinedKeys, getAutoOrScaleIndent, getSize } from "@semcore/core/lib/utils/indentStyles";
2
3
  import propsForElement from "@semcore/core/lib/utils/propsForElement";
3
4
  import cn from "classnames";
4
5
  import React from "react";
5
- import { getAutoOrScaleIndent } from "../utils.mjs";
6
6
  /*!__reshadow-styles__:"../style/use-box.shadow.css"*/
7
7
  const style = (
8
8
  /*__reshadow_css_start__*/
@@ -22,25 +22,6 @@ const style = (
22
22
  "_invertOutline": "__invertOutline_1suvb_gg_"
23
23
  })
24
24
  );
25
- function removeUndefinedKeys(obj) {
26
- return Object.entries(obj).reduce((acc, [key, value]) => {
27
- if (value !== void 0) {
28
- acc[key] = value;
29
- }
30
- return acc;
31
- }, {});
32
- }
33
- function getSize(size) {
34
- if (typeof size !== "number") {
35
- return size;
36
- }
37
- if (size < 1) {
38
- return `${100 * size}%`;
39
- }
40
- if (size >= 1) {
41
- return `${size}px`;
42
- }
43
- }
44
25
  function calculateIndentStyles(props, scaleIndent) {
45
26
  return removeUndefinedKeys({
46
27
  display: props["display"],
@@ -136,6 +117,5 @@ function useBox(props, ref) {
136
117
  }];
137
118
  }
138
119
  export {
139
- useBox as default,
140
- removeUndefinedKeys
120
+ useBox as default
141
121
  };
@@ -1,8 +1,8 @@
1
1
  import { sstyled } from "@semcore/core";
2
+ import { removeUndefinedKeys, getAutoOrScaleIndent } from "@semcore/core/lib/utils/indentStyles";
2
3
  import cn from "classnames";
3
4
  import React from "react";
4
- import useBox, { removeUndefinedKeys } from "../Box/useBox.mjs";
5
- import { getAutoOrScaleIndent } from "../utils.mjs";
5
+ import useBox from "../Box/useBox.mjs";
6
6
  /*!__reshadow-styles__:"../style/use-flex.shadow.css"*/
7
7
  const style = (
8
8
  /*__reshadow_css_start__*/
package/lib/esm/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { defaultBreakpoints } from "./components/breakpoints/index.mjs";
2
2
  import { Col } from "./components/grid/index.mjs";
3
- import { removeUndefinedKeys, default as default2 } from "./components/flex-box/Box/useBox.mjs";
3
+ import { default as default2 } from "./components/flex-box/Box/useBox.mjs";
4
4
  import { default as default3 } from "./components/flex-box/Flex/useFlex.mjs";
5
5
  import { default as default4 } from "./components/grid/Grid.mjs";
6
6
  import { default as default5, animationContext } from "./components/animation/Animation.mjs";
@@ -53,7 +53,6 @@ export {
53
53
  eventCalculate,
54
54
  hideScrollBarsFromScreenReadersContext,
55
55
  isInputTriggerTag,
56
- removeUndefinedKeys,
57
56
  default2 as useBox,
58
57
  default3 as useFlex,
59
58
  useNeighborLocationDetect
@@ -1,7 +1,6 @@
1
1
  import { type UnknownProperties, type IStyledProps } from '@semcore/core';
2
2
  import type { Property } from 'csstype';
3
3
  import React from 'react';
4
- export declare function removeUndefinedKeys<T extends {}>(obj: T): any;
5
4
  export type BoxProps = IStyledProps & {
6
5
  /**
7
6
  * CSS `display` property
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/base-components",
3
3
  "description": "Semrush Base Components",
4
- "version": "17.0.0-prerelease.27",
4
+ "version": "17.0.0-prerelease.29",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/esm/index.mjs",
7
7
  "typings": "lib/types/index.d.ts",
@@ -32,8 +32,8 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/classnames": "2.2.6",
35
- "@semcore/core": "17.0.0-prerelease.27",
36
- "@semcore/testing-utils": "1.0.0"
35
+ "@semcore/testing-utils": "1.0.0",
36
+ "@semcore/core": "17.0.0-prerelease.29"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "pnpm semcore-builder && pnpm vite build"
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getAutoOrScaleIndent = void 0;
7
- const getAutoOrScaleIndent = (indent, scaleIndent) => {
8
- if (typeof indent === 'string') {
9
- return indent;
10
- }
11
- if (typeof indent === 'number' && indent > -1 && indent < 1) {
12
- return `${100 * indent}%`;
13
- }
14
- if (typeof indent === 'number' && (indent >= 1 || indent <= -1)) {
15
- return `${indent * scaleIndent}px`;
16
- }
17
- return indent;
18
- };
19
- exports.getAutoOrScaleIndent = getAutoOrScaleIndent;
20
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","names":["getAutoOrScaleIndent","indent","scaleIndent","exports"],"sources":["../../../../src/components/flex-box/utils.ts"],"sourcesContent":["export const getAutoOrScaleIndent = (indent: number | string | undefined, scaleIndent: number) => {\n if (typeof indent === 'string') {\n return indent;\n }\n if (typeof indent === 'number' && indent > -1 && indent < 1) {\n return `${100 * indent}%`;\n }\n if (typeof indent === 'number' && (indent >= 1 || indent <= -1)) {\n return `${indent * scaleIndent}px`;\n }\n return indent;\n};\n"],"mappings":";;;;;;AAAO,MAAMA,oBAAoB,GAAGA,CAACC,MAAmC,EAAEC,WAAmB,KAAK;EAChG,IAAI,OAAOD,MAAM,KAAK,QAAQ,EAAE;IAC9B,OAAOA,MAAM;EACf;EACA,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAIA,MAAM,GAAG,CAAC,CAAC,IAAIA,MAAM,GAAG,CAAC,EAAE;IAC3D,OAAO,GAAG,GAAG,GAAGA,MAAM,GAAG;EAC3B;EACA,IAAI,OAAOA,MAAM,KAAK,QAAQ,KAAKA,MAAM,IAAI,CAAC,IAAIA,MAAM,IAAI,CAAC,CAAC,CAAC,EAAE;IAC/D,OAAO,GAAGA,MAAM,GAAGC,WAAW,IAAI;EACpC;EACA,OAAOD,MAAM;AACf,CAAC;AAACE,OAAA,CAAAH,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -1,13 +0,0 @@
1
- export const getAutoOrScaleIndent = (indent, scaleIndent) => {
2
- if (typeof indent === 'string') {
3
- return indent;
4
- }
5
- if (typeof indent === 'number' && indent > -1 && indent < 1) {
6
- return `${100 * indent}%`;
7
- }
8
- if (typeof indent === 'number' && (indent >= 1 || indent <= -1)) {
9
- return `${indent * scaleIndent}px`;
10
- }
11
- return indent;
12
- };
13
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","names":["getAutoOrScaleIndent","indent","scaleIndent"],"sources":["../../../../src/components/flex-box/utils.ts"],"sourcesContent":["export const getAutoOrScaleIndent = (indent: number | string | undefined, scaleIndent: number) => {\n if (typeof indent === 'string') {\n return indent;\n }\n if (typeof indent === 'number' && indent > -1 && indent < 1) {\n return `${100 * indent}%`;\n }\n if (typeof indent === 'number' && (indent >= 1 || indent <= -1)) {\n return `${indent * scaleIndent}px`;\n }\n return indent;\n};\n"],"mappings":"AAAA,OAAO,MAAMA,oBAAoB,GAAGA,CAACC,MAAmC,EAAEC,WAAmB,KAAK;EAChG,IAAI,OAAOD,MAAM,KAAK,QAAQ,EAAE;IAC9B,OAAOA,MAAM;EACf;EACA,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAIA,MAAM,GAAG,CAAC,CAAC,IAAIA,MAAM,GAAG,CAAC,EAAE;IAC3D,OAAO,GAAG,GAAG,GAAGA,MAAM,GAAG;EAC3B;EACA,IAAI,OAAOA,MAAM,KAAK,QAAQ,KAAKA,MAAM,IAAI,CAAC,IAAIA,MAAM,IAAI,CAAC,CAAC,CAAC,EAAE;IAC/D,OAAO,GAAGA,MAAM,GAAGC,WAAW,IAAI;EACpC;EACA,OAAOD,MAAM;AACf,CAAC","ignoreList":[]}
@@ -1,15 +0,0 @@
1
- const getAutoOrScaleIndent = (indent, scaleIndent) => {
2
- if (typeof indent === "string") {
3
- return indent;
4
- }
5
- if (typeof indent === "number" && indent > -1 && indent < 1) {
6
- return `${100 * indent}%`;
7
- }
8
- if (typeof indent === "number" && (indent >= 1 || indent <= -1)) {
9
- return `${indent * scaleIndent}px`;
10
- }
11
- return indent;
12
- };
13
- export {
14
- getAutoOrScaleIndent
15
- };
@@ -1 +0,0 @@
1
- export declare const getAutoOrScaleIndent: (indent: number | string | undefined, scaleIndent: number) => string | number | undefined;