@cashub/ui 0.44.3 → 0.45.1
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/chart/DoughnutChart.js +18 -6
- package/chart/utils/centerTextPlugin.js +62 -0
- package/chart/utils/htmlLegendPlugin.js +6 -0
- package/chart/utils/padEmptyChartBar.js +4 -1
- package/package.json +1 -1
- package/select/Select.js +86 -43
- package/select/subComponent/Option.js +7 -2
- package/select/subComponent/SelectedMultipleText.js +44 -2
package/chart/DoughnutChart.js
CHANGED
|
@@ -5,14 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
-
var _styledComponents = require("styled-components");
|
|
8
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
9
|
var _reactChartjs = require("react-chartjs-2");
|
|
10
10
|
var _lodash = _interopRequireDefault(require("lodash.uniqueid"));
|
|
11
11
|
var _htmlLegendPlugin = _interopRequireDefault(require("./utils/htmlLegendPlugin"));
|
|
12
12
|
var _customTooltip = _interopRequireDefault(require("./utils/customTooltip"));
|
|
13
|
+
var _centerTextPlugin = _interopRequireDefault(require("./utils/centerTextPlugin"));
|
|
13
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
-
|
|
15
|
+
var _templateObject;
|
|
16
|
+
const _excluded = ["height", "data", "showCenterText", "centerTextTitle"];
|
|
15
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
19
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
|
+
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
16
21
|
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; }
|
|
17
22
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
23
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -23,7 +28,9 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
|
|
|
23
28
|
const DoughnutChart = _ref => {
|
|
24
29
|
let {
|
|
25
30
|
height = 300,
|
|
26
|
-
data
|
|
31
|
+
data,
|
|
32
|
+
showCenterText = false,
|
|
33
|
+
centerTextTitle
|
|
27
34
|
} = _ref,
|
|
28
35
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
29
36
|
const [legendContainerId] = (0, _react.useState)((0, _lodash.default)('legend-container-'));
|
|
@@ -72,21 +79,26 @@ const DoughnutChart = _ref => {
|
|
|
72
79
|
return color;
|
|
73
80
|
}
|
|
74
81
|
}
|
|
82
|
+
},
|
|
83
|
+
centerText: {
|
|
84
|
+
display: showCenterText,
|
|
85
|
+
title: centerTextTitle
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
};
|
|
78
|
-
}, [legendContainerId, theme.fontOnPrimary]);
|
|
89
|
+
}, [legendContainerId, theme.fontOnPrimary, showCenterText, centerTextTitle]);
|
|
79
90
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
80
91
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
81
92
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Doughnut, _objectSpread({
|
|
82
93
|
height: height,
|
|
83
94
|
data: data,
|
|
84
95
|
options: defaultOptions,
|
|
85
|
-
plugins: [_htmlLegendPlugin.default]
|
|
96
|
+
plugins: [_htmlLegendPlugin.default, _centerTextPlugin.default]
|
|
86
97
|
}, props))
|
|
87
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
98
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(LegendWrapper, {
|
|
88
99
|
id: legendContainerId
|
|
89
100
|
})]
|
|
90
101
|
});
|
|
91
102
|
};
|
|
103
|
+
const LegendWrapper = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .custom-legend-tooltip {\n position: relative;\n }\n\n .custom-legend-tooltip:hover::after {\n content: attr(data-tooltip);\n position: absolute;\n top: calc(1rem + var(--spacing-xs));\n left: 50%;\n transform: translateX(-50%);\n border: 1px solid var(--border-color);\n color: var(--font-on-background);\n background: var(--color-background2);\n box-shadow: var(--box-shadow);\n border-radius: calc(var(--border-radius) / 2);\n padding: var(--spacing-xs);\n font-size: var(--font-body1);\n font-weight: var(--font-normal);\n text-align: center;\n width: max-content;\n max-width: 50vw;\n }\n"])));
|
|
92
104
|
var _default = exports.default = DoughnutChart;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactChartjs = require("react-chartjs-2");
|
|
8
|
+
const centerTextPlugin = {
|
|
9
|
+
id: 'centerText',
|
|
10
|
+
beforeDraw: chart => {
|
|
11
|
+
const {
|
|
12
|
+
options,
|
|
13
|
+
data
|
|
14
|
+
} = chart.config;
|
|
15
|
+
const config = options.plugins.centerText;
|
|
16
|
+
if (!config || !config.display) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const {
|
|
20
|
+
ctx,
|
|
21
|
+
chartArea: {
|
|
22
|
+
top,
|
|
23
|
+
width,
|
|
24
|
+
height
|
|
25
|
+
}
|
|
26
|
+
} = chart;
|
|
27
|
+
ctx.save();
|
|
28
|
+
|
|
29
|
+
// calculate center position
|
|
30
|
+
const centerX = width / 2;
|
|
31
|
+
const centerY = height / 2 + top;
|
|
32
|
+
|
|
33
|
+
// font settings
|
|
34
|
+
const {
|
|
35
|
+
font,
|
|
36
|
+
color
|
|
37
|
+
} = _reactChartjs.defaults;
|
|
38
|
+
const {
|
|
39
|
+
family,
|
|
40
|
+
size,
|
|
41
|
+
lineHeight
|
|
42
|
+
} = font;
|
|
43
|
+
const offset = size * lineHeight / 2;
|
|
44
|
+
ctx.textAlign = 'center';
|
|
45
|
+
ctx.textBaseline = 'middle';
|
|
46
|
+
ctx.fillStyle = color;
|
|
47
|
+
const {
|
|
48
|
+
title
|
|
49
|
+
} = config;
|
|
50
|
+
if (title) {
|
|
51
|
+
ctx.font = "bold ".concat(size, "px ").concat(family);
|
|
52
|
+
ctx.fillText(title, centerX, centerY - offset);
|
|
53
|
+
}
|
|
54
|
+
const total = data.datasets[0].data.reduce((total, current) => {
|
|
55
|
+
return total + current;
|
|
56
|
+
}, 0);
|
|
57
|
+
ctx.font = "".concat(size, "px ").concat(family);
|
|
58
|
+
ctx.fillText(total.toLocaleString(), centerX, centerY + (title ? offset : 0));
|
|
59
|
+
ctx.restore();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var _default = exports.default = centerTextPlugin;
|
|
@@ -26,6 +26,12 @@ const htmlLegendPlugin = {
|
|
|
26
26
|
li.style.marginLeft = '16px';
|
|
27
27
|
li.style.marginTop = '16px';
|
|
28
28
|
li.style.color = _reactChartjs.defaults.color;
|
|
29
|
+
const [dataset] = chart.data.datasets;
|
|
30
|
+
const description = dataset.descriptions ? dataset.descriptions[item.index] : '';
|
|
31
|
+
if (description) {
|
|
32
|
+
li.setAttribute('data-tooltip', description);
|
|
33
|
+
li.classList.add('custom-legend-tooltip');
|
|
34
|
+
}
|
|
29
35
|
li.onclick = () => {
|
|
30
36
|
const {
|
|
31
37
|
type
|
|
@@ -22,7 +22,10 @@ const padEmptyChartBar = {
|
|
|
22
22
|
for (let index = validLabels.length; index < maxBarNumber; index += 1) {
|
|
23
23
|
this.length = this.length === -1 ? index : this.length;
|
|
24
24
|
data.labels[index] = null;
|
|
25
|
-
|
|
25
|
+
const [datasets] = data.datasets;
|
|
26
|
+
if (datasets) {
|
|
27
|
+
datasets.data[index] = 0;
|
|
28
|
+
}
|
|
26
29
|
}
|
|
27
30
|
},
|
|
28
31
|
// prevent padded empty chart bar to be drawn
|
package/package.json
CHANGED
package/select/Select.js
CHANGED
|
@@ -28,7 +28,7 @@ var _Footer = _interopRequireDefault(require("./subComponent/Footer"));
|
|
|
28
28
|
var _figure = require("../figure");
|
|
29
29
|
var _image = require("../image");
|
|
30
30
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
31
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
31
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
32
32
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
33
33
|
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
34
34
|
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; }
|
|
@@ -83,7 +83,11 @@ const Select = _ref => {
|
|
|
83
83
|
} = (0, _hooks.useCustomPopper)(comboboxElement, listBoxElement);
|
|
84
84
|
const newOptions = (0, _react.useMemo)(() => {
|
|
85
85
|
if (!options) return;
|
|
86
|
-
const newOptions =
|
|
86
|
+
const newOptions = options.map(item => {
|
|
87
|
+
return _objectSpread({
|
|
88
|
+
isDisable: false
|
|
89
|
+
}, item);
|
|
90
|
+
});
|
|
87
91
|
if (options.length > 0 && multiple && enableSelectAll) {
|
|
88
92
|
newOptions.unshift({
|
|
89
93
|
id: allOptionId,
|
|
@@ -92,6 +96,9 @@ const Select = _ref => {
|
|
|
92
96
|
}
|
|
93
97
|
return newOptions;
|
|
94
98
|
}, [options, multiple, enableSelectAll, allOptionId]);
|
|
99
|
+
const enabledOptions = (0, _react.useMemo)(() => {
|
|
100
|
+
return newOptions.filter(item => !item.isDisable);
|
|
101
|
+
}, [newOptions]);
|
|
95
102
|
|
|
96
103
|
// parse all value to string
|
|
97
104
|
// for subsequently determine whether it is a selected item
|
|
@@ -108,13 +115,13 @@ const Select = _ref => {
|
|
|
108
115
|
return '';
|
|
109
116
|
}, [selected]);
|
|
110
117
|
const selectedAllOptions = (0, _react.useMemo)(() => {
|
|
111
|
-
if (multiple && enableSelectAll && parsedSelected.length + 1 ===
|
|
118
|
+
if (multiple && enableSelectAll && parsedSelected.length + 1 === enabledOptions.length) {
|
|
112
119
|
const selectedAllOptions = [...parsedSelected];
|
|
113
120
|
selectedAllOptions.unshift(allOptionId);
|
|
114
121
|
return selectedAllOptions;
|
|
115
122
|
}
|
|
116
123
|
return parsedSelected;
|
|
117
|
-
}, [multiple, enableSelectAll,
|
|
124
|
+
}, [multiple, enableSelectAll, enabledOptions.length, parsedSelected, allOptionId]);
|
|
118
125
|
const showCheckbox = (0, _react.useMemo)(() => {
|
|
119
126
|
if (multiple && displayMode === 'text') {
|
|
120
127
|
return true;
|
|
@@ -175,18 +182,37 @@ const Select = _ref => {
|
|
|
175
182
|
const handleOnSelect = (0, _react.useCallback)((event, value) => {
|
|
176
183
|
event.stopPropagation();
|
|
177
184
|
if (disabled === true) return;
|
|
185
|
+
const targetOption = newOptions.find(_ref2 => {
|
|
186
|
+
let {
|
|
187
|
+
id,
|
|
188
|
+
child
|
|
189
|
+
} = _ref2;
|
|
190
|
+
return id === value || child && child.find(_ref3 => {
|
|
191
|
+
let {
|
|
192
|
+
id
|
|
193
|
+
} = _ref3;
|
|
194
|
+
return id === value;
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
const actualOpt = targetOption !== null && targetOption !== void 0 && targetOption.child ? targetOption.child.find(_ref4 => {
|
|
198
|
+
let {
|
|
199
|
+
id
|
|
200
|
+
} = _ref4;
|
|
201
|
+
return id === value;
|
|
202
|
+
}) : targetOption;
|
|
203
|
+
if (actualOpt !== null && actualOpt !== void 0 && actualOpt.isDisable) return;
|
|
178
204
|
|
|
179
205
|
// 選取選項
|
|
180
206
|
// 點選 all 全選
|
|
181
207
|
if (multiple) {
|
|
182
|
-
if (value.toString() === allOptionId && selectedAllOptions.length <
|
|
183
|
-
for (let index = 1; index <
|
|
184
|
-
onSelect(
|
|
208
|
+
if (value.toString() === allOptionId && selectedAllOptions.length < enabledOptions.length) {
|
|
209
|
+
for (let index = 1; index < enabledOptions.length; index += 1) {
|
|
210
|
+
onSelect(enabledOptions[index].id);
|
|
185
211
|
}
|
|
186
212
|
}
|
|
187
213
|
if (value.toString() !== allOptionId && !selectedAllOptions.includes(value.toString())) {
|
|
188
214
|
// 選取一個選項,變成全選
|
|
189
|
-
if (selectedAllOptions.length + 2 ===
|
|
215
|
+
if (selectedAllOptions.length + 2 === enabledOptions.length) {
|
|
190
216
|
onSelect(value);
|
|
191
217
|
} else {
|
|
192
218
|
// 選取特定選項
|
|
@@ -196,14 +222,14 @@ const Select = _ref => {
|
|
|
196
222
|
|
|
197
223
|
// 刪除選項
|
|
198
224
|
// 點選 all 刪除全選
|
|
199
|
-
if (value.toString() === allOptionId && selectedAllOptions.length ===
|
|
200
|
-
for (let index = 0; index <
|
|
201
|
-
onDeselect(
|
|
225
|
+
if (value.toString() === allOptionId && selectedAllOptions.length === enabledOptions.length) {
|
|
226
|
+
for (let index = 0; index < enabledOptions.length; index += 1) {
|
|
227
|
+
onDeselect(enabledOptions[index].id);
|
|
202
228
|
}
|
|
203
229
|
}
|
|
204
230
|
if (value.toString() !== allOptionId && selectedAllOptions.includes(value.toString())) {
|
|
205
231
|
// 原本是 all 全選後來刪除其中一個選項
|
|
206
|
-
if (selectedAllOptions.length ===
|
|
232
|
+
if (selectedAllOptions.length === enabledOptions.length) {
|
|
207
233
|
onDeselect(value);
|
|
208
234
|
} else {
|
|
209
235
|
// 刪除特定選項
|
|
@@ -217,7 +243,7 @@ const Select = _ref => {
|
|
|
217
243
|
}
|
|
218
244
|
comboboxElement.focus();
|
|
219
245
|
setSearch('');
|
|
220
|
-
}, [disabled, onSelect, comboboxElement, selectedAllOptions, onDeselect, newOptions, allOptionId, multiple]);
|
|
246
|
+
}, [disabled, onSelect, comboboxElement, selectedAllOptions, onDeselect, newOptions, allOptionId, multiple, enabledOptions]);
|
|
221
247
|
const handleOnDeselect = (0, _react.useCallback)((event, value) => {
|
|
222
248
|
event.stopPropagation();
|
|
223
249
|
if (disabled === true) return;
|
|
@@ -287,32 +313,41 @@ const Select = _ref => {
|
|
|
287
313
|
id: option.text,
|
|
288
314
|
children: option.text
|
|
289
315
|
}), option.child.map(option => {
|
|
290
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
316
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Option.default, {
|
|
291
317
|
role: "option",
|
|
292
|
-
tabIndex:
|
|
318
|
+
tabIndex: option.isDisable ? '-1' : '0',
|
|
293
319
|
id: option.id,
|
|
294
|
-
onClick: event => handleOnSelect(event, option.id),
|
|
320
|
+
onClick: event => !option.isDisable && handleOnSelect(event, option.id),
|
|
295
321
|
focus: focusedOption && focusedOption.id === option.id.toString(),
|
|
296
322
|
selected: option.selected,
|
|
297
323
|
"aria-selected": option.selected,
|
|
298
|
-
|
|
324
|
+
"aria-disabled": option.isDisable,
|
|
325
|
+
disabled: option.isDisable,
|
|
326
|
+
children: [option.text, option.suffix && /*#__PURE__*/(0, _jsxRuntime.jsxs)(OptionBadge, {
|
|
327
|
+
children: ["\xA0", option.suffix]
|
|
328
|
+
})]
|
|
299
329
|
}, option.id);
|
|
300
330
|
})]
|
|
301
331
|
}, option.text);
|
|
302
332
|
}
|
|
303
333
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Option.default, {
|
|
304
334
|
role: "option",
|
|
305
|
-
tabIndex:
|
|
335
|
+
tabIndex: option.isDisable ? '-1' : '0',
|
|
306
336
|
id: option.id,
|
|
307
|
-
onClick: event => handleOnSelect(event, option.id),
|
|
337
|
+
onClick: event => !option.isDisable && handleOnSelect(event, option.id),
|
|
308
338
|
focus: focusedOption && focusedOption.id === option.id.toString(),
|
|
309
339
|
selected: option.selected,
|
|
310
340
|
"aria-selected": option.selected,
|
|
341
|
+
"aria-disabled": option.isDisable,
|
|
342
|
+
disabled: option.isDisable,
|
|
311
343
|
children: [showCheckbox && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Checkbox.default, {
|
|
312
|
-
selected: option.selected
|
|
344
|
+
selected: option.selected,
|
|
345
|
+
disabled: option.isDisable
|
|
313
346
|
}), option.icon && /*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {
|
|
314
347
|
src: option.icon
|
|
315
|
-
}), option.text
|
|
348
|
+
}), option.text, option.suffix && /*#__PURE__*/(0, _jsxRuntime.jsxs)(OptionBadge, {
|
|
349
|
+
children: ["\xA0", option.suffix]
|
|
350
|
+
})]
|
|
316
351
|
}, option.id);
|
|
317
352
|
});
|
|
318
353
|
}, [optionList, focusedOption, handleOnSelect, showCheckbox]);
|
|
@@ -337,6 +372,7 @@ const Select = _ref => {
|
|
|
337
372
|
if (!display) {
|
|
338
373
|
handleToggle();
|
|
339
374
|
} else if (focusedOption) {
|
|
375
|
+
if (focusedOption.getAttribute('aria-disabled') === 'true') return;
|
|
340
376
|
handleOnSelect(event, focusedOption.id);
|
|
341
377
|
}
|
|
342
378
|
break;
|
|
@@ -350,7 +386,10 @@ const Select = _ref => {
|
|
|
350
386
|
if (!focusedOption) {
|
|
351
387
|
return;
|
|
352
388
|
}
|
|
353
|
-
|
|
389
|
+
let previousItem = findPreviousItem(focusedOption);
|
|
390
|
+
while (previousItem && previousItem.getAttribute('aria-disabled') === 'true') {
|
|
391
|
+
previousItem = findPreviousItem(previousItem);
|
|
392
|
+
}
|
|
354
393
|
if (previousItem) {
|
|
355
394
|
handleFocusItem(previousItem);
|
|
356
395
|
}
|
|
@@ -361,7 +400,10 @@ const Select = _ref => {
|
|
|
361
400
|
if (!focusedOption) {
|
|
362
401
|
return;
|
|
363
402
|
}
|
|
364
|
-
|
|
403
|
+
let nextItem = findNextItem(focusedOption);
|
|
404
|
+
while (nextItem && nextItem.getAttribute('aria-disabled') === 'true') {
|
|
405
|
+
nextItem = findNextItem(nextItem);
|
|
406
|
+
}
|
|
365
407
|
if (nextItem) {
|
|
366
408
|
handleFocusItem(nextItem);
|
|
367
409
|
}
|
|
@@ -593,10 +635,10 @@ const Select = _ref => {
|
|
|
593
635
|
})
|
|
594
636
|
});
|
|
595
637
|
};
|
|
596
|
-
const Icon =
|
|
638
|
+
const Icon = _ref5 => {
|
|
597
639
|
let {
|
|
598
640
|
src
|
|
599
|
-
} =
|
|
641
|
+
} = _ref5;
|
|
600
642
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
601
643
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_figure.IconFigure, {
|
|
602
644
|
size: "medium",
|
|
@@ -609,50 +651,50 @@ const Icon = _ref2 => {
|
|
|
609
651
|
}), "\xA0"]
|
|
610
652
|
});
|
|
611
653
|
};
|
|
612
|
-
const Combobox = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n min-height: 36px;\n cursor: pointer;\n position: relative;\n background: transparent;\n color: var(--font-on-background);\n font-size: var(--font-body1);\n border: var(--border-width) solid var(--border-color);\n border-radius: var(--border-radius-l);\n padding: 0 calc(var(--spacing-s) * 2 + 8px) 0 var(--spacing-s);\n\n &:focus {\n ", ";\n }\n\n ", "\n\n ", "\n\n ", "\n ", "\n \n ", ";\n\n ", "\n\n ", "\n\n ", "\n"])),
|
|
654
|
+
const Combobox = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n min-height: 36px;\n cursor: pointer;\n position: relative;\n background: transparent;\n color: var(--font-on-background);\n font-size: var(--font-body1);\n border: var(--border-width) solid var(--border-color);\n border-radius: var(--border-radius-l);\n padding: 0 calc(var(--spacing-s) * 2 + 8px) 0 var(--spacing-s);\n\n &:focus {\n ", ";\n }\n\n ", "\n\n ", "\n\n ", "\n ", "\n \n ", ";\n\n ", "\n\n ", "\n\n ", "\n"])), _ref6 => {
|
|
613
655
|
let {
|
|
614
656
|
disabled
|
|
615
|
-
} =
|
|
657
|
+
} = _ref6;
|
|
616
658
|
return !disabled && "\n border-color: var(--color-primary);\n outline: none;\n ";
|
|
617
|
-
},
|
|
659
|
+
}, _ref7 => {
|
|
618
660
|
let {
|
|
619
661
|
flexGrow
|
|
620
|
-
} =
|
|
662
|
+
} = _ref7;
|
|
621
663
|
return !flexGrow && 'min-width: 160px;';
|
|
622
|
-
},
|
|
664
|
+
}, _ref8 => {
|
|
623
665
|
let {
|
|
624
666
|
$display
|
|
625
|
-
} =
|
|
667
|
+
} = _ref8;
|
|
626
668
|
return $display && "\n border-color: var(--color-primary);\n outline: none;\n ";
|
|
627
|
-
},
|
|
669
|
+
}, _ref9 => {
|
|
628
670
|
let {
|
|
629
671
|
disabled
|
|
630
|
-
} =
|
|
672
|
+
} = _ref9;
|
|
631
673
|
return disabled && 'cursor: not-allowed;opacity: 0.5;';
|
|
632
|
-
},
|
|
674
|
+
}, _ref10 => {
|
|
633
675
|
let {
|
|
634
676
|
placeholder
|
|
635
|
-
} =
|
|
677
|
+
} = _ref10;
|
|
636
678
|
return placeholder && 'color: var(--font-on-mute);';
|
|
637
|
-
},
|
|
679
|
+
}, _ref11 => {
|
|
638
680
|
let {
|
|
639
681
|
fullWidth
|
|
640
|
-
} =
|
|
682
|
+
} = _ref11;
|
|
641
683
|
return fullWidth ? 'width: 100%' : 'max-width: 320px';
|
|
642
|
-
},
|
|
684
|
+
}, _ref12 => {
|
|
643
685
|
let {
|
|
644
686
|
large
|
|
645
|
-
} =
|
|
687
|
+
} = _ref12;
|
|
646
688
|
return large && "\n height: 40px;\n padding: 12px calc(var(--spacing-s) * 2 + 8px) 12px var(--spacing-s);\n ";
|
|
647
|
-
},
|
|
689
|
+
}, _ref13 => {
|
|
648
690
|
let {
|
|
649
691
|
$fill
|
|
650
|
-
} =
|
|
692
|
+
} = _ref13;
|
|
651
693
|
return $fill && "\n background: var(--color-background2);\n border-color: transparent;\n ";
|
|
652
|
-
},
|
|
694
|
+
}, _ref14 => {
|
|
653
695
|
let {
|
|
654
696
|
fillReverse
|
|
655
|
-
} =
|
|
697
|
+
} = _ref14;
|
|
656
698
|
return fillReverse && "\n background: var(--color-background1);\n border-color: transparent;\n ";
|
|
657
699
|
});
|
|
658
700
|
Combobox.displayName = 'Combobox';
|
|
@@ -662,4 +704,5 @@ const ExpandArrow = (0, _styledComponents.default)(_ti.TiArrowSortedDown)(_templ
|
|
|
662
704
|
ExpandArrow.displayName = 'ExpandArrow';
|
|
663
705
|
const Message = _styledComponents.default.p(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n margin: 0;\n padding: 12px var(--spacing-s);\n"])));
|
|
664
706
|
Message.displayName = 'Message';
|
|
707
|
+
const OptionBadge = _styledComponents.default.span(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n color: var(--color-danger);\n font-style: italic;\n"])));
|
|
665
708
|
var _default = exports.default = Select;
|
|
@@ -5,16 +5,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
|
-
var _templateObject, _templateObject2;
|
|
8
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
9
9
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
11
|
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
12
|
-
const Option = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n max-width: 100%;\n word-break: break-all;\n padding: 12px var(--spacing-s);\n background: var(--color-background1);\n transition: background 0.3s;\n\n &:hover {\n background: var(--color-hover);\n }\n\n ", "\n"])), _ref => {
|
|
12
|
+
const Option = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n max-width: 100%;\n word-break: break-all;\n padding: 12px var(--spacing-s);\n background: var(--color-background1);\n transition: background 0.3s;\n\n &:hover {\n background: var(--color-hover);\n }\n\n ", "\n\n ", "\n"])), _ref => {
|
|
13
13
|
let {
|
|
14
14
|
selected,
|
|
15
15
|
focus
|
|
16
16
|
} = _ref;
|
|
17
17
|
return (selected || focus) && (0, _styledComponents.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n background: var(--color-hover);\n "])));
|
|
18
|
+
}, _ref2 => {
|
|
19
|
+
let {
|
|
20
|
+
disabled
|
|
21
|
+
} = _ref2;
|
|
22
|
+
return disabled && (0, _styledComponents.css)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n cursor: not-allowed;\n opacity: 0.5;\n pointer-events: none;\n "])));
|
|
18
23
|
});
|
|
19
24
|
Option.displayName = 'Option';
|
|
20
25
|
var _default = exports.default = Option;
|
|
@@ -4,9 +4,51 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
7
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
-
var
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
var _templateObject, _templateObject2;
|
|
9
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
12
|
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
11
|
-
const SelectedMultipleText =
|
|
13
|
+
const SelectedMultipleText = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
children
|
|
16
|
+
} = _ref;
|
|
17
|
+
const textRef = (0, _react.useRef)(null);
|
|
18
|
+
const [position, setPosition] = (0, _react.useState)({
|
|
19
|
+
x: 0,
|
|
20
|
+
y: 0
|
|
21
|
+
});
|
|
22
|
+
const [show, setShow] = (0, _react.useState)(false);
|
|
23
|
+
const handleMouseEnter = () => {
|
|
24
|
+
const element = textRef.current;
|
|
25
|
+
// show tooltip on content width exceeds container width only
|
|
26
|
+
if (element.scrollWidth > element.clientWidth) {
|
|
27
|
+
const rect = element.getBoundingClientRect();
|
|
28
|
+
setPosition({
|
|
29
|
+
x: rect.left,
|
|
30
|
+
y: rect.bottom + 8
|
|
31
|
+
});
|
|
32
|
+
setShow(true);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
36
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Text, {
|
|
37
|
+
ref: textRef,
|
|
38
|
+
onMouseEnter: handleMouseEnter,
|
|
39
|
+
onMouseLeave: () => {
|
|
40
|
+
setShow(false);
|
|
41
|
+
},
|
|
42
|
+
children: children
|
|
43
|
+
}), show && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tooltip, {
|
|
44
|
+
style: {
|
|
45
|
+
left: position.x,
|
|
46
|
+
top: position.y
|
|
47
|
+
},
|
|
48
|
+
children: children
|
|
49
|
+
})]
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const Text = _styledComponents.default.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n"])));
|
|
53
|
+
const Tooltip = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: fixed;\n border: 1px solid var(--border-color);\n color: var(--font-on-background);\n background: var(--color-background2);\n box-shadow: var(--box-shadow);\n border-radius: calc(var(--border-radius) / 2);\n padding: var(--spacing-xs);\n font-size: var(--font-body1);\n font-weight: var(--font-normal);\n z-index: 90;\n width: max-content;\n max-width: 50vw;\n"])));
|
|
12
54
|
var _default = exports.default = SelectedMultipleText;
|