@lumx/react 4.11.0-next.7 → 4.11.0-next.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/index.d.ts +275 -272
- package/index.js +712 -658
- package/index.js.map +1 -1
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ColorVariant as ColorVariant$1, Size as Size$1, VISUALLY_HIDDEN, Theme as Theme$1, AspectRatio as AspectRatio$1, DOCUMENT, IS_BROWSER as IS_BROWSER$1, Emphasis as Emphasis$1, WINDOW, DIALOG_TRANSITION_DURATION, Orientation as Orientation$1, NOTIFICATION_TRANSITION_DURATION, Kind as Kind$1, Alignment as Alignment$1, ColorPalette as ColorPalette$1 } from '@lumx/core/js/constants';
|
|
2
2
|
export * from '@lumx/core/js/constants';
|
|
3
3
|
export * from '@lumx/core/js/types';
|
|
4
4
|
import * as React from 'react';
|
|
@@ -73,597 +73,247 @@ function useId() {
|
|
|
73
73
|
const forwardRef = React__default.forwardRef;
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
76
|
+
* Animation duration constants. Take into consideration that if you change one of these variables,
|
|
77
|
+
* you need to update their scss counterpart as well
|
|
77
78
|
*/
|
|
78
|
-
const CONFIG$1 = {
|
|
79
|
-
[Kind$1.error]: {
|
|
80
|
-
color: ColorPalette$1.red,
|
|
81
|
-
icon: mdiAlert
|
|
82
|
-
},
|
|
83
|
-
[Kind$1.info]: {
|
|
84
|
-
color: ColorPalette$1.blue,
|
|
85
|
-
icon: mdiInformation
|
|
86
|
-
},
|
|
87
|
-
[Kind$1.success]: {
|
|
88
|
-
color: ColorPalette$1.green,
|
|
89
|
-
icon: mdiCheckCircle
|
|
90
|
-
},
|
|
91
|
-
[Kind$1.warning]: {
|
|
92
|
-
color: ColorPalette$1.yellow,
|
|
93
|
-
icon: mdiAlertCircle
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
79
|
|
|
97
80
|
/**
|
|
98
|
-
*
|
|
81
|
+
* Delay on hover after which we open or close the tooltip.
|
|
82
|
+
* Only applies to devices supporting pointer hover.
|
|
99
83
|
*/
|
|
100
|
-
const
|
|
84
|
+
const TOOLTIP_HOVER_DELAY = {
|
|
85
|
+
open: 500,
|
|
86
|
+
close: 500
|
|
87
|
+
};
|
|
101
88
|
|
|
102
89
|
/**
|
|
103
|
-
*
|
|
90
|
+
* Delay on long press after which we open or close the tooltip.
|
|
91
|
+
* Only applies to devices not supporting pointer hover.
|
|
104
92
|
*/
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
93
|
+
const TOOLTIP_LONG_PRESS_DELAY = {
|
|
94
|
+
open: 250,
|
|
95
|
+
close: 3000
|
|
96
|
+
};
|
|
109
97
|
|
|
110
98
|
/**
|
|
111
|
-
*
|
|
99
|
+
* Alignments.
|
|
112
100
|
*/
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
101
|
+
const Alignment = {
|
|
102
|
+
left: 'left'};
|
|
103
|
+
const Theme = {
|
|
104
|
+
light: 'light',
|
|
105
|
+
dark: 'dark'
|
|
106
|
+
};
|
|
107
|
+
const Size = {
|
|
108
|
+
xxs: 'xxs',
|
|
109
|
+
xs: 'xs',
|
|
110
|
+
s: 's',
|
|
111
|
+
m: 'm',
|
|
112
|
+
l: 'l',
|
|
113
|
+
xl: 'xl',
|
|
114
|
+
xxl: 'xxl',
|
|
115
|
+
tiny: 'tiny',
|
|
116
|
+
regular: 'regular',
|
|
117
|
+
medium: 'medium',
|
|
118
|
+
big: 'big',
|
|
119
|
+
huge: 'huge'
|
|
120
|
+
};
|
|
121
|
+
const Orientation = {
|
|
122
|
+
horizontal: 'horizontal',
|
|
123
|
+
vertical: 'vertical'
|
|
124
|
+
};
|
|
125
|
+
const Emphasis = {
|
|
126
|
+
low: 'low',
|
|
127
|
+
medium: 'medium',
|
|
128
|
+
high: 'high'
|
|
116
129
|
};
|
|
117
|
-
|
|
118
130
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* An alert dialog is a modal dialog that interrupts the user's workflow to
|
|
122
|
-
* communicate an important message and acquire a response.
|
|
123
|
-
*
|
|
124
|
-
* It should not have a complex content.
|
|
125
|
-
* Children of this component should only be strings, paragraphs or links.
|
|
131
|
+
* List of typographies that can't be customized.
|
|
126
132
|
*/
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
...forwardedProps
|
|
139
|
-
} = props;
|
|
140
|
-
const cancelButtonRef = React__default.useRef(null);
|
|
141
|
-
const confirmationButtonRef = React__default.useRef(null);
|
|
142
|
-
const {
|
|
143
|
-
color,
|
|
144
|
-
icon
|
|
145
|
-
} = CONFIG$1[kind] || {};
|
|
146
|
-
|
|
147
|
-
// Define a unique ID to target title and description for aria attributes.
|
|
148
|
-
const generatedId = useId();
|
|
149
|
-
const uniqueId = id || generatedId;
|
|
150
|
-
const titleId = `${uniqueId}-title`;
|
|
151
|
-
const descriptionId = `${uniqueId}-description`;
|
|
152
|
-
|
|
153
|
-
// If content is a string, set in a paragraph.
|
|
154
|
-
const DescriptionElement = typeof children === 'string' ? 'p' : 'div';
|
|
155
|
-
const {
|
|
156
|
-
label: confirmLabel,
|
|
157
|
-
onClick: confirmOnClick,
|
|
158
|
-
...forwardedConfirmProps
|
|
159
|
-
} = confirmProps;
|
|
160
|
-
const {
|
|
161
|
-
label: cancelLabel,
|
|
162
|
-
onClick: cancelOnClick,
|
|
163
|
-
...forwardedCancelProps
|
|
164
|
-
} = cancelProps || {};
|
|
165
|
-
return /*#__PURE__*/jsxs(Dialog, {
|
|
166
|
-
ref: ref,
|
|
167
|
-
focusElement: cancelProps ? cancelButtonRef : confirmationButtonRef,
|
|
168
|
-
size: size,
|
|
169
|
-
dialogProps: {
|
|
170
|
-
id: uniqueId,
|
|
171
|
-
role: 'alertdialog',
|
|
172
|
-
'aria-labelledby': titleId,
|
|
173
|
-
'aria-describedby': descriptionId,
|
|
174
|
-
...dialogProps
|
|
175
|
-
},
|
|
176
|
-
className: classNames.join(className, block$19({
|
|
177
|
-
[`kind-${kind}`]: Boolean(kind)
|
|
178
|
-
})),
|
|
179
|
-
...forwardedProps,
|
|
180
|
-
children: [/*#__PURE__*/jsx("header", {
|
|
181
|
-
children: /*#__PURE__*/jsx(Toolbar, {
|
|
182
|
-
className: "lumx-spacing-margin-horizontal",
|
|
183
|
-
before: /*#__PURE__*/jsx(Icon, {
|
|
184
|
-
icon: icon,
|
|
185
|
-
size: Size$1.s,
|
|
186
|
-
color: color
|
|
187
|
-
}),
|
|
188
|
-
label: /*#__PURE__*/jsx("h2", {
|
|
189
|
-
id: titleId,
|
|
190
|
-
className: "lumx-typography-title",
|
|
191
|
-
children: title
|
|
192
|
-
})
|
|
193
|
-
})
|
|
194
|
-
}), children && /*#__PURE__*/jsx(DescriptionElement, {
|
|
195
|
-
id: descriptionId,
|
|
196
|
-
className: "lumx-typography-body2 lumx-spacing-padding-vertical-big lumx-spacing-padding-horizontal-huge",
|
|
197
|
-
children: children
|
|
198
|
-
}), /*#__PURE__*/jsx("footer", {
|
|
199
|
-
children: /*#__PURE__*/jsx(Toolbar, {
|
|
200
|
-
className: "lumx-spacing-margin-horizontal",
|
|
201
|
-
after: /*#__PURE__*/jsxs(Fragment, {
|
|
202
|
-
children: [cancelProps && /*#__PURE__*/jsx(Button, {
|
|
203
|
-
...forwardedCancelProps,
|
|
204
|
-
ref: cancelButtonRef,
|
|
205
|
-
emphasis: Emphasis$1.medium,
|
|
206
|
-
onClick: cancelOnClick,
|
|
207
|
-
children: cancelLabel
|
|
208
|
-
}), /*#__PURE__*/jsx(Button, {
|
|
209
|
-
...forwardedConfirmProps,
|
|
210
|
-
ref: confirmationButtonRef,
|
|
211
|
-
color: color,
|
|
212
|
-
className: "lumx-spacing-margin-left-regular",
|
|
213
|
-
onClick: confirmOnClick,
|
|
214
|
-
children: confirmLabel
|
|
215
|
-
})]
|
|
216
|
-
})
|
|
217
|
-
})
|
|
218
|
-
})]
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
AlertDialog.displayName = COMPONENT_NAME$1x;
|
|
222
|
-
AlertDialog.className = CLASSNAME$1v;
|
|
223
|
-
AlertDialog.defaultProps = DEFAULT_PROPS$1g;
|
|
224
|
-
|
|
133
|
+
const TypographyInterface = {
|
|
134
|
+
overline: 'overline',
|
|
135
|
+
caption: 'caption',
|
|
136
|
+
body1: 'body1',
|
|
137
|
+
body2: 'body2',
|
|
138
|
+
subtitle1: 'subtitle1',
|
|
139
|
+
subtitle2: 'subtitle2',
|
|
140
|
+
title: 'title',
|
|
141
|
+
headline: 'headline',
|
|
142
|
+
display1: 'display1'
|
|
143
|
+
};
|
|
225
144
|
/**
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
* @param element Element to focus.
|
|
229
|
-
* @param shouldFocus Boolean flag to trigger the focus
|
|
145
|
+
* List of all typographies.
|
|
230
146
|
*/
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
useEffect(() => {
|
|
234
|
-
if (shouldFocus && wasFocus !== shouldFocus && element) {
|
|
235
|
-
element.focus();
|
|
236
|
-
setWasFocus(shouldFocus);
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
240
|
-
[element, shouldFocus]);
|
|
241
|
-
}
|
|
242
|
-
|
|
147
|
+
const Typography = {
|
|
148
|
+
...TypographyInterface};
|
|
243
149
|
/**
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
* @param refs React references to merge.
|
|
247
|
-
* @return the merged ref.
|
|
150
|
+
* All available aspect ratios.
|
|
248
151
|
*/
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
|
|
152
|
+
const AspectRatio = {
|
|
153
|
+
/** Intrinsic content ratio. */
|
|
154
|
+
original: 'original',
|
|
155
|
+
/** Ratio 3:2 */
|
|
156
|
+
horizontal: 'horizontal',
|
|
157
|
+
/** Ratio 1:1 */
|
|
158
|
+
square: 'square',
|
|
159
|
+
/** Ratio constrained by the parent. */
|
|
160
|
+
free: 'free'
|
|
161
|
+
};
|
|
260
162
|
/**
|
|
261
|
-
*
|
|
163
|
+
* Semantic info about the purpose of the component
|
|
262
164
|
*/
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
165
|
+
const Kind = {
|
|
166
|
+
info: 'info',
|
|
167
|
+
success: 'success',
|
|
168
|
+
warning: 'warning',
|
|
169
|
+
error: 'error'
|
|
267
170
|
};
|
|
268
|
-
|
|
269
|
-
const ThemeContext = /*#__PURE__*/React__default.createContext(undefined);
|
|
270
|
-
|
|
271
|
-
/** Provide a theme context to all children. */
|
|
272
|
-
const ThemeProvider = ThemeContext.Provider;
|
|
273
|
-
|
|
274
|
-
/** Get the theme in the current context. */
|
|
275
|
-
function useTheme() {
|
|
276
|
-
return React__default.useContext(ThemeContext);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
171
|
/**
|
|
280
|
-
*
|
|
281
|
-
* (handles `disabled`, `isDisabled` and `aria-disabled`)
|
|
282
|
-
*
|
|
283
|
-
* @params component props
|
|
172
|
+
* See SCSS variable $lumx-color-palette
|
|
284
173
|
*/
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
} = props;
|
|
294
|
-
const disabledStateContext = useDisabledStateContext();
|
|
295
|
-
const disabledStateProps = getDisabledState$1(disabledStateContext, {
|
|
296
|
-
disabled,
|
|
297
|
-
isDisabled,
|
|
298
|
-
'aria-disabled': ariaDisabled
|
|
299
|
-
});
|
|
300
|
-
const isAnyDisabled = disabledStateProps['aria-disabled'] || disabledStateProps.disabled || undefined;
|
|
301
|
-
if (!isAnyDisabled) {
|
|
302
|
-
otherProps.onClick = onClick;
|
|
303
|
-
otherProps.onChange = onChange;
|
|
304
|
-
}
|
|
305
|
-
return {
|
|
306
|
-
disabledStateProps,
|
|
307
|
-
otherProps: otherProps,
|
|
308
|
-
isAnyDisabled
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
|
|
174
|
+
const ColorPalette = {
|
|
175
|
+
primary: 'primary',
|
|
176
|
+
blue: 'blue',
|
|
177
|
+
dark: 'dark',
|
|
178
|
+
green: 'green',
|
|
179
|
+
yellow: 'yellow',
|
|
180
|
+
red: 'red',
|
|
181
|
+
light: 'light'};
|
|
312
182
|
/**
|
|
313
|
-
*
|
|
183
|
+
* See SCSS variable $lumx-color-variants
|
|
314
184
|
*/
|
|
315
|
-
const
|
|
185
|
+
const ColorVariant = {
|
|
186
|
+
N: 'N'
|
|
187
|
+
};
|
|
316
188
|
|
|
317
|
-
/**
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
189
|
+
/** ColorPalette with all possible color variant combination */
|
|
190
|
+
|
|
191
|
+
({
|
|
192
|
+
[Size.xxs]: 14,
|
|
193
|
+
[Size.xs]: 20,
|
|
194
|
+
[Size.s]: 24,
|
|
195
|
+
[Size.m]: 36,
|
|
196
|
+
[Size.l]: 64,
|
|
197
|
+
[Size.xl]: 128,
|
|
198
|
+
[Size.xxl]: 256
|
|
199
|
+
});
|
|
321
200
|
|
|
322
201
|
/**
|
|
323
|
-
*
|
|
202
|
+
* Check if we are running in a true browser (not SSR and not jsdom test environment).
|
|
324
203
|
*/
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
};
|
|
204
|
+
const IS_BROWSER = typeof window !== 'undefined' && !window.navigator.userAgent.includes('jsdom');
|
|
205
|
+
|
|
206
|
+
function getDefaultExportFromCjs (x) {
|
|
207
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
var classnames$1 = {exports: {}};
|
|
211
|
+
|
|
212
|
+
/*!
|
|
213
|
+
Copyright (c) 2018 Jed Watson.
|
|
214
|
+
Licensed under the MIT License (MIT), see
|
|
215
|
+
http://jedwatson.github.io/classnames
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
var hasRequiredClassnames;
|
|
219
|
+
|
|
220
|
+
function requireClassnames () {
|
|
221
|
+
if (hasRequiredClassnames) return classnames$1.exports;
|
|
222
|
+
hasRequiredClassnames = 1;
|
|
223
|
+
(function (module) {
|
|
224
|
+
/* global define */
|
|
225
|
+
|
|
226
|
+
(function () {
|
|
227
|
+
|
|
228
|
+
var hasOwn = {}.hasOwnProperty;
|
|
229
|
+
|
|
230
|
+
function classNames() {
|
|
231
|
+
var classes = [];
|
|
232
|
+
|
|
233
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
234
|
+
var arg = arguments[i];
|
|
235
|
+
if (!arg) continue;
|
|
236
|
+
|
|
237
|
+
var argType = typeof arg;
|
|
238
|
+
|
|
239
|
+
if (argType === 'string' || argType === 'number') {
|
|
240
|
+
classes.push(arg);
|
|
241
|
+
} else if (Array.isArray(arg)) {
|
|
242
|
+
if (arg.length) {
|
|
243
|
+
var inner = classNames.apply(null, arg);
|
|
244
|
+
if (inner) {
|
|
245
|
+
classes.push(inner);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
} else if (argType === 'object') {
|
|
249
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
250
|
+
classes.push(arg.toString());
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
for (var key in arg) {
|
|
255
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
256
|
+
classes.push(key);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return classes.join(' ');
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (module.exports) {
|
|
266
|
+
classNames.default = classNames;
|
|
267
|
+
module.exports = classNames;
|
|
268
|
+
} else {
|
|
269
|
+
window.classNames = classNames;
|
|
270
|
+
}
|
|
271
|
+
}());
|
|
272
|
+
} (classnames$1));
|
|
273
|
+
return classnames$1.exports;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
var classnamesExports = requireClassnames();
|
|
277
|
+
var classnames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
|
|
332
278
|
|
|
333
279
|
/**
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
* @param props Component props.
|
|
337
|
-
* @param ref Component ref.
|
|
338
|
-
* @return React element.
|
|
280
|
+
* Modifier
|
|
281
|
+
* @example { 'is-disabled': true, 'is-selected': false }
|
|
339
282
|
*/
|
|
340
|
-
const Autocomplete = forwardRef((props, ref) => {
|
|
341
|
-
const defaultTheme = useTheme();
|
|
342
|
-
const {
|
|
343
|
-
disabledStateProps,
|
|
344
|
-
otherProps
|
|
345
|
-
} = useDisableStateProps(props);
|
|
346
|
-
const {
|
|
347
|
-
anchorToInput = DEFAULT_PROPS$1f.anchorToInput,
|
|
348
|
-
children,
|
|
349
|
-
chips,
|
|
350
|
-
className,
|
|
351
|
-
closeOnClick = DEFAULT_PROPS$1f.closeOnClick,
|
|
352
|
-
closeOnClickAway = DEFAULT_PROPS$1f.closeOnClickAway,
|
|
353
|
-
closeOnEscape = DEFAULT_PROPS$1f.closeOnEscape,
|
|
354
|
-
error,
|
|
355
|
-
fitToAnchorWidth,
|
|
356
|
-
hasError,
|
|
357
|
-
helper,
|
|
358
|
-
icon,
|
|
359
|
-
inputRef,
|
|
360
|
-
clearButtonProps,
|
|
361
|
-
isRequired,
|
|
362
|
-
isOpen,
|
|
363
|
-
isValid,
|
|
364
|
-
label,
|
|
365
|
-
name,
|
|
366
|
-
offset,
|
|
367
|
-
onBlur,
|
|
368
|
-
onChange,
|
|
369
|
-
onClose,
|
|
370
|
-
onFocus,
|
|
371
|
-
onInfiniteScroll,
|
|
372
|
-
placeholder,
|
|
373
|
-
placement,
|
|
374
|
-
shouldFocusOnClose = DEFAULT_PROPS$1f.shouldFocusOnClose,
|
|
375
|
-
theme = defaultTheme,
|
|
376
|
-
value,
|
|
377
|
-
textFieldProps = {},
|
|
378
|
-
focusAnchorOnClose,
|
|
379
|
-
...forwardedProps
|
|
380
|
-
} = otherProps;
|
|
381
|
-
const inputAnchorRef = useRef(null);
|
|
382
|
-
const textFieldRef = useRef(null);
|
|
383
|
-
useFocus(inputAnchorRef.current, !isOpen && shouldFocusOnClose);
|
|
384
|
-
return /*#__PURE__*/jsxs("div", {
|
|
385
|
-
ref: ref,
|
|
386
|
-
...forwardedProps,
|
|
387
|
-
className: classNames.join(className, CLASSNAME$1u),
|
|
388
|
-
children: [/*#__PURE__*/jsx(TextField, {
|
|
389
|
-
...textFieldProps,
|
|
390
|
-
chips: chips,
|
|
391
|
-
error: error,
|
|
392
|
-
hasError: hasError,
|
|
393
|
-
helper: helper,
|
|
394
|
-
icon: icon,
|
|
395
|
-
inputRef: mergeRefs(inputAnchorRef, inputRef),
|
|
396
|
-
clearButtonProps: clearButtonProps,
|
|
397
|
-
...disabledStateProps,
|
|
398
|
-
isRequired: isRequired,
|
|
399
|
-
isValid: isValid,
|
|
400
|
-
label: label,
|
|
401
|
-
name: name,
|
|
402
|
-
onBlur: onBlur,
|
|
403
|
-
onChange: onChange,
|
|
404
|
-
onFocus: onFocus,
|
|
405
|
-
placeholder: placeholder,
|
|
406
|
-
textFieldRef: textFieldRef,
|
|
407
|
-
theme: theme,
|
|
408
|
-
value: value
|
|
409
|
-
}), /*#__PURE__*/jsx(Dropdown, {
|
|
410
|
-
anchorRef: anchorToInput ? inputAnchorRef : textFieldRef,
|
|
411
|
-
closeOnClick: closeOnClick,
|
|
412
|
-
closeOnClickAway: closeOnClickAway,
|
|
413
|
-
closeOnEscape: closeOnEscape,
|
|
414
|
-
focusAnchorOnClose: focusAnchorOnClose,
|
|
415
|
-
fitToAnchorWidth: fitToAnchorWidth,
|
|
416
|
-
isOpen: isOpen,
|
|
417
|
-
offset: offset,
|
|
418
|
-
onClose: onClose,
|
|
419
|
-
onInfiniteScroll: onInfiniteScroll,
|
|
420
|
-
placement: placement,
|
|
421
|
-
shouldFocusOnOpen: false,
|
|
422
|
-
theme: theme,
|
|
423
|
-
children: children
|
|
424
|
-
})]
|
|
425
|
-
});
|
|
426
|
-
});
|
|
427
|
-
Autocomplete.displayName = COMPONENT_NAME$1w;
|
|
428
|
-
Autocomplete.className = CLASSNAME$1u;
|
|
429
|
-
Autocomplete.defaultProps = DEFAULT_PROPS$1f;
|
|
430
283
|
|
|
431
284
|
/**
|
|
432
|
-
*
|
|
285
|
+
* Generates BEM modifier class names.
|
|
286
|
+
*
|
|
287
|
+
* @param baseName The base BEM class to attach modifiers to.
|
|
288
|
+
* @param modifiers Map of modifier names to boolean values.
|
|
289
|
+
* @returns Combined modifier class names string.
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* modifier('button', { active: true }); // 'button--active'
|
|
293
|
+
* modifier('button', { active: true, disabled: false }); // 'button--active'
|
|
433
294
|
*/
|
|
434
|
-
|
|
295
|
+
function modifier$1(baseName, modifiers) {
|
|
296
|
+
const modifierClasses = [];
|
|
297
|
+
for (const [key, value] of Object.entries(modifiers)) {
|
|
298
|
+
if (value) modifierClasses.push(`${baseName}--${key}`);
|
|
299
|
+
}
|
|
300
|
+
return modifierClasses.join(' ');
|
|
301
|
+
}
|
|
435
302
|
|
|
436
303
|
/**
|
|
437
|
-
*
|
|
304
|
+
* Generates a BEM block + modifier class name string.
|
|
305
|
+
* Combines a base class with optional modifiers and additional classes.
|
|
306
|
+
*
|
|
307
|
+
* @param baseName The base BEM class
|
|
308
|
+
* @param modifier Optional modifiers
|
|
309
|
+
* @returns Combined class name string
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* block('button'); // 'button'
|
|
313
|
+
* block('button', { active: true, disabled: false }); // 'button button--active'
|
|
438
314
|
*/
|
|
439
|
-
const CLASSNAME$1t = 'lumx-autocomplete-multiple';
|
|
440
315
|
|
|
441
|
-
|
|
442
|
-
* Component default props.
|
|
443
|
-
*/
|
|
444
|
-
const DEFAULT_PROPS$1e = {
|
|
445
|
-
closeOnClickAway: true,
|
|
446
|
-
closeOnEscape: true,
|
|
447
|
-
selectedChipRender(choice, index, onClear, isDisabled) {
|
|
448
|
-
const onClick = event => onClear && onClear(event, choice);
|
|
449
|
-
return /*#__PURE__*/jsx(Chip, {
|
|
450
|
-
after: onClear && /*#__PURE__*/jsx(Icon, {
|
|
451
|
-
icon: mdiClose,
|
|
452
|
-
size: Size$1.xxs
|
|
453
|
-
}),
|
|
454
|
-
isDisabled: isDisabled,
|
|
455
|
-
size: Size$1.s,
|
|
456
|
-
onAfterClick: onClick,
|
|
457
|
-
onClick: onClick,
|
|
458
|
-
children: choice
|
|
459
|
-
}, index);
|
|
460
|
-
},
|
|
461
|
-
values: []
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* AutocompleteMultiple component.
|
|
466
|
-
*
|
|
467
|
-
* @param props Component props.
|
|
468
|
-
* @param ref Component ref.
|
|
469
|
-
* @return React element.
|
|
470
|
-
*/
|
|
471
|
-
const AutocompleteMultiple = forwardRef((props, ref) => {
|
|
472
|
-
const defaultTheme = useTheme();
|
|
473
|
-
const {
|
|
474
|
-
disabledStateProps,
|
|
475
|
-
otherProps
|
|
476
|
-
} = useDisableStateProps(props);
|
|
477
|
-
const {
|
|
478
|
-
anchorToInput,
|
|
479
|
-
children,
|
|
480
|
-
// `chipsAlignment` needs to be here to remove it from `forwardedProps`.
|
|
481
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
482
|
-
chipsAlignment,
|
|
483
|
-
className,
|
|
484
|
-
closeOnClickAway = DEFAULT_PROPS$1e.closeOnClickAway,
|
|
485
|
-
closeOnEscape = DEFAULT_PROPS$1e.closeOnEscape,
|
|
486
|
-
fitToAnchorWidth,
|
|
487
|
-
hasError,
|
|
488
|
-
helper,
|
|
489
|
-
icon,
|
|
490
|
-
inputRef,
|
|
491
|
-
clearButtonProps,
|
|
492
|
-
isRequired,
|
|
493
|
-
isOpen,
|
|
494
|
-
isValid,
|
|
495
|
-
label,
|
|
496
|
-
name,
|
|
497
|
-
offset,
|
|
498
|
-
onBlur,
|
|
499
|
-
onChange,
|
|
500
|
-
onClear,
|
|
501
|
-
onClose,
|
|
502
|
-
onFocus,
|
|
503
|
-
onInfiniteScroll,
|
|
504
|
-
onKeyDown,
|
|
505
|
-
placeholder,
|
|
506
|
-
placement,
|
|
507
|
-
selectedChipRender = DEFAULT_PROPS$1e.selectedChipRender,
|
|
508
|
-
shouldFocusOnClose,
|
|
509
|
-
theme = defaultTheme,
|
|
510
|
-
type,
|
|
511
|
-
value,
|
|
512
|
-
values = DEFAULT_PROPS$1e.values,
|
|
513
|
-
...forwardedProps
|
|
514
|
-
} = otherProps;
|
|
515
|
-
return /*#__PURE__*/jsx(Autocomplete, {
|
|
516
|
-
ref: ref,
|
|
517
|
-
...forwardedProps,
|
|
518
|
-
anchorToInput: anchorToInput,
|
|
519
|
-
className: classNames.join(className, CLASSNAME$1t),
|
|
520
|
-
name: name,
|
|
521
|
-
value: value,
|
|
522
|
-
onChange: onChange,
|
|
523
|
-
onKeyDown: onKeyDown,
|
|
524
|
-
onBlur: onBlur,
|
|
525
|
-
shouldFocusOnClose: shouldFocusOnClose,
|
|
526
|
-
onFocus: onFocus,
|
|
527
|
-
hasError: hasError,
|
|
528
|
-
helper: helper,
|
|
529
|
-
icon: icon,
|
|
530
|
-
inputRef: inputRef,
|
|
531
|
-
chips: values && values.map((chip, index) => selectedChipRender?.(chip, index, onClear)),
|
|
532
|
-
...disabledStateProps,
|
|
533
|
-
isRequired: isRequired,
|
|
534
|
-
clearButtonProps: clearButtonProps,
|
|
535
|
-
isValid: isValid,
|
|
536
|
-
label: label,
|
|
537
|
-
placeholder: placeholder,
|
|
538
|
-
theme: theme,
|
|
539
|
-
type: type,
|
|
540
|
-
isOpen: isOpen,
|
|
541
|
-
closeOnClick: false,
|
|
542
|
-
closeOnClickAway: closeOnClickAway,
|
|
543
|
-
closeOnEscape: closeOnEscape,
|
|
544
|
-
onClose: onClose,
|
|
545
|
-
offset: offset,
|
|
546
|
-
placement: placement,
|
|
547
|
-
fitToAnchorWidth: fitToAnchorWidth,
|
|
548
|
-
onInfiniteScroll: onInfiniteScroll,
|
|
549
|
-
children: children
|
|
550
|
-
});
|
|
551
|
-
});
|
|
552
|
-
AutocompleteMultiple.displayName = COMPONENT_NAME$1v;
|
|
553
|
-
AutocompleteMultiple.className = CLASSNAME$1t;
|
|
554
|
-
AutocompleteMultiple.defaultProps = DEFAULT_PROPS$1e;
|
|
555
|
-
|
|
556
|
-
function getDefaultExportFromCjs (x) {
|
|
557
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
var classnames$1 = {exports: {}};
|
|
561
|
-
|
|
562
|
-
/*!
|
|
563
|
-
Copyright (c) 2018 Jed Watson.
|
|
564
|
-
Licensed under the MIT License (MIT), see
|
|
565
|
-
http://jedwatson.github.io/classnames
|
|
566
|
-
*/
|
|
567
|
-
|
|
568
|
-
var hasRequiredClassnames;
|
|
569
|
-
|
|
570
|
-
function requireClassnames () {
|
|
571
|
-
if (hasRequiredClassnames) return classnames$1.exports;
|
|
572
|
-
hasRequiredClassnames = 1;
|
|
573
|
-
(function (module) {
|
|
574
|
-
/* global define */
|
|
575
|
-
|
|
576
|
-
(function () {
|
|
577
|
-
|
|
578
|
-
var hasOwn = {}.hasOwnProperty;
|
|
579
|
-
|
|
580
|
-
function classNames() {
|
|
581
|
-
var classes = [];
|
|
582
|
-
|
|
583
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
584
|
-
var arg = arguments[i];
|
|
585
|
-
if (!arg) continue;
|
|
586
|
-
|
|
587
|
-
var argType = typeof arg;
|
|
588
|
-
|
|
589
|
-
if (argType === 'string' || argType === 'number') {
|
|
590
|
-
classes.push(arg);
|
|
591
|
-
} else if (Array.isArray(arg)) {
|
|
592
|
-
if (arg.length) {
|
|
593
|
-
var inner = classNames.apply(null, arg);
|
|
594
|
-
if (inner) {
|
|
595
|
-
classes.push(inner);
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
} else if (argType === 'object') {
|
|
599
|
-
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
600
|
-
classes.push(arg.toString());
|
|
601
|
-
continue;
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
for (var key in arg) {
|
|
605
|
-
if (hasOwn.call(arg, key) && arg[key]) {
|
|
606
|
-
classes.push(key);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
return classes.join(' ');
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
if (module.exports) {
|
|
616
|
-
classNames.default = classNames;
|
|
617
|
-
module.exports = classNames;
|
|
618
|
-
} else {
|
|
619
|
-
window.classNames = classNames;
|
|
620
|
-
}
|
|
621
|
-
}());
|
|
622
|
-
} (classnames$1));
|
|
623
|
-
return classnames$1.exports;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
var classnamesExports = requireClassnames();
|
|
627
|
-
var classnames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
|
|
628
|
-
|
|
629
|
-
/**
|
|
630
|
-
* Modifier
|
|
631
|
-
* @example { 'is-disabled': true, 'is-selected': false }
|
|
632
|
-
*/
|
|
633
|
-
|
|
634
|
-
/**
|
|
635
|
-
* Generates BEM modifier class names.
|
|
636
|
-
*
|
|
637
|
-
* @param baseName The base BEM class to attach modifiers to.
|
|
638
|
-
* @param modifiers Map of modifier names to boolean values.
|
|
639
|
-
* @returns Combined modifier class names string.
|
|
640
|
-
*
|
|
641
|
-
* @example
|
|
642
|
-
* modifier('button', { active: true }); // 'button--active'
|
|
643
|
-
* modifier('button', { active: true, disabled: false }); // 'button--active'
|
|
644
|
-
*/
|
|
645
|
-
function modifier$1(baseName, modifiers) {
|
|
646
|
-
const modifierClasses = [];
|
|
647
|
-
for (const [key, value] of Object.entries(modifiers)) {
|
|
648
|
-
if (value) modifierClasses.push(`${baseName}--${key}`);
|
|
649
|
-
}
|
|
650
|
-
return modifierClasses.join(' ');
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
/**
|
|
654
|
-
* Generates a BEM block + modifier class name string.
|
|
655
|
-
* Combines a base class with optional modifiers and additional classes.
|
|
656
|
-
*
|
|
657
|
-
* @param baseName The base BEM class
|
|
658
|
-
* @param modifier Optional modifiers
|
|
659
|
-
* @returns Combined class name string
|
|
660
|
-
*
|
|
661
|
-
* @example
|
|
662
|
-
* block('button'); // 'button'
|
|
663
|
-
* block('button', { active: true, disabled: false }); // 'button button--active'
|
|
664
|
-
*/
|
|
665
|
-
|
|
666
|
-
function block$18(baseName, modifiersOrAdditionalClasses, additionalClasses) {
|
|
316
|
+
function block$19(baseName, modifiersOrAdditionalClasses, additionalClasses) {
|
|
667
317
|
let modifiers;
|
|
668
318
|
let classes;
|
|
669
319
|
if (Array.isArray(modifiersOrAdditionalClasses)) {
|
|
@@ -698,7 +348,7 @@ const ACTION_ELEMENT = `${PREFIX}__action`;
|
|
|
698
348
|
const actionArea = Object.assign(/** Action area container class. Sets `position: relative`. */
|
|
699
349
|
() => PREFIX, {
|
|
700
350
|
/** Action element class. Adds a `::before` pseudo-element with `position: absolute; inset: 0` to expand the click area. */
|
|
701
|
-
action: modifiers => block$
|
|
351
|
+
action: modifiers => block$19(ACTION_ELEMENT, modifiers)
|
|
702
352
|
});
|
|
703
353
|
|
|
704
354
|
/** Resolve color & color variant from a `ColorWithVariants` and optionally a `ColorVariant`. */
|
|
@@ -822,9 +472,9 @@ const visuallyHidden = () => VISUALLY_HIDDEN;
|
|
|
822
472
|
|
|
823
473
|
function element$R(baseClass, elem, modifiersOrAdditionalClasses, additionalClasses) {
|
|
824
474
|
if (Array.isArray(modifiersOrAdditionalClasses)) {
|
|
825
|
-
return block$
|
|
475
|
+
return block$19(`${baseClass}__${elem}`, modifiersOrAdditionalClasses);
|
|
826
476
|
}
|
|
827
|
-
return block$
|
|
477
|
+
return block$19(`${baseClass}__${elem}`, modifiersOrAdditionalClasses, additionalClasses);
|
|
828
478
|
}
|
|
829
479
|
|
|
830
480
|
/**
|
|
@@ -833,9 +483,9 @@ function element$R(baseClass, elem, modifiersOrAdditionalClasses, additionalClas
|
|
|
833
483
|
function bem(baseName) {
|
|
834
484
|
function blockFn(modifiersOrAdditionalClasses, additionalClasses) {
|
|
835
485
|
if (Array.isArray(modifiersOrAdditionalClasses)) {
|
|
836
|
-
return block$
|
|
486
|
+
return block$19(baseName, modifiersOrAdditionalClasses);
|
|
837
487
|
}
|
|
838
|
-
return block$
|
|
488
|
+
return block$19(baseName, modifiersOrAdditionalClasses, additionalClasses);
|
|
839
489
|
}
|
|
840
490
|
function elementFn(elem, modifiersOrAdditionalClasses, additionalClasses) {
|
|
841
491
|
if (Array.isArray(modifiersOrAdditionalClasses)) {
|
|
@@ -879,134 +529,538 @@ const getWithSelector = (selector, object) => {
|
|
|
879
529
|
};
|
|
880
530
|
|
|
881
531
|
/**
|
|
882
|
-
*
|
|
883
|
-
* you need to update their scss counterpart as well
|
|
532
|
+
* Associative map from message kind to color and icon.
|
|
884
533
|
*/
|
|
534
|
+
const CONFIG$1 = {
|
|
535
|
+
[Kind.error]: {
|
|
536
|
+
color: ColorPalette.red,
|
|
537
|
+
icon: mdiAlert
|
|
538
|
+
},
|
|
539
|
+
[Kind.info]: {
|
|
540
|
+
color: ColorPalette.blue,
|
|
541
|
+
icon: mdiInformation
|
|
542
|
+
},
|
|
543
|
+
[Kind.success]: {
|
|
544
|
+
color: ColorPalette.green,
|
|
545
|
+
icon: mdiCheckCircle
|
|
546
|
+
},
|
|
547
|
+
[Kind.warning]: {
|
|
548
|
+
color: ColorPalette.yellow,
|
|
549
|
+
icon: mdiAlertCircle
|
|
550
|
+
}
|
|
551
|
+
};
|
|
885
552
|
|
|
886
553
|
/**
|
|
887
|
-
*
|
|
888
|
-
* Only applies to devices supporting pointer hover.
|
|
554
|
+
* Component display name.
|
|
889
555
|
*/
|
|
890
|
-
const
|
|
891
|
-
open: 500,
|
|
892
|
-
close: 500
|
|
893
|
-
};
|
|
556
|
+
const COMPONENT_NAME$1x = 'AlertDialog';
|
|
894
557
|
|
|
895
558
|
/**
|
|
896
|
-
*
|
|
897
|
-
* Only applies to devices not supporting pointer hover.
|
|
559
|
+
* Component default class name and class prefix.
|
|
898
560
|
*/
|
|
899
|
-
const
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
};
|
|
561
|
+
const CLASSNAME$1v = 'lumx-alert-dialog';
|
|
562
|
+
const {
|
|
563
|
+
block: block$18
|
|
564
|
+
} = bem(CLASSNAME$1v);
|
|
903
565
|
|
|
904
566
|
/**
|
|
905
|
-
*
|
|
567
|
+
* Component default props.
|
|
906
568
|
*/
|
|
907
|
-
const
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
light: 'light',
|
|
911
|
-
dark: 'dark'
|
|
912
|
-
};
|
|
913
|
-
const Size = {
|
|
914
|
-
xxs: 'xxs',
|
|
915
|
-
xs: 'xs',
|
|
916
|
-
s: 's',
|
|
917
|
-
m: 'm',
|
|
918
|
-
l: 'l',
|
|
919
|
-
xl: 'xl',
|
|
920
|
-
xxl: 'xxl',
|
|
921
|
-
tiny: 'tiny',
|
|
922
|
-
regular: 'regular',
|
|
923
|
-
medium: 'medium',
|
|
924
|
-
big: 'big',
|
|
925
|
-
huge: 'huge'
|
|
926
|
-
};
|
|
927
|
-
const Orientation = {
|
|
928
|
-
horizontal: 'horizontal',
|
|
929
|
-
vertical: 'vertical'
|
|
930
|
-
};
|
|
931
|
-
const Emphasis = {
|
|
932
|
-
low: 'low',
|
|
933
|
-
high: 'high'
|
|
569
|
+
const DEFAULT_PROPS$1g = {
|
|
570
|
+
size: Size.tiny,
|
|
571
|
+
kind: Kind.info
|
|
934
572
|
};
|
|
573
|
+
|
|
935
574
|
/**
|
|
936
|
-
*
|
|
575
|
+
* AlertDialog component.
|
|
576
|
+
*
|
|
577
|
+
* An alert dialog is a modal dialog that interrupts the user's workflow to
|
|
578
|
+
* communicate an important message and acquire a response.
|
|
579
|
+
*
|
|
580
|
+
* It should not have a complex content.
|
|
581
|
+
* Children of this component should only be strings, paragraphs or links.
|
|
937
582
|
*/
|
|
938
|
-
const
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
583
|
+
const AlertDialog$1 = props => {
|
|
584
|
+
const {
|
|
585
|
+
id,
|
|
586
|
+
title,
|
|
587
|
+
className,
|
|
588
|
+
cancelProps,
|
|
589
|
+
confirmProps,
|
|
590
|
+
ref,
|
|
591
|
+
kind = DEFAULT_PROPS$1g.kind,
|
|
592
|
+
size = DEFAULT_PROPS$1g.size,
|
|
593
|
+
dialogProps,
|
|
594
|
+
children,
|
|
595
|
+
DescriptionElement,
|
|
596
|
+
cancelButtonRef,
|
|
597
|
+
confirmationButtonRef,
|
|
598
|
+
focusElement,
|
|
599
|
+
Dialog,
|
|
600
|
+
Toolbar,
|
|
601
|
+
Button,
|
|
602
|
+
Icon,
|
|
603
|
+
...forwardedProps
|
|
604
|
+
} = props;
|
|
605
|
+
const {
|
|
606
|
+
color,
|
|
607
|
+
icon
|
|
608
|
+
} = CONFIG$1[kind] || {};
|
|
609
|
+
const titleId = `${id}-title`;
|
|
610
|
+
const descriptionId = `${id}-description`;
|
|
611
|
+
const {
|
|
612
|
+
label: confirmLabel,
|
|
613
|
+
onClick: confirmOnClick,
|
|
614
|
+
...forwardedConfirmProps
|
|
615
|
+
} = confirmProps;
|
|
616
|
+
const {
|
|
617
|
+
label: cancelLabel,
|
|
618
|
+
onClick: cancelOnClick,
|
|
619
|
+
...forwardedCancelProps
|
|
620
|
+
} = cancelProps || {};
|
|
621
|
+
return /*#__PURE__*/jsxs(Dialog, {
|
|
622
|
+
ref: ref,
|
|
623
|
+
focusElement: focusElement ?? (cancelProps ? cancelButtonRef : confirmationButtonRef),
|
|
624
|
+
size: size,
|
|
625
|
+
dialogProps: {
|
|
626
|
+
id,
|
|
627
|
+
role: 'alertdialog',
|
|
628
|
+
'aria-labelledby': titleId,
|
|
629
|
+
'aria-describedby': descriptionId,
|
|
630
|
+
...dialogProps
|
|
631
|
+
},
|
|
632
|
+
className: classnames(className, block$18({
|
|
633
|
+
[`kind-${kind}`]: Boolean(kind)
|
|
634
|
+
})),
|
|
635
|
+
...forwardedProps,
|
|
636
|
+
children: [/*#__PURE__*/jsx("header", {
|
|
637
|
+
children: /*#__PURE__*/jsx(Toolbar, {
|
|
638
|
+
className: "lumx-spacing-margin-horizontal",
|
|
639
|
+
before: /*#__PURE__*/jsx(Icon, {
|
|
640
|
+
icon: icon,
|
|
641
|
+
size: Size.s,
|
|
642
|
+
color: color
|
|
643
|
+
}),
|
|
644
|
+
label: /*#__PURE__*/jsx("h2", {
|
|
645
|
+
id: titleId,
|
|
646
|
+
className: "lumx-typography-title",
|
|
647
|
+
children: title
|
|
648
|
+
})
|
|
649
|
+
})
|
|
650
|
+
}), children && /*#__PURE__*/jsx(DescriptionElement, {
|
|
651
|
+
id: descriptionId,
|
|
652
|
+
className: "lumx-typography-body2 lumx-spacing-padding-vertical-big lumx-spacing-padding-horizontal-huge",
|
|
653
|
+
children: children
|
|
654
|
+
}), /*#__PURE__*/jsx("footer", {
|
|
655
|
+
children: /*#__PURE__*/jsx(Toolbar, {
|
|
656
|
+
className: "lumx-spacing-margin-horizontal",
|
|
657
|
+
after: /*#__PURE__*/jsxs(Fragment, {
|
|
658
|
+
children: [cancelProps && /*#__PURE__*/jsx(Button, {
|
|
659
|
+
...forwardedCancelProps,
|
|
660
|
+
ref: cancelButtonRef,
|
|
661
|
+
emphasis: Emphasis.medium,
|
|
662
|
+
onClick: cancelOnClick,
|
|
663
|
+
children: cancelLabel
|
|
664
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
665
|
+
...forwardedConfirmProps,
|
|
666
|
+
ref: confirmationButtonRef,
|
|
667
|
+
color: color,
|
|
668
|
+
className: "lumx-spacing-margin-left-regular",
|
|
669
|
+
onClick: confirmOnClick,
|
|
670
|
+
children: confirmLabel
|
|
671
|
+
})]
|
|
672
|
+
})
|
|
673
|
+
})
|
|
674
|
+
})]
|
|
675
|
+
});
|
|
948
676
|
};
|
|
677
|
+
|
|
949
678
|
/**
|
|
950
|
-
*
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
*
|
|
679
|
+
* AlertDialog component.
|
|
680
|
+
*
|
|
681
|
+
* An alert dialog is a modal dialog that interrupts the user's workflow to
|
|
682
|
+
* communicate an important message and acquire a response.
|
|
683
|
+
*
|
|
684
|
+
* It should not have a complex content.
|
|
685
|
+
* Children of this component should only be strings, paragraphs or links.
|
|
956
686
|
*/
|
|
957
|
-
const
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
687
|
+
const AlertDialog = forwardRef((props, ref) => {
|
|
688
|
+
const {
|
|
689
|
+
id,
|
|
690
|
+
title,
|
|
691
|
+
className,
|
|
692
|
+
cancelProps,
|
|
693
|
+
confirmProps,
|
|
694
|
+
kind,
|
|
695
|
+
size,
|
|
696
|
+
dialogProps,
|
|
697
|
+
children,
|
|
698
|
+
...forwardedProps
|
|
699
|
+
} = props;
|
|
700
|
+
const cancelButtonRef = React__default.useRef(null);
|
|
701
|
+
const confirmationButtonRef = React__default.useRef(null);
|
|
702
|
+
|
|
703
|
+
// Define a unique ID to target title and description for aria attributes.
|
|
704
|
+
const generatedId = useId();
|
|
705
|
+
const uniqueId = id || generatedId;
|
|
706
|
+
|
|
707
|
+
// If content is a string, set in a paragraph.
|
|
708
|
+
const DescriptionElement = typeof children === 'string' ? 'p' : 'div';
|
|
709
|
+
return AlertDialog$1({
|
|
710
|
+
Button,
|
|
711
|
+
confirmProps,
|
|
712
|
+
DescriptionElement,
|
|
713
|
+
Dialog,
|
|
714
|
+
Icon,
|
|
715
|
+
id: uniqueId,
|
|
716
|
+
Toolbar,
|
|
717
|
+
cancelButtonRef,
|
|
718
|
+
cancelProps,
|
|
719
|
+
children,
|
|
720
|
+
className,
|
|
721
|
+
confirmationButtonRef,
|
|
722
|
+
dialogProps,
|
|
723
|
+
kind,
|
|
724
|
+
ref,
|
|
725
|
+
size,
|
|
726
|
+
title,
|
|
727
|
+
...forwardedProps
|
|
728
|
+
});
|
|
729
|
+
});
|
|
730
|
+
AlertDialog.displayName = COMPONENT_NAME$1x;
|
|
731
|
+
AlertDialog.className = CLASSNAME$1v;
|
|
732
|
+
AlertDialog.defaultProps = DEFAULT_PROPS$1g;
|
|
733
|
+
|
|
967
734
|
/**
|
|
968
|
-
*
|
|
735
|
+
* Hook focusing an element when defined and `focus` boolean `true`.
|
|
736
|
+
*
|
|
737
|
+
* @param element Element to focus.
|
|
738
|
+
* @param shouldFocus Boolean flag to trigger the focus
|
|
969
739
|
*/
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
740
|
+
function useFocus(element, shouldFocus = true) {
|
|
741
|
+
const [wasFocus, setWasFocus] = useState(false);
|
|
742
|
+
useEffect(() => {
|
|
743
|
+
if (shouldFocus && wasFocus !== shouldFocus && element) {
|
|
744
|
+
element.focus();
|
|
745
|
+
setWasFocus(shouldFocus);
|
|
746
|
+
}
|
|
747
|
+
},
|
|
748
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
749
|
+
[element, shouldFocus]);
|
|
750
|
+
}
|
|
751
|
+
|
|
976
752
|
/**
|
|
977
|
-
*
|
|
753
|
+
* Merge refs into a single function ref.
|
|
754
|
+
*
|
|
755
|
+
* @param refs React references to merge.
|
|
756
|
+
* @return the merged ref.
|
|
978
757
|
*/
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
758
|
+
function mergeRefs(...refs) {
|
|
759
|
+
return value => refs.forEach(ref => {
|
|
760
|
+
if (typeof ref === 'function') {
|
|
761
|
+
ref(value);
|
|
762
|
+
} else if (ref) {
|
|
763
|
+
// eslint-disable-next-line no-param-reassign
|
|
764
|
+
ref.current = value;
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
|
|
987
769
|
/**
|
|
988
|
-
*
|
|
770
|
+
* Same as `mergeRefs` but memoized
|
|
989
771
|
*/
|
|
990
|
-
const
|
|
991
|
-
|
|
772
|
+
const useMergeRefs = (...refs) => {
|
|
773
|
+
return useMemo(() => mergeRefs(...refs),
|
|
774
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
775
|
+
refs);
|
|
992
776
|
};
|
|
993
777
|
|
|
994
|
-
|
|
778
|
+
const ThemeContext = /*#__PURE__*/React__default.createContext(undefined);
|
|
995
779
|
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
780
|
+
/** Provide a theme context to all children. */
|
|
781
|
+
const ThemeProvider = ThemeContext.Provider;
|
|
782
|
+
|
|
783
|
+
/** Get the theme in the current context. */
|
|
784
|
+
function useTheme() {
|
|
785
|
+
return React__default.useContext(ThemeContext);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* Resolve disabled state from props.
|
|
790
|
+
* (handles `disabled`, `isDisabled` and `aria-disabled`)
|
|
791
|
+
*
|
|
792
|
+
* @params component props
|
|
793
|
+
*/
|
|
794
|
+
function useDisableStateProps(props) {
|
|
795
|
+
const {
|
|
796
|
+
disabled,
|
|
797
|
+
isDisabled,
|
|
798
|
+
'aria-disabled': ariaDisabled,
|
|
799
|
+
onClick,
|
|
800
|
+
onChange,
|
|
801
|
+
...otherProps
|
|
802
|
+
} = props;
|
|
803
|
+
const disabledStateContext = useDisabledStateContext();
|
|
804
|
+
const disabledStateProps = getDisabledState$1(disabledStateContext, {
|
|
805
|
+
disabled,
|
|
806
|
+
isDisabled,
|
|
807
|
+
'aria-disabled': ariaDisabled
|
|
808
|
+
});
|
|
809
|
+
const isAnyDisabled = disabledStateProps['aria-disabled'] || disabledStateProps.disabled || undefined;
|
|
810
|
+
if (!isAnyDisabled) {
|
|
811
|
+
otherProps.onClick = onClick;
|
|
812
|
+
otherProps.onChange = onChange;
|
|
813
|
+
}
|
|
814
|
+
return {
|
|
815
|
+
disabledStateProps,
|
|
816
|
+
otherProps: otherProps,
|
|
817
|
+
isAnyDisabled
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* Component display name.
|
|
823
|
+
*/
|
|
824
|
+
const COMPONENT_NAME$1w = 'Autocomplete';
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* Component default class name and class prefix.
|
|
828
|
+
*/
|
|
829
|
+
const CLASSNAME$1u = 'lumx-autocomplete';
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* Component default props.
|
|
833
|
+
*/
|
|
834
|
+
const DEFAULT_PROPS$1f = {
|
|
835
|
+
anchorToInput: false,
|
|
836
|
+
closeOnClick: false,
|
|
837
|
+
closeOnClickAway: true,
|
|
838
|
+
closeOnEscape: true,
|
|
839
|
+
shouldFocusOnClose: false
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
/**
|
|
843
|
+
* Autocomplete component.
|
|
844
|
+
*
|
|
845
|
+
* @param props Component props.
|
|
846
|
+
* @param ref Component ref.
|
|
847
|
+
* @return React element.
|
|
848
|
+
*/
|
|
849
|
+
const Autocomplete = forwardRef((props, ref) => {
|
|
850
|
+
const defaultTheme = useTheme();
|
|
851
|
+
const {
|
|
852
|
+
disabledStateProps,
|
|
853
|
+
otherProps
|
|
854
|
+
} = useDisableStateProps(props);
|
|
855
|
+
const {
|
|
856
|
+
anchorToInput = DEFAULT_PROPS$1f.anchorToInput,
|
|
857
|
+
children,
|
|
858
|
+
chips,
|
|
859
|
+
className,
|
|
860
|
+
closeOnClick = DEFAULT_PROPS$1f.closeOnClick,
|
|
861
|
+
closeOnClickAway = DEFAULT_PROPS$1f.closeOnClickAway,
|
|
862
|
+
closeOnEscape = DEFAULT_PROPS$1f.closeOnEscape,
|
|
863
|
+
error,
|
|
864
|
+
fitToAnchorWidth,
|
|
865
|
+
hasError,
|
|
866
|
+
helper,
|
|
867
|
+
icon,
|
|
868
|
+
inputRef,
|
|
869
|
+
clearButtonProps,
|
|
870
|
+
isRequired,
|
|
871
|
+
isOpen,
|
|
872
|
+
isValid,
|
|
873
|
+
label,
|
|
874
|
+
name,
|
|
875
|
+
offset,
|
|
876
|
+
onBlur,
|
|
877
|
+
onChange,
|
|
878
|
+
onClose,
|
|
879
|
+
onFocus,
|
|
880
|
+
onInfiniteScroll,
|
|
881
|
+
placeholder,
|
|
882
|
+
placement,
|
|
883
|
+
shouldFocusOnClose = DEFAULT_PROPS$1f.shouldFocusOnClose,
|
|
884
|
+
theme = defaultTheme,
|
|
885
|
+
value,
|
|
886
|
+
textFieldProps = {},
|
|
887
|
+
focusAnchorOnClose,
|
|
888
|
+
...forwardedProps
|
|
889
|
+
} = otherProps;
|
|
890
|
+
const inputAnchorRef = useRef(null);
|
|
891
|
+
const textFieldRef = useRef(null);
|
|
892
|
+
useFocus(inputAnchorRef.current, !isOpen && shouldFocusOnClose);
|
|
893
|
+
return /*#__PURE__*/jsxs("div", {
|
|
894
|
+
ref: ref,
|
|
895
|
+
...forwardedProps,
|
|
896
|
+
className: classNames.join(className, CLASSNAME$1u),
|
|
897
|
+
children: [/*#__PURE__*/jsx(TextField, {
|
|
898
|
+
...textFieldProps,
|
|
899
|
+
chips: chips,
|
|
900
|
+
error: error,
|
|
901
|
+
hasError: hasError,
|
|
902
|
+
helper: helper,
|
|
903
|
+
icon: icon,
|
|
904
|
+
inputRef: mergeRefs(inputAnchorRef, inputRef),
|
|
905
|
+
clearButtonProps: clearButtonProps,
|
|
906
|
+
...disabledStateProps,
|
|
907
|
+
isRequired: isRequired,
|
|
908
|
+
isValid: isValid,
|
|
909
|
+
label: label,
|
|
910
|
+
name: name,
|
|
911
|
+
onBlur: onBlur,
|
|
912
|
+
onChange: onChange,
|
|
913
|
+
onFocus: onFocus,
|
|
914
|
+
placeholder: placeholder,
|
|
915
|
+
textFieldRef: textFieldRef,
|
|
916
|
+
theme: theme,
|
|
917
|
+
value: value
|
|
918
|
+
}), /*#__PURE__*/jsx(Dropdown, {
|
|
919
|
+
anchorRef: anchorToInput ? inputAnchorRef : textFieldRef,
|
|
920
|
+
closeOnClick: closeOnClick,
|
|
921
|
+
closeOnClickAway: closeOnClickAway,
|
|
922
|
+
closeOnEscape: closeOnEscape,
|
|
923
|
+
focusAnchorOnClose: focusAnchorOnClose,
|
|
924
|
+
fitToAnchorWidth: fitToAnchorWidth,
|
|
925
|
+
isOpen: isOpen,
|
|
926
|
+
offset: offset,
|
|
927
|
+
onClose: onClose,
|
|
928
|
+
onInfiniteScroll: onInfiniteScroll,
|
|
929
|
+
placement: placement,
|
|
930
|
+
shouldFocusOnOpen: false,
|
|
931
|
+
theme: theme,
|
|
932
|
+
children: children
|
|
933
|
+
})]
|
|
934
|
+
});
|
|
1004
935
|
});
|
|
936
|
+
Autocomplete.displayName = COMPONENT_NAME$1w;
|
|
937
|
+
Autocomplete.className = CLASSNAME$1u;
|
|
938
|
+
Autocomplete.defaultProps = DEFAULT_PROPS$1f;
|
|
1005
939
|
|
|
1006
940
|
/**
|
|
1007
|
-
*
|
|
941
|
+
* Component display name.
|
|
1008
942
|
*/
|
|
1009
|
-
const
|
|
943
|
+
const COMPONENT_NAME$1v = 'AutocompleteMultiple';
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* Component default class name and class prefix.
|
|
947
|
+
*/
|
|
948
|
+
const CLASSNAME$1t = 'lumx-autocomplete-multiple';
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* Component default props.
|
|
952
|
+
*/
|
|
953
|
+
const DEFAULT_PROPS$1e = {
|
|
954
|
+
closeOnClickAway: true,
|
|
955
|
+
closeOnEscape: true,
|
|
956
|
+
selectedChipRender(choice, index, onClear, isDisabled) {
|
|
957
|
+
const onClick = event => onClear && onClear(event, choice);
|
|
958
|
+
return /*#__PURE__*/jsx(Chip, {
|
|
959
|
+
after: onClear && /*#__PURE__*/jsx(Icon, {
|
|
960
|
+
icon: mdiClose,
|
|
961
|
+
size: Size$1.xxs
|
|
962
|
+
}),
|
|
963
|
+
isDisabled: isDisabled,
|
|
964
|
+
size: Size$1.s,
|
|
965
|
+
onAfterClick: onClick,
|
|
966
|
+
onClick: onClick,
|
|
967
|
+
children: choice
|
|
968
|
+
}, index);
|
|
969
|
+
},
|
|
970
|
+
values: []
|
|
971
|
+
};
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* AutocompleteMultiple component.
|
|
975
|
+
*
|
|
976
|
+
* @param props Component props.
|
|
977
|
+
* @param ref Component ref.
|
|
978
|
+
* @return React element.
|
|
979
|
+
*/
|
|
980
|
+
const AutocompleteMultiple = forwardRef((props, ref) => {
|
|
981
|
+
const defaultTheme = useTheme();
|
|
982
|
+
const {
|
|
983
|
+
disabledStateProps,
|
|
984
|
+
otherProps
|
|
985
|
+
} = useDisableStateProps(props);
|
|
986
|
+
const {
|
|
987
|
+
anchorToInput,
|
|
988
|
+
children,
|
|
989
|
+
// `chipsAlignment` needs to be here to remove it from `forwardedProps`.
|
|
990
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
991
|
+
chipsAlignment,
|
|
992
|
+
className,
|
|
993
|
+
closeOnClickAway = DEFAULT_PROPS$1e.closeOnClickAway,
|
|
994
|
+
closeOnEscape = DEFAULT_PROPS$1e.closeOnEscape,
|
|
995
|
+
fitToAnchorWidth,
|
|
996
|
+
hasError,
|
|
997
|
+
helper,
|
|
998
|
+
icon,
|
|
999
|
+
inputRef,
|
|
1000
|
+
clearButtonProps,
|
|
1001
|
+
isRequired,
|
|
1002
|
+
isOpen,
|
|
1003
|
+
isValid,
|
|
1004
|
+
label,
|
|
1005
|
+
name,
|
|
1006
|
+
offset,
|
|
1007
|
+
onBlur,
|
|
1008
|
+
onChange,
|
|
1009
|
+
onClear,
|
|
1010
|
+
onClose,
|
|
1011
|
+
onFocus,
|
|
1012
|
+
onInfiniteScroll,
|
|
1013
|
+
onKeyDown,
|
|
1014
|
+
placeholder,
|
|
1015
|
+
placement,
|
|
1016
|
+
selectedChipRender = DEFAULT_PROPS$1e.selectedChipRender,
|
|
1017
|
+
shouldFocusOnClose,
|
|
1018
|
+
theme = defaultTheme,
|
|
1019
|
+
type,
|
|
1020
|
+
value,
|
|
1021
|
+
values = DEFAULT_PROPS$1e.values,
|
|
1022
|
+
...forwardedProps
|
|
1023
|
+
} = otherProps;
|
|
1024
|
+
return /*#__PURE__*/jsx(Autocomplete, {
|
|
1025
|
+
ref: ref,
|
|
1026
|
+
...forwardedProps,
|
|
1027
|
+
anchorToInput: anchorToInput,
|
|
1028
|
+
className: classNames.join(className, CLASSNAME$1t),
|
|
1029
|
+
name: name,
|
|
1030
|
+
value: value,
|
|
1031
|
+
onChange: onChange,
|
|
1032
|
+
onKeyDown: onKeyDown,
|
|
1033
|
+
onBlur: onBlur,
|
|
1034
|
+
shouldFocusOnClose: shouldFocusOnClose,
|
|
1035
|
+
onFocus: onFocus,
|
|
1036
|
+
hasError: hasError,
|
|
1037
|
+
helper: helper,
|
|
1038
|
+
icon: icon,
|
|
1039
|
+
inputRef: inputRef,
|
|
1040
|
+
chips: values && values.map((chip, index) => selectedChipRender?.(chip, index, onClear)),
|
|
1041
|
+
...disabledStateProps,
|
|
1042
|
+
isRequired: isRequired,
|
|
1043
|
+
clearButtonProps: clearButtonProps,
|
|
1044
|
+
isValid: isValid,
|
|
1045
|
+
label: label,
|
|
1046
|
+
placeholder: placeholder,
|
|
1047
|
+
theme: theme,
|
|
1048
|
+
type: type,
|
|
1049
|
+
isOpen: isOpen,
|
|
1050
|
+
closeOnClick: false,
|
|
1051
|
+
closeOnClickAway: closeOnClickAway,
|
|
1052
|
+
closeOnEscape: closeOnEscape,
|
|
1053
|
+
onClose: onClose,
|
|
1054
|
+
offset: offset,
|
|
1055
|
+
placement: placement,
|
|
1056
|
+
fitToAnchorWidth: fitToAnchorWidth,
|
|
1057
|
+
onInfiniteScroll: onInfiniteScroll,
|
|
1058
|
+
children: children
|
|
1059
|
+
});
|
|
1060
|
+
});
|
|
1061
|
+
AutocompleteMultiple.displayName = COMPONENT_NAME$1v;
|
|
1062
|
+
AutocompleteMultiple.className = CLASSNAME$1t;
|
|
1063
|
+
AutocompleteMultiple.defaultProps = DEFAULT_PROPS$1e;
|
|
1010
1064
|
|
|
1011
1065
|
/**
|
|
1012
1066
|
* Component display name.
|