@stokr/components-library 2.3.65-beta.6 → 2.3.65-beta.8
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/dist/components/Input/Input.js +33 -33
- package/dist/components/Input/Input.stories.js +83 -8
- package/dist/components/Input/MultiSelect.js +35 -8
- package/dist/components/Input/MultiSelect.stories.js +68 -2
- package/dist/components/Input/SearchInput.js +5 -2
- package/dist/components/Input/SearchInput.stories.js +63 -1
- package/dist/components/Input/SearchInput.styles.js +1 -1
- package/dist/components/Input/Select.js +51 -28
- package/dist/components/Input/Select.stories.js +345 -6
- package/dist/components/ProfileBox/ProfileBox.js +2 -1
- package/dist/components/Snackbar/Snackbar.js +193 -0
- package/dist/components/Snackbar/Snackbar.stories.js +292 -0
- package/dist/components/Snackbar/Snackbar.styles.js +97 -0
- package/dist/components/Snackbar/SnackbarProvider.js +81 -0
- package/dist/components/Snackbar/index.js +32 -0
- package/dist/components/Snackbar/useSnackbar.js +43 -0
- package/dist/components/StepsProgress/StepIndicator.js +2 -1
- package/dist/index.js +11 -0
- package/package.json +1 -1
|
@@ -7,65 +7,64 @@ exports.default = exports.Input = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _Input = require("./Input.styles");
|
|
10
|
+
const _excluded = ["type", "id", "name", "label", "placeholder", "value", "error", "touched", "readOnly", "inverted", "dashboard", "disabled", "inputWrapStyle", "wrapperStyle", "autoHeightLabel", "onChange", "onBlur", "onFocus"];
|
|
10
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
12
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
13
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
14
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
15
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
13
16
|
const Input = props => {
|
|
14
17
|
const {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
type,
|
|
19
|
+
id,
|
|
20
|
+
name,
|
|
21
|
+
label,
|
|
22
|
+
placeholder,
|
|
23
|
+
value,
|
|
24
|
+
error,
|
|
25
|
+
touched,
|
|
26
|
+
readOnly,
|
|
27
|
+
inverted,
|
|
28
|
+
dashboard,
|
|
29
|
+
disabled,
|
|
30
|
+
inputWrapStyle,
|
|
31
|
+
wrapperStyle,
|
|
32
|
+
autoHeightLabel,
|
|
33
|
+
// Destructure these so they don't get spread to the input
|
|
34
|
+
onChange: onChangeProp,
|
|
35
|
+
onBlur: onBlurProp,
|
|
36
|
+
onFocus: onFocusProp
|
|
37
|
+
} = props,
|
|
38
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
31
39
|
const [labelUp, setLabelUp] = (0, _react.useState)(false);
|
|
32
40
|
const [hasFocus, setHasFocus] = (0, _react.useState)(false);
|
|
33
41
|
(0, _react.useEffect)(() => {
|
|
34
42
|
checkLabel(false);
|
|
35
43
|
}, []);
|
|
36
44
|
(0, _react.useEffect)(() => {
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
if (!!value && !labelUp) {
|
|
46
|
+
checkLabel(false);
|
|
47
|
+
}
|
|
48
|
+
}, [labelUp, value]);
|
|
39
49
|
(0, _react.useEffect)(() => {
|
|
40
50
|
if (value && !labelUp) setLabelUp(true);
|
|
41
51
|
}, [value, labelUp]);
|
|
42
52
|
const onBlur = (e, field) => {
|
|
43
|
-
const {
|
|
44
|
-
onBlur
|
|
45
|
-
} = props;
|
|
46
|
-
|
|
47
53
|
// formik handler MUST be called before our logic !
|
|
48
|
-
|
|
54
|
+
onBlurProp && onBlurProp(e, field);
|
|
49
55
|
|
|
50
56
|
// our logic follows
|
|
51
57
|
checkLabel(false);
|
|
52
58
|
};
|
|
53
59
|
const onFocus = (e, field) => {
|
|
54
|
-
const {
|
|
55
|
-
onFocus
|
|
56
|
-
} = props;
|
|
57
|
-
|
|
58
60
|
// formik handler MUST be called before our logic !
|
|
59
|
-
|
|
61
|
+
onFocusProp && onFocusProp(e, field);
|
|
60
62
|
|
|
61
63
|
// our logic follows
|
|
62
64
|
checkLabel(true);
|
|
63
65
|
};
|
|
64
66
|
const onChange = (e, field) => {
|
|
65
|
-
|
|
66
|
-
onChange
|
|
67
|
-
} = props;
|
|
68
|
-
onChange && onChange(e, field); // formik handler
|
|
67
|
+
onChangeProp && onChangeProp(e, field); // formik handler
|
|
69
68
|
};
|
|
70
69
|
const checkLabel = focus => {
|
|
71
70
|
setHasFocus(focus);
|
|
@@ -96,11 +95,12 @@ const Input = props => {
|
|
|
96
95
|
onFocus: onFocus,
|
|
97
96
|
readOnly: readOnly,
|
|
98
97
|
placeholder: placeholder,
|
|
98
|
+
disabled: disabled,
|
|
99
99
|
style: {
|
|
100
100
|
WebkitAppearance: 'none',
|
|
101
101
|
WebkitBorderRadius: 0
|
|
102
102
|
}
|
|
103
|
-
},
|
|
103
|
+
}, restProps))));
|
|
104
104
|
};
|
|
105
105
|
exports.Input = Input;
|
|
106
106
|
Input.propTypes = {
|
|
@@ -3,16 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.InputLabeled = exports.InputFilled = exports.InputFillInverted = exports.InputEmpty = void 0;
|
|
6
|
+
exports.default = exports.InputLabeled = exports.InputFilled = exports.InputFillInverted = exports.InputEmpty = exports.AllStates = void 0;
|
|
7
7
|
var _viewport = require("storybook/viewport");
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _Input = require("./Input");
|
|
10
10
|
var _ComponentWrapper = require("../ComponentWrapper/ComponentWrapper.styles");
|
|
11
11
|
var _global = _interopRequireDefault(require("../../styles/global"));
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
13
15
|
var _default = exports.default = {
|
|
14
16
|
title: 'Components Library/Inputs/Input',
|
|
15
17
|
component: _Input.Input,
|
|
18
|
+
decorators: [Story => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(Story, null)))],
|
|
16
19
|
argTypes: {
|
|
17
20
|
type: {
|
|
18
21
|
type: 'string'
|
|
@@ -79,8 +82,19 @@ var _default = exports.default = {
|
|
|
79
82
|
defaultViewport: 'resetviewport'
|
|
80
83
|
}
|
|
81
84
|
}
|
|
85
|
+
}; // Controlled wrapper for interactive stories
|
|
86
|
+
const ControlledInput = props => {
|
|
87
|
+
const [value, setValue] = (0, _react.useState)(props.value || '');
|
|
88
|
+
return /*#__PURE__*/_react.default.createElement(_Input.Input, _extends({}, props, {
|
|
89
|
+
value: value,
|
|
90
|
+
onChange: e => {
|
|
91
|
+
var _props$onChange;
|
|
92
|
+
setValue(e.target.value);
|
|
93
|
+
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, e);
|
|
94
|
+
}
|
|
95
|
+
}));
|
|
82
96
|
};
|
|
83
|
-
const Template = args => /*#__PURE__*/_react.default.createElement(
|
|
97
|
+
const Template = args => /*#__PURE__*/_react.default.createElement(ControlledInput, args);
|
|
84
98
|
|
|
85
99
|
//trying to integrate state:
|
|
86
100
|
// const Template = args => {
|
|
@@ -135,8 +149,69 @@ InputEmpty.parameters = {
|
|
|
135
149
|
}
|
|
136
150
|
};
|
|
137
151
|
|
|
138
|
-
//
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
152
|
+
// All states example
|
|
153
|
+
const AllStates = () => {
|
|
154
|
+
const [value1, setValue1] = (0, _react.useState)('');
|
|
155
|
+
const [value2, setValue2] = (0, _react.useState)('Filled value');
|
|
156
|
+
const [value3, setValue3] = (0, _react.useState)('');
|
|
157
|
+
const [value4, setValue4] = (0, _react.useState)('Error text');
|
|
158
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
159
|
+
style: {
|
|
160
|
+
display: 'flex',
|
|
161
|
+
flexDirection: 'column',
|
|
162
|
+
gap: '32px'
|
|
163
|
+
}
|
|
164
|
+
}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
|
|
165
|
+
style: {
|
|
166
|
+
marginBottom: '8px',
|
|
167
|
+
fontSize: '12px',
|
|
168
|
+
color: '#666'
|
|
169
|
+
}
|
|
170
|
+
}, "Empty - Click to see blue label on focus"), /*#__PURE__*/_react.default.createElement(_Input.Input, {
|
|
171
|
+
id: "empty",
|
|
172
|
+
name: "empty",
|
|
173
|
+
label: "Empty Input",
|
|
174
|
+
value: value1,
|
|
175
|
+
onChange: e => setValue1(e.target.value)
|
|
176
|
+
})), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
|
|
177
|
+
style: {
|
|
178
|
+
marginBottom: '8px',
|
|
179
|
+
fontSize: '12px',
|
|
180
|
+
color: '#666'
|
|
181
|
+
}
|
|
182
|
+
}, "With value"), /*#__PURE__*/_react.default.createElement(_Input.Input, {
|
|
183
|
+
id: "filled",
|
|
184
|
+
name: "filled",
|
|
185
|
+
label: "Filled Input",
|
|
186
|
+
value: value2,
|
|
187
|
+
onChange: e => setValue2(e.target.value)
|
|
188
|
+
})), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
|
|
189
|
+
style: {
|
|
190
|
+
marginBottom: '8px',
|
|
191
|
+
fontSize: '12px',
|
|
192
|
+
color: '#666'
|
|
193
|
+
}
|
|
194
|
+
}, "Disabled"), /*#__PURE__*/_react.default.createElement(_Input.Input, {
|
|
195
|
+
id: "disabled",
|
|
196
|
+
name: "disabled",
|
|
197
|
+
label: "Disabled Input",
|
|
198
|
+
value: "Cannot edit",
|
|
199
|
+
disabled: true,
|
|
200
|
+
onChange: () => {}
|
|
201
|
+
})), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
|
|
202
|
+
style: {
|
|
203
|
+
marginBottom: '8px',
|
|
204
|
+
fontSize: '12px',
|
|
205
|
+
color: '#666'
|
|
206
|
+
}
|
|
207
|
+
}, "Error state"), /*#__PURE__*/_react.default.createElement(_Input.Input, {
|
|
208
|
+
id: "error",
|
|
209
|
+
name: "error",
|
|
210
|
+
label: "Error Input",
|
|
211
|
+
value: value4,
|
|
212
|
+
onChange: e => setValue4(e.target.value),
|
|
213
|
+
error: true,
|
|
214
|
+
touched: true
|
|
215
|
+
})));
|
|
216
|
+
};
|
|
217
|
+
exports.AllStates = AllStates;
|
|
@@ -13,7 +13,7 @@ var _colors = _interopRequireDefault(require("../../styles/colors"));
|
|
|
13
13
|
var _checkIcon = require("../../static/images/check-icon.svg");
|
|
14
14
|
var _Select = require("./Select.styles");
|
|
15
15
|
const _excluded = ["children", "selectProps"],
|
|
16
|
-
_excluded2 = ["id", "name", "label", "options", "search", "error", "touched", "value", "disabled", "menuHeight", "placeholder", "showCheckboxes", "showCountBadge", "closeMenuOnSelect", "hideSelectedOptions"];
|
|
16
|
+
_excluded2 = ["id", "name", "label", "options", "search", "error", "touched", "value", "disabled", "menuHeight", "placeholder", "showCheckboxes", "showCountBadge", "closeMenuOnSelect", "hideSelectedOptions", "width", "minMenuWidth", "maxMenuWidth"];
|
|
17
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
18
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
19
19
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -39,7 +39,7 @@ const Checkbox = _styledComponents.default.div.withConfig({
|
|
|
39
39
|
const OptionLabel = _styledComponents.default.span.withConfig({
|
|
40
40
|
displayName: "MultiSelect__OptionLabel",
|
|
41
41
|
componentId: "sc-1udb3q8-3"
|
|
42
|
-
})(["font-size:14px;color:", ";font-weight:400;letter-spacing:0.6px;"], _colors.default.black);
|
|
42
|
+
})(["font-size:14px;color:", ";font-weight:400;letter-spacing:0.6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1;min-width:0;"], _colors.default.black);
|
|
43
43
|
const PlaceholderText = _styledComponents.default.span.withConfig({
|
|
44
44
|
displayName: "MultiSelect__PlaceholderText",
|
|
45
45
|
componentId: "sc-1udb3q8-4"
|
|
@@ -125,7 +125,10 @@ const MultiSelect = props => {
|
|
|
125
125
|
showCheckboxes = true,
|
|
126
126
|
showCountBadge = true,
|
|
127
127
|
closeMenuOnSelect = false,
|
|
128
|
-
hideSelectedOptions = false
|
|
128
|
+
hideSelectedOptions = false,
|
|
129
|
+
width,
|
|
130
|
+
minMenuWidth = 150,
|
|
131
|
+
maxMenuWidth = 300
|
|
129
132
|
} = props,
|
|
130
133
|
otherProps = _objectWithoutProperties(props, _excluded2);
|
|
131
134
|
const hasValue = (value === null || value === void 0 ? void 0 : value.length) > 0;
|
|
@@ -164,7 +167,11 @@ const MultiSelect = props => {
|
|
|
164
167
|
|
|
165
168
|
// Get selected options from value array
|
|
166
169
|
const selectedOptions = options === null || options === void 0 ? void 0 : options.filter(option => value === null || value === void 0 ? void 0 : value.includes(option.value));
|
|
167
|
-
return /*#__PURE__*/_react.default.createElement(_Input.Wrapper,
|
|
170
|
+
return /*#__PURE__*/_react.default.createElement(_Input.Wrapper, {
|
|
171
|
+
style: {
|
|
172
|
+
width: width || 'auto'
|
|
173
|
+
}
|
|
174
|
+
}, label && /*#__PURE__*/_react.default.createElement(_Input.Label, {
|
|
168
175
|
isUp: labelUp,
|
|
169
176
|
active: hasFocus,
|
|
170
177
|
error: error && touched,
|
|
@@ -206,7 +213,10 @@ const MultiSelect = props => {
|
|
|
206
213
|
borderRadius: '8px',
|
|
207
214
|
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
|
|
208
215
|
border: "1px solid ".concat(_colors.default.lightGrey),
|
|
209
|
-
overflow: 'hidden'
|
|
216
|
+
overflow: 'hidden',
|
|
217
|
+
minWidth: minMenuWidth,
|
|
218
|
+
maxWidth: maxMenuWidth,
|
|
219
|
+
width: 'auto'
|
|
210
220
|
}),
|
|
211
221
|
menuList: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
212
222
|
padding: 0
|
|
@@ -219,6 +229,9 @@ const MultiSelect = props => {
|
|
|
219
229
|
color: _colors.default.black,
|
|
220
230
|
cursor: 'pointer',
|
|
221
231
|
fontWeight: state.isSelected ? 600 : 400,
|
|
232
|
+
whiteSpace: 'nowrap',
|
|
233
|
+
overflow: 'hidden',
|
|
234
|
+
textOverflow: 'ellipsis',
|
|
222
235
|
'&:active': {
|
|
223
236
|
backgroundColor: _colors.default.grey
|
|
224
237
|
}
|
|
@@ -239,7 +252,15 @@ const MultiSelect = props => {
|
|
|
239
252
|
padding: 0
|
|
240
253
|
}),
|
|
241
254
|
indicatorsContainer: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
242
|
-
|
|
255
|
+
padding: 0,
|
|
256
|
+
gap: '4px'
|
|
257
|
+
}),
|
|
258
|
+
dropdownIndicator: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
259
|
+
padding: '4px'
|
|
260
|
+
}),
|
|
261
|
+
clearIndicator: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
262
|
+
padding: '4px'
|
|
263
|
+
// display: 'none',
|
|
243
264
|
})
|
|
244
265
|
},
|
|
245
266
|
components: {
|
|
@@ -272,7 +293,10 @@ MultiSelect.propTypes = {
|
|
|
272
293
|
showCheckboxes: _propTypes.default.bool,
|
|
273
294
|
showCountBadge: _propTypes.default.bool,
|
|
274
295
|
closeMenuOnSelect: _propTypes.default.bool,
|
|
275
|
-
hideSelectedOptions: _propTypes.default.bool
|
|
296
|
+
hideSelectedOptions: _propTypes.default.bool,
|
|
297
|
+
width: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
298
|
+
minMenuWidth: _propTypes.default.number,
|
|
299
|
+
maxMenuWidth: _propTypes.default.number
|
|
276
300
|
};
|
|
277
301
|
MultiSelect.defaultProps = {
|
|
278
302
|
label: '',
|
|
@@ -287,6 +311,9 @@ MultiSelect.defaultProps = {
|
|
|
287
311
|
showCheckboxes: true,
|
|
288
312
|
showCountBadge: true,
|
|
289
313
|
closeMenuOnSelect: false,
|
|
290
|
-
hideSelectedOptions: false
|
|
314
|
+
hideSelectedOptions: false,
|
|
315
|
+
width: undefined,
|
|
316
|
+
minMenuWidth: 150,
|
|
317
|
+
maxMenuWidth: 300
|
|
291
318
|
};
|
|
292
319
|
var _default = exports.default = MultiSelect;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.WithoutCheckboxes = exports.WithPreselectedValues = exports.WithManyOptions = exports.MultipleFilters = exports.Disabled = exports.Default = void 0;
|
|
6
|
+
exports.default = exports.WithoutCheckboxes = exports.WithPreselectedValues = exports.WithManyOptions = exports.MultipleFilters = exports.Disabled = exports.Default = exports.CustomWidth = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _MultiSelect = require("./MultiSelect");
|
|
9
9
|
var _global = _interopRequireDefault(require("../../styles/global"));
|
|
@@ -195,4 +195,70 @@ const Disabled = () => /*#__PURE__*/_react.default.createElement(ControlledMulti
|
|
|
195
195
|
value: ['initiated'],
|
|
196
196
|
disabled: true
|
|
197
197
|
});
|
|
198
|
-
|
|
198
|
+
|
|
199
|
+
// Custom width - narrow select with wider menu
|
|
200
|
+
exports.Disabled = Disabled;
|
|
201
|
+
const CustomWidth = () => {
|
|
202
|
+
const longOptions = [{
|
|
203
|
+
key: 'opt1',
|
|
204
|
+
value: 'opt1',
|
|
205
|
+
label: 'Very Long Option Name Here'
|
|
206
|
+
}, {
|
|
207
|
+
key: 'opt2',
|
|
208
|
+
value: 'opt2',
|
|
209
|
+
label: 'Another Long Option'
|
|
210
|
+
}, {
|
|
211
|
+
key: 'opt3',
|
|
212
|
+
value: 'opt3',
|
|
213
|
+
label: 'Short'
|
|
214
|
+
}, {
|
|
215
|
+
key: 'opt4',
|
|
216
|
+
value: 'opt4',
|
|
217
|
+
label: 'Medium Length Option'
|
|
218
|
+
}];
|
|
219
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
220
|
+
style: {
|
|
221
|
+
display: 'flex',
|
|
222
|
+
flexDirection: 'column',
|
|
223
|
+
gap: '24px'
|
|
224
|
+
}
|
|
225
|
+
}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
|
|
226
|
+
style: {
|
|
227
|
+
marginBottom: '8px',
|
|
228
|
+
fontSize: '14px'
|
|
229
|
+
}
|
|
230
|
+
}, "Narrow select (80px), menu expands (150-250px)"), /*#__PURE__*/_react.default.createElement(ControlledMultiSelect, {
|
|
231
|
+
id: "narrow",
|
|
232
|
+
name: "narrow",
|
|
233
|
+
placeholder: "Filter",
|
|
234
|
+
options: longOptions,
|
|
235
|
+
width: 80,
|
|
236
|
+
minMenuWidth: 150,
|
|
237
|
+
maxMenuWidth: 250
|
|
238
|
+
})), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
|
|
239
|
+
style: {
|
|
240
|
+
marginBottom: '8px',
|
|
241
|
+
fontSize: '14px'
|
|
242
|
+
}
|
|
243
|
+
}, "Fixed width (200px)"), /*#__PURE__*/_react.default.createElement(ControlledMultiSelect, {
|
|
244
|
+
id: "fixed",
|
|
245
|
+
name: "fixed",
|
|
246
|
+
placeholder: "Status",
|
|
247
|
+
options: statusOptions,
|
|
248
|
+
width: "200px"
|
|
249
|
+
})), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
|
|
250
|
+
style: {
|
|
251
|
+
marginBottom: '8px',
|
|
252
|
+
fontSize: '14px'
|
|
253
|
+
}
|
|
254
|
+
}, "Wide menu (up to 400px) for long text"), /*#__PURE__*/_react.default.createElement(ControlledMultiSelect, {
|
|
255
|
+
id: "wide",
|
|
256
|
+
name: "wide",
|
|
257
|
+
placeholder: "Select",
|
|
258
|
+
options: longOptions,
|
|
259
|
+
width: 120,
|
|
260
|
+
minMenuWidth: 200,
|
|
261
|
+
maxMenuWidth: 400
|
|
262
|
+
})));
|
|
263
|
+
};
|
|
264
|
+
exports.CustomWidth = CustomWidth;
|
|
@@ -7,7 +7,7 @@ exports.default = exports.SearchInput = void 0;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _SearchInput = require("./SearchInput.styles");
|
|
9
9
|
var _searchIcon = require("../../static/images/search-icon.svg");
|
|
10
|
-
const _excluded = ["value", "onChange", "placeholder", "icon", "showIcon", "disabled", "onFocus", "onBlur", "className", "containerStyle", "inputStyle", "iconStyle", "id", "name", "aria-label", "aria-describedby"];
|
|
10
|
+
const _excluded = ["value", "onChange", "placeholder", "icon", "showIcon", "disabled", "variant", "onFocus", "onBlur", "className", "containerStyle", "inputStyle", "iconStyle", "id", "name", "aria-label", "aria-describedby"];
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
13
13
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
@@ -20,6 +20,8 @@ const SearchInput = _ref => {
|
|
|
20
20
|
icon,
|
|
21
21
|
showIcon = true,
|
|
22
22
|
disabled = false,
|
|
23
|
+
variant = 'filled',
|
|
24
|
+
// 'filled' or 'outlined'
|
|
23
25
|
onFocus,
|
|
24
26
|
onBlur,
|
|
25
27
|
className,
|
|
@@ -53,7 +55,8 @@ const SearchInput = _ref => {
|
|
|
53
55
|
className: className,
|
|
54
56
|
style: containerStyle
|
|
55
57
|
}, /*#__PURE__*/_react.default.createElement(_SearchInput.SearchInputWrapper, {
|
|
56
|
-
disabled: disabled
|
|
58
|
+
disabled: disabled,
|
|
59
|
+
variant: variant
|
|
57
60
|
}, showIcon && /*#__PURE__*/_react.default.createElement(_SearchInput.SearchIconWrapper, {
|
|
58
61
|
style: iconStyle
|
|
59
62
|
}, icon || /*#__PURE__*/_react.default.createElement(_searchIcon.ReactComponent, null)), /*#__PURE__*/_react.default.createElement(_SearchInput.SearchInputField, _extends({
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.WithoutIcon = exports.WithInitialValue = exports.WithCustomIcon = exports.LongText = exports.Disabled = exports.DifferentWidths = exports.Default = exports.CustomStyling = exports.CustomPlaceholder = exports.AllStates = exports.AccessibilityExample = void 0;
|
|
6
|
+
exports.default = exports.WithoutIcon = exports.WithInitialValue = exports.WithCustomIcon = exports.Variants = exports.Outlined = exports.LongText = exports.Disabled = exports.DifferentWidths = exports.Default = exports.CustomStyling = exports.CustomPlaceholder = exports.AllStates = exports.AccessibilityExample = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _SearchInput = _interopRequireDefault(require("./SearchInput"));
|
|
9
9
|
var _ComponentWrapper = require("../ComponentWrapper/ComponentWrapper.styles");
|
|
@@ -28,6 +28,14 @@ var _default = exports.default = {
|
|
|
28
28
|
description: 'Placeholder text',
|
|
29
29
|
defaultValue: 'Search'
|
|
30
30
|
},
|
|
31
|
+
variant: {
|
|
32
|
+
control: {
|
|
33
|
+
type: 'select'
|
|
34
|
+
},
|
|
35
|
+
options: ['filled', 'outlined'],
|
|
36
|
+
description: 'Visual variant of the input',
|
|
37
|
+
defaultValue: 'filled'
|
|
38
|
+
},
|
|
31
39
|
showIcon: {
|
|
32
40
|
control: 'boolean',
|
|
33
41
|
description: 'Show/hide the search icon',
|
|
@@ -276,7 +284,61 @@ AccessibilityExample.decorators = [Story => /*#__PURE__*/_react.default.createEl
|
|
|
276
284
|
}
|
|
277
285
|
}, "Use this search to find products by name, category, or description."))];
|
|
278
286
|
|
|
287
|
+
// Outlined variant
|
|
288
|
+
const Outlined = () => {
|
|
289
|
+
const [value, setValue] = (0, _react.useState)('');
|
|
290
|
+
return /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(_SearchInput.default, {
|
|
291
|
+
value: value,
|
|
292
|
+
onChange: setValue,
|
|
293
|
+
placeholder: "Search",
|
|
294
|
+
variant: "outlined"
|
|
295
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
296
|
+
style: {
|
|
297
|
+
marginTop: '12px',
|
|
298
|
+
fontSize: '12px',
|
|
299
|
+
color: _colors.default.grey2
|
|
300
|
+
}
|
|
301
|
+
}, "Current value: ", /*#__PURE__*/_react.default.createElement("strong", null, value || '(empty)')));
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
// Both variants side by side
|
|
305
|
+
exports.Outlined = Outlined;
|
|
306
|
+
const Variants = () => {
|
|
307
|
+
const [value1, setValue1] = (0, _react.useState)('');
|
|
308
|
+
const [value2, setValue2] = (0, _react.useState)('');
|
|
309
|
+
return /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
310
|
+
style: {
|
|
311
|
+
marginBottom: '24px'
|
|
312
|
+
}
|
|
313
|
+
}, /*#__PURE__*/_react.default.createElement("h4", {
|
|
314
|
+
style: {
|
|
315
|
+
marginBottom: '8px',
|
|
316
|
+
fontSize: '14px'
|
|
317
|
+
}
|
|
318
|
+
}, "Filled (default)"), /*#__PURE__*/_react.default.createElement(_SearchInput.default, {
|
|
319
|
+
value: value1,
|
|
320
|
+
onChange: setValue1,
|
|
321
|
+
placeholder: "Search",
|
|
322
|
+
variant: "filled"
|
|
323
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
324
|
+
style: {
|
|
325
|
+
marginBottom: '24px'
|
|
326
|
+
}
|
|
327
|
+
}, /*#__PURE__*/_react.default.createElement("h4", {
|
|
328
|
+
style: {
|
|
329
|
+
marginBottom: '8px',
|
|
330
|
+
fontSize: '14px'
|
|
331
|
+
}
|
|
332
|
+
}, "Outlined"), /*#__PURE__*/_react.default.createElement(_SearchInput.default, {
|
|
333
|
+
value: value2,
|
|
334
|
+
onChange: setValue2,
|
|
335
|
+
placeholder: "Search",
|
|
336
|
+
variant: "outlined"
|
|
337
|
+
})));
|
|
338
|
+
};
|
|
339
|
+
|
|
279
340
|
// Custom styling
|
|
341
|
+
exports.Variants = Variants;
|
|
280
342
|
const CustomStyling = () => {
|
|
281
343
|
const [value, setValue] = (0, _react.useState)('');
|
|
282
344
|
return /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(_SearchInput.default, {
|
|
@@ -14,7 +14,7 @@ const SearchInputContainer = exports.SearchInputContainer = _styledComponents.de
|
|
|
14
14
|
const SearchInputWrapper = exports.SearchInputWrapper = _styledComponents.default.div.withConfig({
|
|
15
15
|
displayName: "SearchInputstyles__SearchInputWrapper",
|
|
16
16
|
componentId: "sc-dcxztv-1"
|
|
17
|
-
})(["position:relative;display:flex;align-items:center;width:100%;
|
|
17
|
+
})(["position:relative;display:flex;align-items:center;width:100%;border-radius:8px;padding:0 16px;min-height:40px;transition:all 0.2s ease;background-color:", ";border:", ";", " &:focus-within{background-color:", ";border-color:", ";box-shadow:", ";}&:hover{border-color:", ";}"], props => props.variant === 'outlined' ? 'transparent' : _colors.default.grey3, props => props.variant === 'outlined' ? "1px solid ".concat(_colors.default.lightGrey) : '1px solid transparent', props => props.disabled && "\n opacity: 0.6;\n cursor: not-allowed;\n ", props => props.variant === 'outlined' ? 'transparent' : _colors.default.white, props => props.variant === 'outlined' ? _colors.default.grey2 : 'transparent', props => props.variant === 'outlined' ? 'none' : "0 0 0 2px ".concat(_colors.default.lightGrey), props => props.variant === 'outlined' ? _colors.default.grey2 : 'transparent');
|
|
18
18
|
const SearchIconWrapper = exports.SearchIconWrapper = _styledComponents.default.div.withConfig({
|
|
19
19
|
displayName: "SearchInputstyles__SearchIconWrapper",
|
|
20
20
|
componentId: "sc-dcxztv-2"
|