@spaced-out/ui-design-system 0.3.9 → 0.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/.cspell/custom-words.txt +1 -0
  2. package/CHANGELOG.md +11 -0
  3. package/lib/components/Banner/Banner.js +1 -0
  4. package/lib/components/Banner/Banner.js.flow +1 -0
  5. package/lib/components/ChatBubble/ChatBubble.js +152 -0
  6. package/lib/components/ChatBubble/ChatBubble.js.flow +218 -0
  7. package/lib/components/ChatBubble/ChatBubble.module.css +132 -0
  8. package/lib/components/ChatBubble/index.js +16 -0
  9. package/lib/components/ChatBubble/index.js.flow +3 -0
  10. package/lib/components/Disclaimer/Disclaimer.js +36 -0
  11. package/lib/components/Disclaimer/Disclaimer.js.flow +44 -0
  12. package/lib/components/Disclaimer/Disclaimer.module.css +14 -0
  13. package/lib/components/Disclaimer/index.js +16 -0
  14. package/lib/components/Disclaimer/index.js.flow +3 -0
  15. package/lib/components/InContextAlert/InContextAlert.js +17 -8
  16. package/lib/components/InContextAlert/InContextAlert.js.flow +11 -0
  17. package/lib/components/KPIBox/KPIBox.js.flow +1 -1
  18. package/lib/components/PromptChip/PromptChip.js +88 -0
  19. package/lib/components/PromptChip/PromptChip.js.flow +161 -0
  20. package/lib/components/PromptChip/PromptChip.module.css +82 -0
  21. package/lib/components/PromptChip/index.js +16 -0
  22. package/lib/components/PromptChip/index.js.flow +3 -0
  23. package/lib/components/PromptInput/PromptInput.js +119 -0
  24. package/lib/components/PromptInput/PromptInput.js.flow +190 -0
  25. package/lib/components/PromptInput/PromptInput.module.css +56 -0
  26. package/lib/components/PromptInput/index.js +16 -0
  27. package/lib/components/PromptInput/index.js.flow +3 -0
  28. package/lib/components/RadioTile/RadioTile.js +77 -0
  29. package/lib/components/RadioTile/RadioTile.js.flow +110 -0
  30. package/lib/components/RadioTile/RadioTile.module.css +41 -0
  31. package/lib/components/RadioTile/index.js +16 -0
  32. package/lib/components/RadioTile/index.js.flow +3 -0
  33. package/lib/components/Separator/Separator.js +41 -0
  34. package/lib/components/Separator/Separator.js.flow +62 -0
  35. package/lib/components/Separator/Separator.module.css +10 -0
  36. package/lib/components/Separator/index.js +16 -0
  37. package/lib/components/Separator/index.js.flow +3 -0
  38. package/lib/components/TextTile/TextTile.js +36 -0
  39. package/lib/components/TextTile/TextTile.js.flow +44 -0
  40. package/lib/components/TextTile/TextTile.module.css +27 -0
  41. package/lib/components/TextTile/index.js +16 -0
  42. package/lib/components/TextTile/index.js.flow +3 -0
  43. package/lib/components/Textarea/Textarea.js +2 -1
  44. package/lib/components/Textarea/Textarea.js.flow +2 -1
  45. package/lib/components/index.js +99 -0
  46. package/lib/components/index.js.flow +9 -0
  47. package/package.json +1 -1
