@semcore/base-components 17.0.0-prerelease.27 → 17.0.0-prerelease.30
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 +41 -25
- package/lib/cjs/components/flex-box/Box/useBox.js +22 -44
- package/lib/cjs/components/flex-box/Box/useBox.js.map +1 -1
- package/lib/cjs/components/flex-box/Flex/useFlex.js +5 -6
- package/lib/cjs/components/flex-box/Flex/useFlex.js.map +1 -1
- package/lib/cjs/components/hint/Hint.js +6 -2
- package/lib/cjs/components/hint/Hint.js.map +1 -1
- package/lib/es6/components/flex-box/Box/useBox.js +1 -22
- package/lib/es6/components/flex-box/Box/useBox.js.map +1 -1
- package/lib/es6/components/flex-box/Flex/useFlex.js +2 -2
- package/lib/es6/components/flex-box/Flex/useFlex.js.map +1 -1
- package/lib/es6/components/hint/Hint.js +6 -2
- package/lib/es6/components/hint/Hint.js.map +1 -1
- package/lib/esm/components/flex-box/Box/useBox.mjs +2 -22
- package/lib/esm/components/flex-box/Flex/useFlex.mjs +2 -2
- package/lib/esm/components/hint/Hint.mjs +6 -2
- package/lib/esm/index.mjs +1 -2
- package/lib/types/components/flex-box/Box/useBox.d.ts +0 -1
- package/package.json +3 -3
- package/lib/cjs/components/flex-box/utils.js +0 -20
- package/lib/cjs/components/flex-box/utils.js.map +0 -1
- package/lib/es6/components/flex-box/utils.js +0 -13
- package/lib/es6/components/flex-box/utils.js.map +0 -1
- package/lib/esm/components/flex-box/utils.mjs +0 -15
- package/lib/types/components/flex-box/utils.d.ts +0 -1
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-
|
|
5
|
+
## [17.0.0] - 2026-03-09
|
|
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
|
-
-
|
|
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
|
-
-
|
|
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
|
-
-
|
|
40
|
-
-
|
|
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
|
-
-
|
|
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
|
-
-
|
|
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
|
-
-
|
|
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
|
-
-
|
|
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
|
-
-
|
|
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
|
-
-
|
|
92
|
+
- ResizeObserver for the `Wrapper` component in the `ScrollArea`.
|
|
77
93
|
|
|
78
94
|
### Changed
|
|
79
95
|
|
|
80
|
-
-
|
|
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
|
-
-
|
|
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
|
-
-
|
|
94
|
-
-
|
|
95
|
-
-
|
|
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
|
-
-
|
|
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,
|
|
67
|
-
marginTop: (0,
|
|
68
|
-
marginBottom: (0,
|
|
69
|
-
marginLeft: (0,
|
|
70
|
-
marginRight: (0,
|
|
71
|
-
padding: (0,
|
|
72
|
-
paddingTop: (0,
|
|
73
|
-
paddingBottom: (0,
|
|
74
|
-
paddingLeft: (0,
|
|
75
|
-
paddingRight: (0,
|
|
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,OAAA;AACA,IAAAG,WAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,MAAA,GAAAF,sBAAA,CAAAF,OAAA;AAGA,IAAAK,MAAA,GAAAL,OAAA;AAAgD;AAAA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,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"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,W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FC,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 =
|
|
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,
|
|
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,
|
|
34
|
-
columnGap: (0,
|
|
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","
|
|
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,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C,KAAK,CAAC;EACnC,CAAC,EAAE,CACDS,QAAQ,EACRI,SAAS,EACTH,OAAO,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":[]}
|
|
@@ -102,8 +102,12 @@ class HintPopperRoot extends _core.Component {
|
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
componentDidMount() {
|
|
105
|
-
const
|
|
106
|
-
|
|
105
|
+
const {
|
|
106
|
+
triggerRef,
|
|
107
|
+
children
|
|
108
|
+
} = this.asProps;
|
|
109
|
+
const trigger = triggerRef.current;
|
|
110
|
+
if (trigger && children) {
|
|
107
111
|
this.subscribe(trigger);
|
|
108
112
|
}
|
|
109
113
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hint.js","names":["_core","require","_dom","_canUseDOM","_interopRequireDefault","_getAccessibleName","_useCssVariable","_zIndexStacking","_react","_Middleware","_flexBox","_portal","keyframes","sstyled","insert","styles","enhances","zIndexStackingEnhance","cssVariableEnhance","variable","fallback","map","v","Number","parseInt","toString","prop","propToArray","Array","isArray","keyframesMap","Map","HintPopperRoot","Component","constructor","props","_defineProperty2","default","React","createRef","handleFocus","bind","handleBlur","handleMouseEnter","handleMouseLeave","handleKeyDown","state","innerVisible","visible","calculatedPlacement","placement","uncontrolledProps","componentDidMount","trigger","asProps","triggerRef","current","subscribe","componentWillUnmount","unsubscribe","componentDidUpdate","prevProps","requestAnimationFrame","showHint","hideHint","addEventListener","removeEventListener","node","mouseEvent","timeout","showTimeout","hideTimer","clearTimeout","showTimer","window","setTimeout","handlers","popperElement","hintRef","middleware","offset","flip","shift","padding","verticalPlacement","startsWith","undefined","push","Middleware","verticalCursorAnchoring","x","clientX","computePosition","then","y","Object","assign","style","left","top","visibility","setState","hideTimeout","setProperty","e","target","HTMLElement","lastInteraction","isKeyboard","key","stopPropagation","keyframesKey","has","get","keyframe","set","setTriggerAriaLabel","children","textContent","ariaLabel","getAccessibleName","label","setAttribute","render","_ref","_ref2","SHintPopper","Box","Children","parentZIndexStacking","timingFunction","canUseDOM","duration","createElement","Portal","cn","assignProps","defaultVisible","Hint","exports","createComponent"],"sources":["../../../../src/components/hint/Hint.tsx"],"sourcesContent":["import { computePosition, flip, offset, shift, type Placement } from '@floating-ui/dom';\nimport { createComponent, Root, sstyled, Component, lastInteraction } from '@semcore/core';\nimport canUseDOM from '@semcore/core/lib/utils/canUseDOM';\nimport { getAccessibleName } from '@semcore/core/lib/utils/getAccessibleName';\nimport { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';\nimport { zIndexStackingEnhance } from '@semcore/core/lib/utils/zIndexStacking';\nimport type { DataType } from 'csstype';\nimport React from 'react';\n\nimport { Middleware } from './Middleware';\nimport keyframes from '../animation/style/keyframes.shadow.css';\nimport { Box } from '../flex-box';\nimport { Portal } from '../portal';\nimport styles from './style/hint.shadow.css';\n\ntype Handlers = {\n visible: null;\n};\n\nexport type SimpleHintPopperProps = {\n /** Ref to the trigger element */\n triggerRef: React.RefObject<HTMLElement | null>;\n /**\n * The position of the popper relative to the trigger that called it.\n * @default top\n */\n placement?: Placement;\n /**\n * Timer to show and hide the popper\n * @default [500, 500]\n */\n timeout?: DefaultProps['timeout'];\n /**\n * Hint content.\n * Better to use here some short text.\n * */\n children: React.ReactNode;\n\n /** Popper visibility value */\n visible?: boolean;\n /** Default popper visibility\n * @default false */\n defaultVisible?: boolean;\n /** Function called when visibility changes */\n onVisibleChange?: (visible: boolean, e?: Event) => boolean | void;\n};\n\ntype DefaultProps = {\n defaultVisible?: boolean;\n timeout: number | [number, number];\n timingFunction: DataType.EasingFunction;\n placement?: Placement;\n};\n\ntype State = {\n innerVisible: boolean | null;\n calculatedPlacement?: Placement;\n};\n\nconst enhances = [\n zIndexStackingEnhance('z-index-tooltip'),\n cssVariableEnhance({\n variable: '--intergalactic-duration-popper',\n fallback: '200',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'duration',\n }),\n cssVariableEnhance({\n variable: '--intergalactic-spacing-1x',\n fallback: '4',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'offset',\n }),\n cssVariableEnhance({\n variable: '--intergalactic-spacing-1x',\n fallback: '4',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'padding',\n }),\n] as const;\n\nfunction propToArray(prop: number | [number, number]): [number, number] {\n return Array.isArray(prop) ? prop : [prop, prop];\n}\n\nconst keyframesMap = new Map<Placement, string>();\n\nclass HintPopperRoot extends Component<SimpleHintPopperProps, typeof enhances, Handlers, DefaultProps, State> {\n public readonly hintRef = React.createRef<HTMLElement>();\n\n static style = Object.assign(keyframes, styles);\n\n private showTimer?: number;\n private hideTimer?: number;\n\n static enhance = enhances;\n\n static defaultProps: DefaultProps = {\n defaultVisible: false,\n timeout: [500, 500],\n timingFunction: 'ease-out',\n placement: 'top',\n };\n\n constructor(props: SimpleHintPopperProps) {\n super(props);\n\n this.handleFocus = this.handleFocus.bind(this);\n this.handleBlur = this.handleBlur.bind(this);\n this.handleMouseEnter = this.handleMouseEnter.bind(this);\n this.handleMouseLeave = this.handleMouseLeave.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n\n this.state = {\n innerVisible: props.visible ?? null,\n calculatedPlacement: props.placement,\n };\n }\n\n uncontrolledProps() {\n return {\n visible: null,\n };\n }\n\n componentDidMount() {\n const trigger = this.asProps.triggerRef.current;\n\n if (trigger) {\n this.subscribe(trigger);\n }\n }\n\n componentWillUnmount() {\n const trigger = this.asProps.triggerRef.current;\n\n if (trigger) {\n this.unsubscribe(trigger);\n }\n }\n\n componentDidUpdate(prevProps: SimpleHintPopperProps) {\n if (prevProps.visible !== this.props.visible) {\n requestAnimationFrame(() => {\n const trigger = this.props.triggerRef.current;\n\n if (this.props.visible && trigger) {\n this.showHint(trigger);\n } else {\n this.hideHint();\n }\n });\n }\n }\n\n private subscribe(trigger: HTMLElement) {\n trigger.addEventListener('focus', this.handleFocus);\n trigger.addEventListener('blur', this.handleBlur);\n trigger.addEventListener('mouseenter', this.handleMouseEnter);\n trigger.addEventListener('mouseleave', this.handleMouseLeave);\n trigger.addEventListener('keydown', this.handleKeyDown);\n\n if (this.asProps.visible) {\n this.showHint(trigger);\n }\n }\n\n private unsubscribe(trigger: HTMLElement) {\n trigger.removeEventListener('focus', this.handleFocus);\n trigger.removeEventListener('blur', this.handleBlur);\n trigger.removeEventListener('mouseenter', this.handleMouseEnter);\n trigger.removeEventListener('mouseleave', this.handleMouseLeave);\n trigger.removeEventListener('keydown', this.handleKeyDown);\n\n this.hideHint();\n }\n\n private showHint(node: HTMLElement, mouseEvent?: MouseEvent): void {\n const { placement, timeout } = this.asProps;\n\n const showTimeout = Array.isArray(timeout) ? timeout[0] : timeout;\n\n if (this.hideTimer) {\n clearTimeout(this.hideTimer);\n }\n\n this.showTimer = window.setTimeout(() => {\n this.handlers.visible(true);\n\n window.setTimeout(() => {\n const popperElement = this.hintRef.current;\n if (popperElement) {\n const middleware = [\n offset(Number(this.asProps.offset)),\n flip(),\n shift({ padding: Number(this.asProps.padding) }),\n ];\n const verticalPlacement = !placement || placement.startsWith('top') || placement.startsWith('bottom');\n if (mouseEvent !== undefined && verticalPlacement) {\n middleware.push(\n Middleware.verticalCursorAnchoring({ x: mouseEvent.clientX }),\n shift({ padding: Number(this.asProps.padding) }),\n );\n }\n\n computePosition(node, popperElement, {\n placement: placement,\n middleware,\n }).then(({ x, y, placement }) => {\n Object.assign(popperElement.style, {\n left: `${x}px`,\n top: `${y}px`,\n });\n popperElement.style.visibility = 'visible';\n\n this.setState({ innerVisible: true, calculatedPlacement: placement });\n });\n }\n }, 10);\n }, showTimeout);\n }\n\n private hideHint(): void {\n const { timeout } = this.asProps;\n\n const hideTimeout = Array.isArray(timeout) ? timeout[1] : timeout;\n\n if (this.showTimer) {\n clearTimeout(this.showTimer);\n }\n\n this.setState({ innerVisible: false });\n\n this.hideTimer = window.setTimeout(() => {\n this.hintRef.current?.style.setProperty('visibility', 'hidden');\n this.handlers.visible(false);\n this.setState({ innerVisible: null });\n }, hideTimeout);\n }\n\n private handleFocus(e: FocusEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target && lastInteraction.isKeyboard()) {\n this.showHint(e.target);\n }\n }\n\n private handleBlur(e: FocusEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target) {\n this.hideHint();\n }\n }\n\n private handleKeyDown(e: KeyboardEvent): void {\n if (e.key === 'Escape' && e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target && this.state.innerVisible) {\n e.stopPropagation();\n this.hideHint();\n }\n }\n\n private handleMouseEnter(e: MouseEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target) {\n this.showHint(e.target, e);\n }\n }\n\n private handleMouseLeave(e: MouseEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target) {\n this.hideHint();\n }\n }\n\n private keyframesKey(placement?: Placement) {\n if (!placement) {\n return 'opacity';\n }\n\n if (keyframesMap.has(placement)) {\n return keyframesMap.get(placement)!;\n }\n\n let keyframe: string = 'opacity';\n\n if (placement.startsWith('left')) keyframe = 'scale-left';\n if (placement.startsWith('right')) keyframe = 'scale-right';\n if (placement.startsWith('bottom')) keyframe = 'scale-bottom';\n if (placement.startsWith('top')) keyframe = 'scale-top';\n\n keyframesMap.set(placement, keyframe);\n\n return keyframe;\n }\n\n private setTriggerAriaLabel() {\n const { triggerRef, children } = this.asProps;\n\n requestAnimationFrame(() => {\n const trigger = triggerRef.current;\n\n if (trigger) {\n const textContent = trigger.textContent;\n const ariaLabel = getAccessibleName(trigger);\n\n if (!textContent && !ariaLabel) {\n const label = (typeof children === 'string' || typeof children === 'number')\n ? children.toString()\n : (this.hintRef.current?.textContent ?? '');\n triggerRef.current?.setAttribute('aria-label', label);\n }\n }\n });\n }\n\n render() {\n const SHintPopper = Root;\n const { visible, Children, parentZIndexStacking, styles, timingFunction } = this.asProps;\n const { innerVisible, calculatedPlacement } = this.state;\n\n if (canUseDOM()) {\n this.setTriggerAriaLabel();\n }\n\n if (!visible) {\n return null;\n }\n\n const duration = propToArray(Number(this.asProps.duration));\n\n /* `visible && innerVisible === null` - is a condition to start showing right after hover/focus */\n const showHint = (visible && innerVisible === null) || innerVisible === true;\n\n return sstyled(styles)(\n <Portal>\n <SHintPopper\n render={Box}\n ref={this.hintRef}\n aria-hidden={true}\n role={undefined}\n zIndex={parentZIndexStacking}\n use:visible={showHint}\n durationInitialize={`${duration[0]}ms`}\n durationFinalize={`${duration[1]}ms`}\n timingFunction={timingFunction}\n keyframesInitialize={keyframes[`@${this.keyframesKey(calculatedPlacement)}-in`]}\n keyframesFinalize={keyframes[`@${this.keyframesKey(calculatedPlacement)}-out`]}\n use:data-ui-name='Hint'\n >\n <Children />\n </SHintPopper>\n </Portal>,\n );\n }\n}\n\nexport const Hint = createComponent<'div', SimpleHintPopperProps>(HintPopperRoot);\n"],"mappings":";;;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AADA,IAAAC,IAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,G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AAE;AACb,CAAC;AA2PI,MAAMwF,IAAI,GAAAC,OAAA,CAAAD,IAAA,GAAG,IAAAE,qBAAe,EAA+B5G,cAAc,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Hint.js","names":["_core","require","_dom","_canUseDOM","_interopRequireDefault","_getAccessibleName","_useCssVariable","_zIndexStacking","_react","_Middleware","_flexBox","_portal","keyframes","sstyled","insert","styles","enhances","zIndexStackingEnhance","cssVariableEnhance","variable","fallback","map","v","Number","parseInt","toString","prop","propToArray","Array","isArray","keyframesMap","Map","HintPopperRoot","Component","constructor","props","_defineProperty2","default","React","createRef","handleFocus","bind","handleBlur","handleMouseEnter","handleMouseLeave","handleKeyDown","state","innerVisible","visible","calculatedPlacement","placement","uncontrolledProps","componentDidMount","triggerRef","children","asProps","trigger","current","subscribe","componentWillUnmount","unsubscribe","componentDidUpdate","prevProps","requestAnimationFrame","showHint","hideHint","addEventListener","removeEventListener","node","mouseEvent","timeout","showTimeout","hideTimer","clearTimeout","showTimer","window","setTimeout","handlers","popperElement","hintRef","middleware","offset","flip","shift","padding","verticalPlacement","startsWith","undefined","push","Middleware","verticalCursorAnchoring","x","clientX","computePosition","then","y","Object","assign","style","left","top","visibility","setState","hideTimeout","setProperty","e","target","HTMLElement","lastInteraction","isKeyboard","key","stopPropagation","keyframesKey","has","get","keyframe","set","setTriggerAriaLabel","textContent","ariaLabel","getAccessibleName","label","setAttribute","render","_ref","_ref2","SHintPopper","Box","Children","parentZIndexStacking","timingFunction","canUseDOM","duration","createElement","Portal","cn","assignProps","defaultVisible","Hint","exports","createComponent"],"sources":["../../../../src/components/hint/Hint.tsx"],"sourcesContent":["import { computePosition, flip, offset, shift, type Placement } from '@floating-ui/dom';\nimport { createComponent, Root, sstyled, Component, lastInteraction } from '@semcore/core';\nimport canUseDOM from '@semcore/core/lib/utils/canUseDOM';\nimport { getAccessibleName } from '@semcore/core/lib/utils/getAccessibleName';\nimport { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';\nimport { zIndexStackingEnhance } from '@semcore/core/lib/utils/zIndexStacking';\nimport type { DataType } from 'csstype';\nimport React from 'react';\n\nimport { Middleware } from './Middleware';\nimport keyframes from '../animation/style/keyframes.shadow.css';\nimport { Box } from '../flex-box';\nimport { Portal } from '../portal';\nimport styles from './style/hint.shadow.css';\n\ntype Handlers = {\n visible: null;\n};\n\nexport type SimpleHintPopperProps = {\n /** Ref to the trigger element */\n triggerRef: React.RefObject<HTMLElement | null>;\n /**\n * The position of the popper relative to the trigger that called it.\n * @default top\n */\n placement?: Placement;\n /**\n * Timer to show and hide the popper\n * @default [500, 500]\n */\n timeout?: DefaultProps['timeout'];\n /**\n * Hint content.\n * Better to use here some short text.\n * */\n children: React.ReactNode;\n\n /** Popper visibility value */\n visible?: boolean;\n /** Default popper visibility\n * @default false */\n defaultVisible?: boolean;\n /** Function called when visibility changes */\n onVisibleChange?: (visible: boolean, e?: Event) => boolean | void;\n};\n\ntype DefaultProps = {\n defaultVisible?: boolean;\n timeout: number | [number, number];\n timingFunction: DataType.EasingFunction;\n placement?: Placement;\n};\n\ntype State = {\n innerVisible: boolean | null;\n calculatedPlacement?: Placement;\n};\n\nconst enhances = [\n zIndexStackingEnhance('z-index-tooltip'),\n cssVariableEnhance({\n variable: '--intergalactic-duration-popper',\n fallback: '200',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'duration',\n }),\n cssVariableEnhance({\n variable: '--intergalactic-spacing-1x',\n fallback: '4',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'offset',\n }),\n cssVariableEnhance({\n variable: '--intergalactic-spacing-1x',\n fallback: '4',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'padding',\n }),\n] as const;\n\nfunction propToArray(prop: number | [number, number]): [number, number] {\n return Array.isArray(prop) ? prop : [prop, prop];\n}\n\nconst keyframesMap = new Map<Placement, string>();\n\nclass HintPopperRoot extends Component<SimpleHintPopperProps, typeof enhances, Handlers, DefaultProps, State> {\n public readonly hintRef = React.createRef<HTMLElement>();\n\n static style = Object.assign(keyframes, styles);\n\n private showTimer?: number;\n private hideTimer?: number;\n\n static enhance = enhances;\n\n static defaultProps: DefaultProps = {\n defaultVisible: false,\n timeout: [500, 500],\n timingFunction: 'ease-out',\n placement: 'top',\n };\n\n constructor(props: SimpleHintPopperProps) {\n super(props);\n\n this.handleFocus = this.handleFocus.bind(this);\n this.handleBlur = this.handleBlur.bind(this);\n this.handleMouseEnter = this.handleMouseEnter.bind(this);\n this.handleMouseLeave = this.handleMouseLeave.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n\n this.state = {\n innerVisible: props.visible ?? null,\n calculatedPlacement: props.placement,\n };\n }\n\n uncontrolledProps() {\n return {\n visible: null,\n };\n }\n\n componentDidMount() {\n const { triggerRef, children } = this.asProps;\n const trigger = triggerRef.current;\n\n if (trigger && children) {\n this.subscribe(trigger);\n }\n }\n\n componentWillUnmount() {\n const trigger = this.asProps.triggerRef.current;\n\n if (trigger) {\n this.unsubscribe(trigger);\n }\n }\n\n componentDidUpdate(prevProps: SimpleHintPopperProps) {\n if (prevProps.visible !== this.props.visible) {\n requestAnimationFrame(() => {\n const trigger = this.props.triggerRef.current;\n\n if (this.props.visible && trigger) {\n this.showHint(trigger);\n } else {\n this.hideHint();\n }\n });\n }\n }\n\n private subscribe(trigger: HTMLElement) {\n trigger.addEventListener('focus', this.handleFocus);\n trigger.addEventListener('blur', this.handleBlur);\n trigger.addEventListener('mouseenter', this.handleMouseEnter);\n trigger.addEventListener('mouseleave', this.handleMouseLeave);\n trigger.addEventListener('keydown', this.handleKeyDown);\n\n if (this.asProps.visible) {\n this.showHint(trigger);\n }\n }\n\n private unsubscribe(trigger: HTMLElement) {\n trigger.removeEventListener('focus', this.handleFocus);\n trigger.removeEventListener('blur', this.handleBlur);\n trigger.removeEventListener('mouseenter', this.handleMouseEnter);\n trigger.removeEventListener('mouseleave', this.handleMouseLeave);\n trigger.removeEventListener('keydown', this.handleKeyDown);\n\n this.hideHint();\n }\n\n private showHint(node: HTMLElement, mouseEvent?: MouseEvent): void {\n const { placement, timeout } = this.asProps;\n\n const showTimeout = Array.isArray(timeout) ? timeout[0] : timeout;\n\n if (this.hideTimer) {\n clearTimeout(this.hideTimer);\n }\n\n this.showTimer = window.setTimeout(() => {\n this.handlers.visible(true);\n\n window.setTimeout(() => {\n const popperElement = this.hintRef.current;\n if (popperElement) {\n const middleware = [\n offset(Number(this.asProps.offset)),\n flip(),\n shift({ padding: Number(this.asProps.padding) }),\n ];\n const verticalPlacement = !placement || placement.startsWith('top') || placement.startsWith('bottom');\n if (mouseEvent !== undefined && verticalPlacement) {\n middleware.push(\n Middleware.verticalCursorAnchoring({ x: mouseEvent.clientX }),\n shift({ padding: Number(this.asProps.padding) }),\n );\n }\n\n computePosition(node, popperElement, {\n placement: placement,\n middleware,\n }).then(({ x, y, placement }) => {\n Object.assign(popperElement.style, {\n left: `${x}px`,\n top: `${y}px`,\n });\n popperElement.style.visibility = 'visible';\n\n this.setState({ innerVisible: true, calculatedPlacement: placement });\n });\n }\n }, 10);\n }, showTimeout);\n }\n\n private hideHint(): void {\n const { timeout } = this.asProps;\n\n const hideTimeout = Array.isArray(timeout) ? timeout[1] : timeout;\n\n if (this.showTimer) {\n clearTimeout(this.showTimer);\n }\n\n this.setState({ innerVisible: false });\n\n this.hideTimer = window.setTimeout(() => {\n this.hintRef.current?.style.setProperty('visibility', 'hidden');\n this.handlers.visible(false);\n this.setState({ innerVisible: null });\n }, hideTimeout);\n }\n\n private handleFocus(e: FocusEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target && lastInteraction.isKeyboard()) {\n this.showHint(e.target);\n }\n }\n\n private handleBlur(e: FocusEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target) {\n this.hideHint();\n }\n }\n\n private handleKeyDown(e: KeyboardEvent): void {\n if (e.key === 'Escape' && e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target && this.state.innerVisible) {\n e.stopPropagation();\n this.hideHint();\n }\n }\n\n private handleMouseEnter(e: MouseEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target) {\n this.showHint(e.target, e);\n }\n }\n\n private handleMouseLeave(e: MouseEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target) {\n this.hideHint();\n }\n }\n\n private keyframesKey(placement?: Placement) {\n if (!placement) {\n return 'opacity';\n }\n\n if (keyframesMap.has(placement)) {\n return keyframesMap.get(placement)!;\n }\n\n let keyframe: string = 'opacity';\n\n if (placement.startsWith('left')) keyframe = 'scale-left';\n if (placement.startsWith('right')) keyframe = 'scale-right';\n if (placement.startsWith('bottom')) keyframe = 'scale-bottom';\n if (placement.startsWith('top')) keyframe = 'scale-top';\n\n keyframesMap.set(placement, keyframe);\n\n return keyframe;\n }\n\n private setTriggerAriaLabel() {\n const { triggerRef, children } = this.asProps;\n\n requestAnimationFrame(() => {\n const trigger = triggerRef.current;\n\n if (trigger) {\n const textContent = trigger.textContent;\n const ariaLabel = getAccessibleName(trigger);\n\n if (!textContent && !ariaLabel) {\n const label = (typeof children === 'string' || typeof children === 'number')\n ? children.toString()\n : (this.hintRef.current?.textContent ?? '');\n triggerRef.current?.setAttribute('aria-label', label);\n }\n }\n });\n }\n\n render() {\n const SHintPopper = Root;\n const { visible, Children, parentZIndexStacking, styles, timingFunction } = this.asProps;\n const { innerVisible, calculatedPlacement } = this.state;\n\n if (canUseDOM()) {\n this.setTriggerAriaLabel();\n }\n\n if (!visible) {\n return null;\n }\n\n const duration = propToArray(Number(this.asProps.duration));\n\n /* `visible && innerVisible === null` - is a condition to start showing right after hover/focus */\n const showHint = (visible && innerVisible === null) || innerVisible === true;\n\n return sstyled(styles)(\n <Portal>\n <SHintPopper\n render={Box}\n ref={this.hintRef}\n aria-hidden={true}\n role={undefined}\n zIndex={parentZIndexStacking}\n use:visible={showHint}\n durationInitialize={`${duration[0]}ms`}\n durationFinalize={`${duration[1]}ms`}\n timingFunction={timingFunction}\n keyframesInitialize={keyframes[`@${this.keyframesKey(calculatedPlacement)}-in`]}\n keyframesFinalize={keyframes[`@${this.keyframesKey(calculatedPlacement)}-out`]}\n use:data-ui-name='Hint'\n >\n <Children />\n </SHintPopper>\n </Portal>,\n );\n }\n}\n\nexport const Hint = createComponent<'div', SimpleHintPopperProps>(HintPopperRoot);\n"],"mappings":";;;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AADA,IAAAC,IAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AAEA,IAAAO,MAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAEA,IAAAQ,WAAA,GAAAR,OAAA;AAEA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AAAmC;AAAA,MAAAW,SAAA,8BAAAZ,KAAA,CAAAa,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAAA;AAAA,MAAAC,MAAA,8BAAAf,KAAA,CAAAa,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AA+CnC,MAAME,QAAQ,GAAG,CACf,IAAAC,qCAAqB,EAAC,iBAAiB,CAAC,EACxC,IAAAC,kCAAkB,EAAC;EACjBC,QAAQ,EAAE,iCAAiC;EAC3CC,QAAQ,EAAE,KAAK;EACfC,GAAG,EAAGC,CAAS,IAAKC,MAAM,CAACC,QAAQ,CAACF,CAAC,EAAE,EAAE,CAAC,CAACG,QAAQ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KAAA,CAAAU,EAAA,gBAAE,CACA,CACP,CAAC;EAEb;AACF;AAAC,IAAAnG,gBAAA,CAAAC,OAAA,EAzQKL,cAAc,WAGHgE,MAAM,CAACC,MAAM,CAACrF,SAAS,EAAEG,MAAM,CAAC;AAAA,IAAAqB,gBAAA,CAAAC,OAAA,EAH3CL,cAAc,aAQDhB,QAAQ;AAAA,IAAAoB,gBAAA,CAAAC,OAAA,EARrBL,cAAc,kBAUkB;EAClCyG,cAAc,EAAE,KAAK;EACrBnE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;EACnB4D,cAAc,EAAE,UAAU;EAC1BhF,SAAS,EAAE;AACb,CAAC;AA4PI,MAAMwF,IAAI,GAAAC,OAAA,CAAAD,IAAA,GAAG,IAAAE,qBAAe,EAA+B5G,cAAc,CAAC","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,KAAK;IAC5D,IAAIA,KAAK,KAAKC,SAAS,EAAE;MACvBH,GAAG,CAACC,GAAG,CAAC,GAAGC,KAAK;IAClB;IACA,OAAOF,GAAG;EACZ,CAAC,EAAE,CAAC,CAAC,CAAC;AACR;AAEA,SAASI,OAAOA,CAACC,IAAS,EAAE;EAC1B,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAOA,IAAI;EACb;EACA,IAAIA,IAAI,GAAG,CAAC,EAAE;IACZ,OAAO,GAAG,GAAG,GAAGA,IAAI,GAAG;EACzB;EACA,IAAIA,IAAI,IAAI,CAAC,EAAE;IACb,OAAO,GAAGA,IAAI,IAAI;EACpB;AACF;;AAgJA;;AASA,SAASC,qBAAqBA,CAACC,KAAe,EAAEC,WAAmB,EAAE;EACnE,OAAOb,mBAAmB,CAAC;IACzBc,OAAO,EAAEF,KAA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ChBoF,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;IAC3BK,QAAQ,EAAEb,OAAO,CAACQ,KAAK,CAAC,MAAM,CAAC,CAAC;IAChCM,QAAQ,EAAEd,OAAO,CAACQ,KAAK,CAAC,MAAM,CAAC,CAAC;IAChCO,SAAS,EAAEf,OAAO,CAACQ,KAAK,CAAC,MAAM,CAAC,CAAC;IACjCQ,SAAS,EAAEhB,OAAO,CAACQ,KAAK,CAAC,MAAM,CAAC,CAAC;IACjCS,QAAQ,EAAET,KAAK,CAAC,UAAU,CAAC;IAC3BU,GAAG,EAAElB,OAAO,CAACQ,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1BW,IAAI,EAAEnB,OAAO,CAACQ,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5BY,MAAM,EAAEpB,OAAO,CAACQ,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChCa,KAAK,EAAErB,OAAO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EACFC,EAAE,EACFC,EAAE,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,GAAG1E,OAAO,CAACO,KAAK,CAAC;EAE7B,IAAImC,GAAG,KAAKpC,KAAK,CAACqE,QAAQ,EAAE,OAAO,CAACrE,KAAK,CAACqE,QAAQ,EAAE;IAAEC,QAAQ,EAAEjE,KAAK,CAACiE;EAAS,CAAC,CAAC;EAEjF,OAAO,CACLlC,GAAG,EACH;IACEF,GAAG;IACH,WAAW,EACTnC,EAAE,CACAqE,MAAM,CAACrE,EAAE,CAAC,MAAM,EAAE;MAChBwE,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,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
|
|
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","
|
|
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,EAAEC,mBAAmB,QAAQ,sCAAsC;AAChG,OAAOC,EAAE,MAAM,YAAY;AAE3B,OAAOC,KAAK,MAAM,OAAO;AAEzB,OAAOC,MAAM,MAAyB,eAAe;AAAC;AAAA,MAAAC,KAAA,8BAAAC,QAAA,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,OAAOZ,mBAAmB,CAAC;IACzBa,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,GAAG,UAAU,GAAG,EAAE,EAAE,GAAGC,SAAS;IAC/EC,aAAa,EAAGX,KAAK,CAACS,OAAO,IAAIR,gBAAgB,CAACD,KAAK,CAACY,SAAS,CAAC,IAAKZ,KAAK,CAACY,SAAS;IACtFC,MAAM,EAAEtB,oBAAoB,CAACS,KAAK,CAACa,MAAM,IAAIb,KAAK,CAACc,GAAG,EAAEV,WAAW,CAAC;IACpEW,SAAS,EAAExB,oBAAoB,CAACS,KAAK,CAACe,SAAS,IAAIf,KAAK,CAACc,GAAG,EAAEV,WAAW;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","ignoreList":[]}
|
|
@@ -98,8 +98,12 @@ class HintPopperRoot extends Component {
|
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
componentDidMount() {
|
|
101
|
-
const
|
|
102
|
-
|
|
101
|
+
const {
|
|
102
|
+
triggerRef,
|
|
103
|
+
children
|
|
104
|
+
} = this.asProps;
|
|
105
|
+
const trigger = triggerRef.current;
|
|
106
|
+
if (trigger && children) {
|
|
103
107
|
this.subscribe(trigger);
|
|
104
108
|
}
|
|
105
109
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hint.js","names":["computePosition","flip","offset","shift","createComponent","Root","sstyled","Component","lastInteraction","canUseDOM","getAccessibleName","cssVariableEnhance","zIndexStackingEnhance","React","Middleware","keyframes","_sstyled","insert","Box","Portal","styles","_sstyled2","enhances","variable","fallback","map","v","Number","parseInt","toString","prop","propToArray","Array","isArray","keyframesMap","Map","HintPopperRoot","constructor","props","_defineProperty","createRef","handleFocus","bind","handleBlur","handleMouseEnter","handleMouseLeave","handleKeyDown","state","innerVisible","visible","calculatedPlacement","placement","uncontrolledProps","componentDidMount","trigger","asProps","triggerRef","current","subscribe","componentWillUnmount","unsubscribe","componentDidUpdate","prevProps","requestAnimationFrame","showHint","hideHint","addEventListener","removeEventListener","node","mouseEvent","timeout","showTimeout","hideTimer","clearTimeout","showTimer","window","setTimeout","handlers","popperElement","hintRef","middleware","padding","verticalPlacement","startsWith","undefined","push","verticalCursorAnchoring","x","clientX","then","y","Object","assign","style","left","top","visibility","setState","hideTimeout","setProperty","e","target","HTMLElement","isKeyboard","key","stopPropagation","keyframesKey","has","get","keyframe","set","setTriggerAriaLabel","children","textContent","ariaLabel","label","setAttribute","render","_ref","_ref2","SHintPopper","Children","parentZIndexStacking","timingFunction","duration","createElement","cn","_assignProps","defaultVisible","Hint"],"sources":["../../../../src/components/hint/Hint.tsx"],"sourcesContent":["import { computePosition, flip, offset, shift, type Placement } from '@floating-ui/dom';\nimport { createComponent, Root, sstyled, Component, lastInteraction } from '@semcore/core';\nimport canUseDOM from '@semcore/core/lib/utils/canUseDOM';\nimport { getAccessibleName } from '@semcore/core/lib/utils/getAccessibleName';\nimport { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';\nimport { zIndexStackingEnhance } from '@semcore/core/lib/utils/zIndexStacking';\nimport type { DataType } from 'csstype';\nimport React from 'react';\n\nimport { Middleware } from './Middleware';\nimport keyframes from '../animation/style/keyframes.shadow.css';\nimport { Box } from '../flex-box';\nimport { Portal } from '../portal';\nimport styles from './style/hint.shadow.css';\n\ntype Handlers = {\n visible: null;\n};\n\nexport type SimpleHintPopperProps = {\n /** Ref to the trigger element */\n triggerRef: React.RefObject<HTMLElement | null>;\n /**\n * The position of the popper relative to the trigger that called it.\n * @default top\n */\n placement?: Placement;\n /**\n * Timer to show and hide the popper\n * @default [500, 500]\n */\n timeout?: DefaultProps['timeout'];\n /**\n * Hint content.\n * Better to use here some short text.\n * */\n children: React.ReactNode;\n\n /** Popper visibility value */\n visible?: boolean;\n /** Default popper visibility\n * @default false */\n defaultVisible?: boolean;\n /** Function called when visibility changes */\n onVisibleChange?: (visible: boolean, e?: Event) => boolean | void;\n};\n\ntype DefaultProps = {\n defaultVisible?: boolean;\n timeout: number | [number, number];\n timingFunction: DataType.EasingFunction;\n placement?: Placement;\n};\n\ntype State = {\n innerVisible: boolean | null;\n calculatedPlacement?: Placement;\n};\n\nconst enhances = [\n zIndexStackingEnhance('z-index-tooltip'),\n cssVariableEnhance({\n variable: '--intergalactic-duration-popper',\n fallback: '200',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'duration',\n }),\n cssVariableEnhance({\n variable: '--intergalactic-spacing-1x',\n fallback: '4',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'offset',\n }),\n cssVariableEnhance({\n variable: '--intergalactic-spacing-1x',\n fallback: '4',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'padding',\n }),\n] as const;\n\nfunction propToArray(prop: number | [number, number]): [number, number] {\n return Array.isArray(prop) ? prop : [prop, prop];\n}\n\nconst keyframesMap = new Map<Placement, string>();\n\nclass HintPopperRoot extends Component<SimpleHintPopperProps, typeof enhances, Handlers, DefaultProps, State> {\n public readonly hintRef = React.createRef<HTMLElement>();\n\n static style = Object.assign(keyframes, styles);\n\n private showTimer?: number;\n private hideTimer?: number;\n\n static enhance = enhances;\n\n static defaultProps: DefaultProps = {\n defaultVisible: false,\n timeout: [500, 500],\n timingFunction: 'ease-out',\n placement: 'top',\n };\n\n constructor(props: SimpleHintPopperProps) {\n super(props);\n\n this.handleFocus = this.handleFocus.bind(this);\n this.handleBlur = this.handleBlur.bind(this);\n this.handleMouseEnter = this.handleMouseEnter.bind(this);\n this.handleMouseLeave = this.handleMouseLeave.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n\n this.state = {\n innerVisible: props.visible ?? null,\n calculatedPlacement: props.placement,\n };\n }\n\n uncontrolledProps() {\n return {\n visible: null,\n };\n }\n\n componentDidMount() {\n const trigger = this.asProps.triggerRef.current;\n\n if (trigger) {\n this.subscribe(trigger);\n }\n }\n\n componentWillUnmount() {\n const trigger = this.asProps.triggerRef.current;\n\n if (trigger) {\n this.unsubscribe(trigger);\n }\n }\n\n componentDidUpdate(prevProps: SimpleHintPopperProps) {\n if (prevProps.visible !== this.props.visible) {\n requestAnimationFrame(() => {\n const trigger = this.props.triggerRef.current;\n\n if (this.props.visible && trigger) {\n this.showHint(trigger);\n } else {\n this.hideHint();\n }\n });\n }\n }\n\n private subscribe(trigger: HTMLElement) {\n trigger.addEventListener('focus', this.handleFocus);\n trigger.addEventListener('blur', this.handleBlur);\n trigger.addEventListener('mouseenter', this.handleMouseEnter);\n trigger.addEventListener('mouseleave', this.handleMouseLeave);\n trigger.addEventListener('keydown', this.handleKeyDown);\n\n if (this.asProps.visible) {\n this.showHint(trigger);\n }\n }\n\n private unsubscribe(trigger: HTMLElement) {\n trigger.removeEventListener('focus', this.handleFocus);\n trigger.removeEventListener('blur', this.handleBlur);\n trigger.removeEventListener('mouseenter', this.handleMouseEnter);\n trigger.removeEventListener('mouseleave', this.handleMouseLeave);\n trigger.removeEventListener('keydown', this.handleKeyDown);\n\n this.hideHint();\n }\n\n private showHint(node: HTMLElement, mouseEvent?: MouseEvent): void {\n const { placement, timeout } = this.asProps;\n\n const showTimeout = Array.isArray(timeout) ? timeout[0] : timeout;\n\n if (this.hideTimer) {\n clearTimeout(this.hideTimer);\n }\n\n this.showTimer = window.setTimeout(() => {\n this.handlers.visible(true);\n\n window.setTimeout(() => {\n const popperElement = this.hintRef.current;\n if (popperElement) {\n const middleware = [\n offset(Number(this.asProps.offset)),\n flip(),\n shift({ padding: Number(this.asProps.padding) }),\n ];\n const verticalPlacement = !placement || placement.startsWith('top') || placement.startsWith('bottom');\n if (mouseEvent !== undefined && verticalPlacement) {\n middleware.push(\n Middleware.verticalCursorAnchoring({ x: mouseEvent.clientX }),\n shift({ padding: Number(this.asProps.padding) }),\n );\n }\n\n computePosition(node, popperElement, {\n placement: placement,\n middleware,\n }).then(({ x, y, placement }) => {\n Object.assign(popperElement.style, {\n left: `${x}px`,\n top: `${y}px`,\n });\n popperElement.style.visibility = 'visible';\n\n this.setState({ innerVisible: true, calculatedPlacement: placement });\n });\n }\n }, 10);\n }, showTimeout);\n }\n\n private hideHint(): void {\n const { timeout } = this.asProps;\n\n const hideTimeout = Array.isArray(timeout) ? timeout[1] : timeout;\n\n if (this.showTimer) {\n clearTimeout(this.showTimer);\n }\n\n this.setState({ innerVisible: false });\n\n this.hideTimer = window.setTimeout(() => {\n this.hintRef.current?.style.setProperty('visibility', 'hidden');\n this.handlers.visible(false);\n this.setState({ innerVisible: null });\n }, hideTimeout);\n }\n\n private handleFocus(e: FocusEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target && lastInteraction.isKeyboard()) {\n this.showHint(e.target);\n }\n }\n\n private handleBlur(e: FocusEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target) {\n this.hideHint();\n }\n }\n\n private handleKeyDown(e: KeyboardEvent): void {\n if (e.key === 'Escape' && e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target && this.state.innerVisible) {\n e.stopPropagation();\n this.hideHint();\n }\n }\n\n private handleMouseEnter(e: MouseEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target) {\n this.showHint(e.target, e);\n }\n }\n\n private handleMouseLeave(e: MouseEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target) {\n this.hideHint();\n }\n }\n\n private keyframesKey(placement?: Placement) {\n if (!placement) {\n return 'opacity';\n }\n\n if (keyframesMap.has(placement)) {\n return keyframesMap.get(placement)!;\n }\n\n let keyframe: string = 'opacity';\n\n if (placement.startsWith('left')) keyframe = 'scale-left';\n if (placement.startsWith('right')) keyframe = 'scale-right';\n if (placement.startsWith('bottom')) keyframe = 'scale-bottom';\n if (placement.startsWith('top')) keyframe = 'scale-top';\n\n keyframesMap.set(placement, keyframe);\n\n return keyframe;\n }\n\n private setTriggerAriaLabel() {\n const { triggerRef, children } = this.asProps;\n\n requestAnimationFrame(() => {\n const trigger = triggerRef.current;\n\n if (trigger) {\n const textContent = trigger.textContent;\n const ariaLabel = getAccessibleName(trigger);\n\n if (!textContent && !ariaLabel) {\n const label = (typeof children === 'string' || typeof children === 'number')\n ? children.toString()\n : (this.hintRef.current?.textContent ?? '');\n triggerRef.current?.setAttribute('aria-label', label);\n }\n }\n });\n }\n\n render() {\n const SHintPopper = Root;\n const { visible, Children, parentZIndexStacking, styles, timingFunction } = this.asProps;\n const { innerVisible, calculatedPlacement } = this.state;\n\n if (canUseDOM()) {\n this.setTriggerAriaLabel();\n }\n\n if (!visible) {\n return null;\n }\n\n const duration = propToArray(Number(this.asProps.duration));\n\n /* `visible && innerVisible === null` - is a condition to start showing right after hover/focus */\n const showHint = (visible && innerVisible === null) || innerVisible === true;\n\n return sstyled(styles)(\n <Portal>\n <SHintPopper\n render={Box}\n ref={this.hintRef}\n aria-hidden={true}\n role={undefined}\n zIndex={parentZIndexStacking}\n use:visible={showHint}\n durationInitialize={`${duration[0]}ms`}\n durationFinalize={`${duration[1]}ms`}\n timingFunction={timingFunction}\n keyframesInitialize={keyframes[`@${this.keyframesKey(calculatedPlacement)}-in`]}\n keyframesFinalize={keyframes[`@${this.keyframesKey(calculatedPlacement)}-out`]}\n use:data-ui-name='Hint'\n >\n <Children />\n </SHintPopper>\n </Portal>,\n );\n }\n}\n\nexport const Hint = createComponent<'div', SimpleHintPopperProps>(HintPopperRoot);\n"],"mappings":";;;;AAAA,SAASA,eAAe,EAAEC,IAAI,EAAEC,MAAM,EAAEC,KAAK,QAAwB,kBAAkB;AACvF,SAASC,eAAe,EAAEC,IAAI,EAAEC,OAAO,EAAEC,SAAS,EAAEC,eAAe,QAAQ,eAAe;AAC1F,OAAOC,SAAS,MAAM,mCAAmC;AACzD,SAASC,iBAAiB,QAAQ,2CAA2C;AAC7E,SAASC,kBAAkB,QAAQ,wCAAwC;AAC3E,SAASC,qBAAqB,QAAQ,wCAAwC;AAE9E,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,UAAU,QAAQ,cAAc;AAAC;AAAA,MAAAC,SAAA,8BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAE1C,SAASC,GAAG,QAAQ,aAAa;AACjC,SAASC,MAAM,QAAQ,WAAW;AAAC;AAAA,MAAAC,MAAA,8BAAAC,SAAA,CAAAJ,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AA+CnC,MAAMK,QAAQ,GAAG,CACfV,qBAAqB,CAAC,iBAAiB,CAAC,EACxC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GHuD,MAAM,CAACC,MAAM,CAAC7E,SAAS,EAAEK,MAAM,CAAC;AAAAmB,eAAA,CAH3CH,cAAc,aAQDd,QAAQ;AAAAiB,eAAA,CARrBH,cAAc,kBAUkB;EAClC4F,cAAc,EAAE,KAAK;EACrB1D,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;EACnBqD,cAAc,EAAE,UAAU;EAC1BxE,SAAS,EAAE;AACb,CAAC;AA2PH,OAAO,MAAM8E,IAAI,GAAG7H,eAAe,CAA+BgC,cAAc,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Hint.js","names":["computePosition","flip","offset","shift","createComponent","Root","sstyled","Component","lastInteraction","canUseDOM","getAccessibleName","cssVariableEnhance","zIndexStackingEnhance","React","Middleware","keyframes","_sstyled","insert","Box","Portal","styles","_sstyled2","enhances","variable","fallback","map","v","Number","parseInt","toString","prop","propToArray","Array","isArray","keyframesMap","Map","HintPopperRoot","constructor","props","_defineProperty","createRef","handleFocus","bind","handleBlur","handleMouseEnter","handleMouseLeave","handleKeyDown","state","innerVisible","visible","calculatedPlacement","placement","uncontrolledProps","componentDidMount","triggerRef","children","asProps","trigger","current","subscribe","componentWillUnmount","unsubscribe","componentDidUpdate","prevProps","requestAnimationFrame","showHint","hideHint","addEventListener","removeEventListener","node","mouseEvent","timeout","showTimeout","hideTimer","clearTimeout","showTimer","window","setTimeout","handlers","popperElement","hintRef","middleware","padding","verticalPlacement","startsWith","undefined","push","verticalCursorAnchoring","x","clientX","then","y","Object","assign","style","left","top","visibility","setState","hideTimeout","setProperty","e","target","HTMLElement","isKeyboard","key","stopPropagation","keyframesKey","has","get","keyframe","set","setTriggerAriaLabel","textContent","ariaLabel","label","setAttribute","render","_ref","_ref2","SHintPopper","Children","parentZIndexStacking","timingFunction","duration","createElement","cn","_assignProps","defaultVisible","Hint"],"sources":["../../../../src/components/hint/Hint.tsx"],"sourcesContent":["import { computePosition, flip, offset, shift, type Placement } from '@floating-ui/dom';\nimport { createComponent, Root, sstyled, Component, lastInteraction } from '@semcore/core';\nimport canUseDOM from '@semcore/core/lib/utils/canUseDOM';\nimport { getAccessibleName } from '@semcore/core/lib/utils/getAccessibleName';\nimport { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';\nimport { zIndexStackingEnhance } from '@semcore/core/lib/utils/zIndexStacking';\nimport type { DataType } from 'csstype';\nimport React from 'react';\n\nimport { Middleware } from './Middleware';\nimport keyframes from '../animation/style/keyframes.shadow.css';\nimport { Box } from '../flex-box';\nimport { Portal } from '../portal';\nimport styles from './style/hint.shadow.css';\n\ntype Handlers = {\n visible: null;\n};\n\nexport type SimpleHintPopperProps = {\n /** Ref to the trigger element */\n triggerRef: React.RefObject<HTMLElement | null>;\n /**\n * The position of the popper relative to the trigger that called it.\n * @default top\n */\n placement?: Placement;\n /**\n * Timer to show and hide the popper\n * @default [500, 500]\n */\n timeout?: DefaultProps['timeout'];\n /**\n * Hint content.\n * Better to use here some short text.\n * */\n children: React.ReactNode;\n\n /** Popper visibility value */\n visible?: boolean;\n /** Default popper visibility\n * @default false */\n defaultVisible?: boolean;\n /** Function called when visibility changes */\n onVisibleChange?: (visible: boolean, e?: Event) => boolean | void;\n};\n\ntype DefaultProps = {\n defaultVisible?: boolean;\n timeout: number | [number, number];\n timingFunction: DataType.EasingFunction;\n placement?: Placement;\n};\n\ntype State = {\n innerVisible: boolean | null;\n calculatedPlacement?: Placement;\n};\n\nconst enhances = [\n zIndexStackingEnhance('z-index-tooltip'),\n cssVariableEnhance({\n variable: '--intergalactic-duration-popper',\n fallback: '200',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'duration',\n }),\n cssVariableEnhance({\n variable: '--intergalactic-spacing-1x',\n fallback: '4',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'offset',\n }),\n cssVariableEnhance({\n variable: '--intergalactic-spacing-1x',\n fallback: '4',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'padding',\n }),\n] as const;\n\nfunction propToArray(prop: number | [number, number]): [number, number] {\n return Array.isArray(prop) ? prop : [prop, prop];\n}\n\nconst keyframesMap = new Map<Placement, string>();\n\nclass HintPopperRoot extends Component<SimpleHintPopperProps, typeof enhances, Handlers, DefaultProps, State> {\n public readonly hintRef = React.createRef<HTMLElement>();\n\n static style = Object.assign(keyframes, styles);\n\n private showTimer?: number;\n private hideTimer?: number;\n\n static enhance = enhances;\n\n static defaultProps: DefaultProps = {\n defaultVisible: false,\n timeout: [500, 500],\n timingFunction: 'ease-out',\n placement: 'top',\n };\n\n constructor(props: SimpleHintPopperProps) {\n super(props);\n\n this.handleFocus = this.handleFocus.bind(this);\n this.handleBlur = this.handleBlur.bind(this);\n this.handleMouseEnter = this.handleMouseEnter.bind(this);\n this.handleMouseLeave = this.handleMouseLeave.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n\n this.state = {\n innerVisible: props.visible ?? null,\n calculatedPlacement: props.placement,\n };\n }\n\n uncontrolledProps() {\n return {\n visible: null,\n };\n }\n\n componentDidMount() {\n const { triggerRef, children } = this.asProps;\n const trigger = triggerRef.current;\n\n if (trigger && children) {\n this.subscribe(trigger);\n }\n }\n\n componentWillUnmount() {\n const trigger = this.asProps.triggerRef.current;\n\n if (trigger) {\n this.unsubscribe(trigger);\n }\n }\n\n componentDidUpdate(prevProps: SimpleHintPopperProps) {\n if (prevProps.visible !== this.props.visible) {\n requestAnimationFrame(() => {\n const trigger = this.props.triggerRef.current;\n\n if (this.props.visible && trigger) {\n this.showHint(trigger);\n } else {\n this.hideHint();\n }\n });\n }\n }\n\n private subscribe(trigger: HTMLElement) {\n trigger.addEventListener('focus', this.handleFocus);\n trigger.addEventListener('blur', this.handleBlur);\n trigger.addEventListener('mouseenter', this.handleMouseEnter);\n trigger.addEventListener('mouseleave', this.handleMouseLeave);\n trigger.addEventListener('keydown', this.handleKeyDown);\n\n if (this.asProps.visible) {\n this.showHint(trigger);\n }\n }\n\n private unsubscribe(trigger: HTMLElement) {\n trigger.removeEventListener('focus', this.handleFocus);\n trigger.removeEventListener('blur', this.handleBlur);\n trigger.removeEventListener('mouseenter', this.handleMouseEnter);\n trigger.removeEventListener('mouseleave', this.handleMouseLeave);\n trigger.removeEventListener('keydown', this.handleKeyDown);\n\n this.hideHint();\n }\n\n private showHint(node: HTMLElement, mouseEvent?: MouseEvent): void {\n const { placement, timeout } = this.asProps;\n\n const showTimeout = Array.isArray(timeout) ? timeout[0] : timeout;\n\n if (this.hideTimer) {\n clearTimeout(this.hideTimer);\n }\n\n this.showTimer = window.setTimeout(() => {\n this.handlers.visible(true);\n\n window.setTimeout(() => {\n const popperElement = this.hintRef.current;\n if (popperElement) {\n const middleware = [\n offset(Number(this.asProps.offset)),\n flip(),\n shift({ padding: Number(this.asProps.padding) }),\n ];\n const verticalPlacement = !placement || placement.startsWith('top') || placement.startsWith('bottom');\n if (mouseEvent !== undefined && verticalPlacement) {\n middleware.push(\n Middleware.verticalCursorAnchoring({ x: mouseEvent.clientX }),\n shift({ padding: Number(this.asProps.padding) }),\n );\n }\n\n computePosition(node, popperElement, {\n placement: placement,\n middleware,\n }).then(({ x, y, placement }) => {\n Object.assign(popperElement.style, {\n left: `${x}px`,\n top: `${y}px`,\n });\n popperElement.style.visibility = 'visible';\n\n this.setState({ innerVisible: true, calculatedPlacement: placement });\n });\n }\n }, 10);\n }, showTimeout);\n }\n\n private hideHint(): void {\n const { timeout } = this.asProps;\n\n const hideTimeout = Array.isArray(timeout) ? timeout[1] : timeout;\n\n if (this.showTimer) {\n clearTimeout(this.showTimer);\n }\n\n this.setState({ innerVisible: false });\n\n this.hideTimer = window.setTimeout(() => {\n this.hintRef.current?.style.setProperty('visibility', 'hidden');\n this.handlers.visible(false);\n this.setState({ innerVisible: null });\n }, hideTimeout);\n }\n\n private handleFocus(e: FocusEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target && lastInteraction.isKeyboard()) {\n this.showHint(e.target);\n }\n }\n\n private handleBlur(e: FocusEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target) {\n this.hideHint();\n }\n }\n\n private handleKeyDown(e: KeyboardEvent): void {\n if (e.key === 'Escape' && e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target && this.state.innerVisible) {\n e.stopPropagation();\n this.hideHint();\n }\n }\n\n private handleMouseEnter(e: MouseEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target) {\n this.showHint(e.target, e);\n }\n }\n\n private handleMouseLeave(e: MouseEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target) {\n this.hideHint();\n }\n }\n\n private keyframesKey(placement?: Placement) {\n if (!placement) {\n return 'opacity';\n }\n\n if (keyframesMap.has(placement)) {\n return keyframesMap.get(placement)!;\n }\n\n let keyframe: string = 'opacity';\n\n if (placement.startsWith('left')) keyframe = 'scale-left';\n if (placement.startsWith('right')) keyframe = 'scale-right';\n if (placement.startsWith('bottom')) keyframe = 'scale-bottom';\n if (placement.startsWith('top')) keyframe = 'scale-top';\n\n keyframesMap.set(placement, keyframe);\n\n return keyframe;\n }\n\n private setTriggerAriaLabel() {\n const { triggerRef, children } = this.asProps;\n\n requestAnimationFrame(() => {\n const trigger = triggerRef.current;\n\n if (trigger) {\n const textContent = trigger.textContent;\n const ariaLabel = getAccessibleName(trigger);\n\n if (!textContent && !ariaLabel) {\n const label = (typeof children === 'string' || typeof children === 'number')\n ? children.toString()\n : (this.hintRef.current?.textContent ?? '');\n triggerRef.current?.setAttribute('aria-label', label);\n }\n }\n });\n }\n\n render() {\n const SHintPopper = Root;\n const { visible, Children, parentZIndexStacking, styles, timingFunction } = this.asProps;\n const { innerVisible, calculatedPlacement } = this.state;\n\n if (canUseDOM()) {\n this.setTriggerAriaLabel();\n }\n\n if (!visible) {\n return null;\n }\n\n const duration = propToArray(Number(this.asProps.duration));\n\n /* `visible && innerVisible === null` - is a condition to start showing right after hover/focus */\n const showHint = (visible && innerVisible === null) || innerVisible === true;\n\n return sstyled(styles)(\n <Portal>\n <SHintPopper\n render={Box}\n ref={this.hintRef}\n aria-hidden={true}\n role={undefined}\n zIndex={parentZIndexStacking}\n use:visible={showHint}\n durationInitialize={`${duration[0]}ms`}\n durationFinalize={`${duration[1]}ms`}\n timingFunction={timingFunction}\n keyframesInitialize={keyframes[`@${this.keyframesKey(calculatedPlacement)}-in`]}\n keyframesFinalize={keyframes[`@${this.keyframesKey(calculatedPlacement)}-out`]}\n use:data-ui-name='Hint'\n >\n <Children />\n </SHintPopper>\n </Portal>,\n );\n }\n}\n\nexport const Hint = createComponent<'div', SimpleHintPopperProps>(HintPopperRoot);\n"],"mappings":";;;;AAAA,SAASA,eAAe,EAAEC,IAAI,EAAEC,MAAM,EAAEC,KAAK,QAAwB,kBAAkB;AACvF,SAASC,eAAe,EAAEC,IAAI,EAAEC,OAAO,EAAEC,SAAS,EAAEC,eAAe,QAAQ,eAAe;AAC1F,OAAOC,SAAS,MAAM,mCAAmC;AACzD,SAASC,iBAAiB,QAAQ,2CAA2C;AAC7E,SAASC,kBAAkB,QAAQ,wCAAwC;AAC3E,SAASC,qBAAqB,QAAQ,wCAAwC;AAE9E,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,UAAU,QAAQ,cAAc;AAAC;AAAA,MAAAC,SAAA,8BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAE1C,SAASC,GAAG,QAAQ,aAAa;AACjC,SAASC,MAAM,QAAQ,WAAW;AAAC;AAAA,MAAAC,MAAA,8BAAAC,SAAA,CAAAJ,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AA+CnC,MAAMK,QAAQ,GAAG,CACfV,qBAAq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,EAAAF,KAAA,CAAAO,EAAA,gBAAE,CACA,CACP,CAAC;EAEb;AACF;AAACvF,eAAA,CAzQKH,cAAc,WAGHwD,MAAM,CAACC,MAAM,CAAC9E,SAAS,EAAEK,MAAM,CAAC;AAAAmB,eAAA,CAH3CH,cAAc,aAQDd,QAAQ;AAAAiB,eAAA,CARrBH,cAAc,kBAUkB;EAClC4F,cAAc,EAAE,KAAK;EACrBzD,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;EACnBoD,cAAc,EAAE,UAAU;EAC1BxE,SAAS,EAAE;AACb,CAAC;AA4PH,OAAO,MAAM8E,IAAI,GAAG7H,eAAe,CAA+BgC,cAAc,CAAC","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
|
|
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__*/
|
|
@@ -109,8 +109,12 @@ class HintPopperRoot extends Component {
|
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
componentDidMount() {
|
|
112
|
-
const
|
|
113
|
-
|
|
112
|
+
const {
|
|
113
|
+
triggerRef,
|
|
114
|
+
children
|
|
115
|
+
} = this.asProps;
|
|
116
|
+
const trigger = triggerRef.current;
|
|
117
|
+
if (trigger && children) {
|
|
114
118
|
this.subscribe(trigger);
|
|
115
119
|
}
|
|
116
120
|
}
|
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 {
|
|
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.
|
|
4
|
+
"version": "17.0.0-prerelease.30",
|
|
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/
|
|
36
|
-
"@semcore/
|
|
35
|
+
"@semcore/testing-utils": "1.0.0",
|
|
36
|
+
"@semcore/core": "17.0.0-prerelease.30"
|
|
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;
|