@@ -0,0 +1,190 @@
1
+ // @flow strict
2
+
3
+ import * as React from 'react';
4
+
5
+ import {size200} from '../../styles/variables/_size';
6
+ import classify from '../../utils/classify';
7
+ import {Button, BUTTON_TYPES} from '../Button';
8
+ import type {IconType} from '../Icon';
9
+ import {ICON_TYPE} from '../Icon';
10
+ import {BodySmallBold, FormLabelSmall} from '../Text';
11
+ import {Textarea} from '../Textarea';
12
+
13
+ import css from './PromptInput.module.css';
14
+
15
+
16
+ const CONSTANTS = {
17
+ DEFAULT_INPUT_PLACEHOLDER: 'Ask me anything',
18
+ INPUT_NAME: 'prompt-textarea',
19
+ BUTTON_TEXT: 'Generate',
20
+ BUTTON_ICON: 'sparkles',
21
+ BUTTON_ARIA_LABEL: 'Prompt Button',
22
+ TEXT_AREA_ROWS: 1,
23
+ };
24
+
25
+ type ClassNames = $ReadOnly<{
26
+ wrapper?: string,
27
+ inputBox?: string,
28
+ textarea?: string,
29
+ buttonWrapper?: string,
30
+ buttonIcon?: string,
31
+ buttonText?: string,
32
+ }>;
33
+
34
+ export type PromptInputProps = {
35
+ // textArea Props
36
+ value?: string,
37
+ onInputChange?: (
38
+ evt: SyntheticInputEvent<HTMLInputElement>,
39
+ isEnter?: boolean,
40
+ ) => mixed,
41
+ onInputFocus?: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
42
+ onInputBlur?: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
43
+ onInputKeyDown?: (e: SyntheticKeyboardEvent<HTMLInputElement>) => mixed,
44
+ inputName?: string,
45
+ inputDisabled?: boolean,
46
+ inputPlaceholder?: string,
47
+ inputLocked?: boolean,
48
+ inputError?: boolean,
49
+ inputErrorText?: string,
50
+
51
+ // Common props
52
+ helperContent?: React.Node,
53
+ textCountLimit?: number,
54
+ classNames?: ClassNames,
55
+ withPadding?: boolean,
56
+
57
+ // Button Props
58
+ buttonText?: string,
59
+ buttonDisabled?: boolean,
60
+ onButtonClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
61
+ buttonAriaLabel?: string,
62
+ isButtonLoading?: boolean,
63
+ buttonIconLeftName?: string,
64
+ buttonIconLeftType?: IconType,
65
+ };
66
+
67
+ export const PromptInput: React$AbstractComponent<
68
+ PromptInputProps,
69
+ HTMLDivElement,
70
+ > = React.forwardRef<PromptInputProps, HTMLDivElement>(
71
+ (
72
+ {
73
+ value,
74
+ onInputChange,
75
+ onInputFocus,
76
+ onInputBlur,
77
+ onInputKeyDown,
78
+ inputName = CONSTANTS.INPUT_NAME,
79
+ inputDisabled,
80
+ inputPlaceholder = CONSTANTS.DEFAULT_INPUT_PLACEHOLDER,
81
+ inputLocked,
82
+ inputError,
83
+ inputErrorText,
84
+
85
+ helperContent,
86
+ textCountLimit,
87
+ classNames,
88
+ withPadding = true,
89
+
90
+ buttonText = CONSTANTS.BUTTON_TEXT,
91
+ buttonDisabled,
92
+ onButtonClick,
93
+ buttonAriaLabel = CONSTANTS.BUTTON_ARIA_LABEL,
94
+ isButtonLoading,
95
+ buttonIconLeftName = CONSTANTS.BUTTON_ICON,
96
+ buttonIconLeftType = ICON_TYPE.solid,
97
+ }: PromptInputProps,
98
+ ref,
99
+ ) => {
100
+ const textareaRef = React.useRef(null);
101
+
102
+ const handleInput = () => {
103
+ const textarea = textareaRef.current;
104
+ if (textarea) {
105
+ textarea.style.height = 'auto';
106
+ if (textarea.scrollHeight > parseInt(size200)) {
107
+ textarea.style.height = size200;
108
+ textarea.style.overflowY = 'auto';
109
+ } else {
110
+ textarea.style.height = `${textarea.scrollHeight}px`;
111
+ textarea.style.overflowY = 'hidden';
112
+ }
113
+ }
114
+ };
115
+
116
+ const textCountError = React.useMemo(() => {
117
+ const charCount = value ? value.length : 0;
118
+ return textCountLimit != null && charCount > textCountLimit;
119
+ }, [value, textCountLimit]);
120
+
121
+ return (
122
+ <div
123
+ ref={ref}
124
+ data-testid="PromptInput"
125
+ className={classify(
126
+ css.wrapper,
127
+ {[css.styledPromptContainer]: withPadding},
128
+ classNames?.wrapper,
129
+ )}
130
+ >
131
+ <div className={css.inputActionWrapper}>
132
+ <Textarea
133
+ classNames={{
134
+ box: classify(css.promptInputBox, classNames?.inputBox),
135
+ textarea: classify(css.textarea, classNames?.textarea),
136
+ }}
137
+ ref={textareaRef}
138
+ onInput={handleInput}
139
+ value={value}
140
+ onChange={onInputChange}
141
+ onFocus={onInputFocus}
142
+ onBlur={onInputBlur}
143
+ onKeyDown={onInputKeyDown}
144
+ name={inputName}
145
+ disabled={inputDisabled}
146
+ placeholder={inputPlaceholder}
147
+ locked={inputLocked}
148
+ error={inputError || textCountError}
149
+ errorText={inputErrorText}
150
+ rows={CONSTANTS.TEXT_AREA_ROWS}
151
+ ></Textarea>
152
+ <Button
153
+ iconLeftName={buttonIconLeftName}
154
+ iconLeftType={buttonIconLeftType}
155
+ onClick={onButtonClick}
156
+ type={BUTTON_TYPES.gradient}
157
+ disabled={buttonDisabled}
158
+ ariaLabel={buttonAriaLabel}
159
+ isLoading={isButtonLoading}
160
+ classNames={{
161
+ wrapper: classify(css.actionButton, classNames?.buttonWrapper),
162
+ icon: classNames?.buttonIcon,
163
+ text: classNames?.buttonText,
164
+ }}
165
+ >
166
+ {buttonText}
167
+ </Button>
168
+ </div>
169
+ {(!!helperContent || !!textCountLimit) && (
170
+ <div className={css.secondaryRow}>
171
+ {typeof helperContent === 'string' ? (
172
+ <BodySmallBold color={inputDisabled ? 'disabled' : 'secondary'}>
173
+ {helperContent}
174
+ </BodySmallBold>
175
+ ) : (
176
+ helperContent
177
+ )}
178
+ <FormLabelSmall
179
+ color={inputError || textCountError ? 'danger' : 'secondary'}
180
+ className={css.textCounter}
181
+ >
182
+ {!!textCountLimit &&
183
+ ((value && value.length) || 0) + '/' + textCountLimit}
184
+ </FormLabelSmall>
185
+ </div>
186
+ )}
187
+ </div>
188
+ );
189
+ },
190
+ );
@@ -0,0 +1,56 @@
1
+ @value (colorBackgroundTertiary) from '../../styles/variables/_color.css';
2
+ @value (
3
+ sizeFluid,
4
+ size140,
5
+ size42,
6
+ size200,
7
+ size160
8
+ ) from '../../styles/variables/_size.css';
9
+ @value (
10
+ spaceSmall,
11
+ spaceMedium
12
+ ) from '../../styles/variables/_space.css';
13
+
14
+ .wrapper {
15
+ display: flex;
16
+ flex-flow: column;
17
+ width: sizeFluid;
18
+ gap: spaceSmall;
19
+ }
20
+
21
+ .inputActionWrapper {
22
+ display: flex;
23
+ width: sizeFluid;
24
+ gap: spaceSmall;
25
+ }
26
+
27
+ .styledPromptContainer {
28
+ composes: borderTopPrimary from '../../styles/border.module.css';
29
+ background: colorBackgroundTertiary;
30
+ padding: spaceMedium;
31
+ }
32
+
33
+ .actionButton {
34
+ width: auto;
35
+ flex-shrink: 0;
36
+ }
37
+
38
+ .promptInputBox {
39
+ height: initial;
40
+ min-height: size42;
41
+ }
42
+
43
+ .textarea {
44
+ width: sizeFluid;
45
+ max-height: size200;
46
+ }
47
+
48
+ .secondaryRow {
49
+ display: flex;
50
+ justify-content: space-between;
51
+ align-items: flex-start;
52
+ }
53
+
54
+ .textCounter {
55
+ margin-left: auto;
56
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _PromptInput = require("./PromptInput");
7
+ Object.keys(_PromptInput).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _PromptInput[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _PromptInput[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,3 @@
1
+ // @flow strict
2
+
3
+ export * from './PromptInput';
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RadioTile = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _common = require("../../types/common");
9
+ var _classify = _interopRequireDefault(require("../../utils/classify"));
10
+ var _Card = require("../Card");
11
+ var _Chip = require("../Chip");
12
+ var _Icon = require("../Icon");
13
+ var _RadioButton = require("../RadioButton");
14
+ var _Text = require("../Text");
15
+ var _RadioTileModule = _interopRequireDefault(require("./RadioTile.module.css"));
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
20
+ const RadioTile = /*#__PURE__*/React.forwardRef((_ref, ref) => {
21
+ let {
22
+ classNames,
23
+ id,
24
+ semantic = _common.ALERT_SEMANTIC.neutral,
25
+ header,
26
+ description,
27
+ chipItems,
28
+ iconName,
29
+ iconSize = _Icon.ICON_SIZE.medium,
30
+ iconType = _Icon.ICON_TYPE.solid,
31
+ onTileClick,
32
+ isSelected = false,
33
+ ...props
34
+ } = _ref;
35
+ const handleTileClick = e => {
36
+ onTileClick && onTileClick(e, id);
37
+ };
38
+ return /*#__PURE__*/React.createElement(_Card.ClickableCard, _extends({}, props, {
39
+ ref: ref,
40
+ "data-testid": "RadioTile",
41
+ classNames: {
42
+ wrapper: (0, _classify.default)(_RadioTileModule.default.wrapper, classNames?.wrapper)
43
+ },
44
+ onClick: handleTileClick
45
+ }), /*#__PURE__*/React.createElement("div", {
46
+ className: _RadioTileModule.default.iconContainer
47
+ }, !!iconName && /*#__PURE__*/React.createElement(_Icon.SemanticIcon, {
48
+ semantic: semantic,
49
+ name: iconName,
50
+ size: iconSize,
51
+ type: iconType
52
+ })), /*#__PURE__*/React.createElement("div", {
53
+ className: _RadioTileModule.default.contentContainer
54
+ }, /*#__PURE__*/React.createElement("div", {
55
+ className: _RadioTileModule.default.textContainer
56
+ }, !!header && /*#__PURE__*/React.createElement(_Text.SubTitleMedium, null, header), !!description && /*#__PURE__*/React.createElement(_Text.BodyMedium, {
57
+ color: "secondary"
58
+ }, description)), !!chipItems?.length && /*#__PURE__*/React.createElement("div", {
59
+ className: _RadioTileModule.default.chipsContainer
60
+ }, chipItems.map((item, index) =>
61
+ /*#__PURE__*/
62
+ // eslint-disable-next-line react/no-array-index-key
63
+ React.createElement(_Chip.Chip, {
64
+ key: index,
65
+ semantic: "primary"
66
+ }, item)))), /*#__PURE__*/React.createElement("div", {
67
+ className: _RadioTileModule.default.btnContainer
68
+ }, /*#__PURE__*/React.createElement(_RadioButton.RadioButton, {
69
+ classNames: {
70
+ wrapper: _RadioTileModule.default.radioButtonWrapper
71
+ },
72
+ value: id,
73
+ selectedValue: isSelected ? id : '',
74
+ tabIndex: -1
75
+ })));
76
+ });
77
+ exports.RadioTile = RadioTile;
@@ -0,0 +1,110 @@
1
+ // @flow strict
2
+
3
+ import * as React from 'react';
4
+
5
+ import type {AlertSemanticType} from '../../types/common';
6
+ import {ALERT_SEMANTIC} from '../../types/common';
7
+ import classify from '../../utils/classify';
8
+ import {ClickableCard} from '../Card';
9
+ import {Chip} from '../Chip';
10
+ import type {IconSize, IconType} from '../Icon';
11
+ import {ICON_SIZE, ICON_TYPE, SemanticIcon} from '../Icon';
12
+ import {RadioButton} from '../RadioButton';
13
+ import {BodyMedium, SubTitleMedium} from '../Text';
14
+
15
+ import css from './RadioTile.module.css';
16
+
17
+
18
+ type ClassNames = $ReadOnly<{
19
+ wrapper?: string,
20
+ }>;
21
+
22
+ export type RadioTileProps = {
23
+ id: string,
24
+ classNames?: ClassNames,
25
+ semantic?: AlertSemanticType,
26
+ header?: string,
27
+ description?: string,
28
+ chipItems?: Array<string>,
29
+ onTileClick?: (e: SyntheticEvent<HTMLElement>, id: string) => void,
30
+ iconName?: string,
31
+ iconSize?: IconSize,
32
+ iconType?: IconType,
33
+ isSelected?: boolean,
34
+ };
35
+
36
+ export const RadioTile: React$AbstractComponent<
37
+ RadioTileProps,
38
+ HTMLDivElement,
39
+ > = React.forwardRef<RadioTileProps, HTMLDivElement>(
40
+ (
41
+ {
42
+ classNames,
43
+ id,
44
+ semantic = ALERT_SEMANTIC.neutral,
45
+ header,
46
+ description,
47
+ chipItems,
48
+ iconName,
49
+ iconSize = ICON_SIZE.medium,
50
+ iconType = ICON_TYPE.solid,
51
+ onTileClick,
52
+ isSelected = false,
53
+ ...props
54
+ }: RadioTileProps,
55
+ ref,
56
+ ) => {
57
+ const handleTileClick = (e: SyntheticEvent<HTMLElement>) => {
58
+ onTileClick && onTileClick(e, id);
59
+ };
60
+
61
+ return (
62
+ <ClickableCard
63
+ {...props}
64
+ ref={ref}
65
+ data-testid="RadioTile"
66
+ classNames={{
67
+ wrapper: classify(css.wrapper, classNames?.wrapper),
68
+ }}
69
+ onClick={handleTileClick}
70
+ >
71
+ <div className={css.iconContainer}>
72
+ {!!iconName && (
73
+ <SemanticIcon
74
+ semantic={semantic}
75
+ name={iconName}
76
+ size={iconSize}
77
+ type={iconType}
78
+ />
79
+ )}
80
+ </div>
81
+ <div className={css.contentContainer}>
82
+ <div className={css.textContainer}>
83
+ {!!header && <SubTitleMedium>{header}</SubTitleMedium>}
84
+ {!!description && (
85
+ <BodyMedium color="secondary">{description}</BodyMedium>
86
+ )}
87
+ </div>
88
+ {!!chipItems?.length && (
89
+ <div className={css.chipsContainer}>
90
+ {chipItems.map((item, index) => (
91
+ // eslint-disable-next-line react/no-array-index-key
92
+ <Chip key={index} semantic="primary">
93
+ {item}
94
+ </Chip>
95
+ ))}
96
+ </div>
97
+ )}
98
+ </div>
99
+ <div className={css.btnContainer}>
100
+ <RadioButton
101
+ classNames={{wrapper: css.radioButtonWrapper}}
102
+ value={id}
103
+ selectedValue={isSelected ? id : ''}
104
+ tabIndex={-1}
105
+ />
106
+ </div>
107
+ </ClickableCard>
108
+ );
109
+ },
110
+ );
@@ -0,0 +1,41 @@
1
+ @value (spaceXXSmall, spaceXSmall, spaceSmall) from '../../styles/variables/_space.css';
2
+ @value (size252, size26) from '../../styles/variables/_size.css';
3
+
4
+ .wrapper {
5
+ display: flex;
6
+ min-width: size252;
7
+ height: fit-content;
8
+ gap: spaceSmall;
9
+ }
10
+
11
+ .btnContainer {
12
+ align-self: center;
13
+ margin-left: auto;
14
+ }
15
+
16
+ .radioButtonWrapper {
17
+ padding-left: size26;
18
+ }
19
+
20
+ .iconContainer {
21
+ align-self: flex-start;
22
+ }
23
+
24
+ .chipsContainer {
25
+ display: flex;
26
+ flex-wrap: wrap;
27
+ gap: spaceXSmall;
28
+ margin-top: auto;
29
+ }
30
+
31
+ .contentContainer {
32
+ display: flex;
33
+ flex-direction: column;
34
+ gap: spaceSmall;
35
+ }
36
+
37
+ .textContainer {
38
+ display: flex;
39
+ flex-direction: column;
40
+ gap: spaceXXSmall;
41
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _RadioTile = require("./RadioTile");
7
+ Object.keys(_RadioTile).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _RadioTile[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _RadioTile[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,3 @@
1
+ // @flow strict
2
+
3
+ export * from './RadioTile';
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Separator = exports.ORIENTATION = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _size = require("../../styles/variables/_size");
9
+ var _classify = _interopRequireDefault(require("../../utils/classify"));
10
+ var _SeparatorModule = _interopRequireDefault(require("./Separator.module.css"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
+
15
+ const ORIENTATION = Object.freeze({
16
+ horizontal: 'horizontal',
17
+ vertical: 'vertical'
18
+ });
19
+ exports.ORIENTATION = ORIENTATION;
20
+ const Separator = /*#__PURE__*/React.forwardRef((_ref, ref) => {
21
+ let {
22
+ classNames,
23
+ orientation = ORIENTATION.vertical,
24
+ width,
25
+ height
26
+ } = _ref;
27
+ // Dynamically compute width and height based on orientation if not provided
28
+ const resolvedWidth = width || (orientation === ORIENTATION.vertical ? _size.size2 : 'auto');
29
+ const resolvedHeight = height || (orientation === ORIENTATION.horizontal ? _size.size2 : 'auto');
30
+ const style = {
31
+ '--separator-width': orientation === ORIENTATION.vertical ? resolvedWidth : 'auto',
32
+ '--separator-height': orientation === ORIENTATION.horizontal ? resolvedHeight : 'auto'
33
+ };
34
+ return /*#__PURE__*/React.createElement("div", {
35
+ ref: ref,
36
+ "data-testid": "Separator",
37
+ style: style,
38
+ className: (0, _classify.default)(_SeparatorModule.default.wrapper, classNames?.wrapper)
39
+ });
40
+ });
41
+ exports.Separator = Separator;
@@ -0,0 +1,62 @@
1
+ // @flow strict
2
+
3
+ import * as React from 'react';
4
+
5
+ import {size2} from '../../styles/variables/_size';
6
+ import classify from '../../utils/classify';
7
+
8
+ import css from './Separator.module.css';
9
+
10
+
11
+ type ClassNames = $ReadOnly<{wrapper?: string}>;
12
+
13
+ export const ORIENTATION = Object.freeze({
14
+ horizontal: 'horizontal',
15
+ vertical: 'vertical',
16
+ });
17
+
18
+ export type OrientationType = $Values<typeof ORIENTATION>;
19
+
20
+ export type SeparatorProps = {
21
+ classNames?: ClassNames,
22
+ orientation?: OrientationType,
23
+ width?: string,
24
+ height?: string,
25
+ };
26
+
27
+ export const Separator: React$AbstractComponent<
28
+ SeparatorProps,
29
+ HTMLDivElement,
30
+ > = React.forwardRef<SeparatorProps, HTMLDivElement>(
31
+ (
32
+ {
33
+ classNames,
34
+ orientation = ORIENTATION.vertical,
35
+ width,
36
+ height,
37
+ }: SeparatorProps,
38
+ ref,
39
+ ) => {
40
+ // Dynamically compute width and height based on orientation if not provided
41
+ const resolvedWidth =
42
+ width || (orientation === ORIENTATION.vertical ? size2 : 'auto');
43
+ const resolvedHeight =
44
+ height || (orientation === ORIENTATION.horizontal ? size2 : 'auto');
45
+
46
+ const style = {
47
+ '--separator-width':
48
+ orientation === ORIENTATION.vertical ? resolvedWidth : 'auto',
49
+ '--separator-height':
50
+ orientation === ORIENTATION.horizontal ? resolvedHeight : 'auto',
51
+ };
52
+
53
+ return (
54
+ <div
55
+ ref={ref}
56
+ data-testid="Separator"
57
+ style={style}
58
+ className={classify(css.wrapper, classNames?.wrapper)}
59
+ />
60
+ );
61
+ },
62
+ );
@@ -0,0 +1,10 @@
1
+ @value (colorBorderSecondary) from '../../styles/variables/_color.css';
2
+ @value (borderRadiusSmall) from '../../styles/variables/_border.css';
3
+
4
+ .wrapper {
5
+ display: flex;
6
+ background-color: colorBorderSecondary;
7
+ width: var(--separator-width);
8
+ height: var(--separator-height);
9
+ border-radius: borderRadiusSmall;
10
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _Separator = require("./Separator");
7
+ Object.keys(_Separator).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _Separator[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _Separator[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,3 @@
1
+ // @flow strict
2
+
3
+ export * from './Separator';