@lumx/react 3.20.1-alpha.15 → 3.20.1-alpha.16
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/_internal/{Button-f19e18df.js → Button-1f227024.js} +30 -28
- package/_internal/{Button-f19e18df.js.map → Button-1f227024.js.map} +1 -1
- package/_internal/{ButtonRoot-ab633b1d.js → ButtonRoot-823f3e9c.js} +18 -16
- package/_internal/{ButtonRoot-ab633b1d.js.map → ButtonRoot-823f3e9c.js.map} +1 -1
- package/_internal/{Chip-4c572eec.js → Chip-a34f6905.js} +31 -34
- package/_internal/{Chip-4c572eec.js.map → Chip-a34f6905.js.map} +1 -1
- package/_internal/{ClickAwayProvider-bcce6ceb.js → ClickAwayProvider-7093ba23.js} +6 -4
- package/_internal/{ClickAwayProvider-bcce6ceb.js.map → ClickAwayProvider-7093ba23.js.map} +1 -1
- package/_internal/{DisabledStateContext-077b7bef.js → DisabledStateContext-ea04260d.js} +6 -6
- package/_internal/{DisabledStateContext-077b7bef.js.map → DisabledStateContext-ea04260d.js.map} +1 -1
- package/_internal/{HeadingLevelProvider-e4817816.js → HeadingLevelProvider-ebdcb0c7.js} +6 -4
- package/_internal/{HeadingLevelProvider-e4817816.js.map → HeadingLevelProvider-ebdcb0c7.js.map} +1 -1
- package/_internal/{IconButton-10585058.js → IconButton-f4df224c.js} +29 -24
- package/_internal/{IconButton-10585058.js.map → IconButton-f4df224c.js.map} +1 -1
- package/_internal/ImageCaption-8134a3aa.js +75 -0
- package/_internal/{ImageCaption-4279b2b6.js.map → ImageCaption-8134a3aa.js.map} +1 -1
- package/_internal/{List-d5f5d465.js → List-54237e0e.js} +52 -50
- package/_internal/{List-d5f5d465.js.map → List-54237e0e.js.map} +1 -1
- package/_internal/{PopoverDialog-21e5c9dd.js → PopoverDialog-e0967e5f.js} +166 -158
- package/_internal/{PopoverDialog-21e5c9dd.js.map → PopoverDialog-e0967e5f.js.map} +1 -1
- package/_internal/{Portal-c43d098b.js → Portal-3f86608e.js} +5 -2
- package/_internal/{Portal-c43d098b.js.map → Portal-3f86608e.js.map} +1 -1
- package/_internal/{RawClickable-c76bbc4c.js → RawClickable-2c2b6a89.js} +9 -7
- package/_internal/{RawClickable-c76bbc4c.js.map → RawClickable-2c2b6a89.js.map} +1 -1
- package/_internal/{Slides-01f513ce.js → Slides-b7a67f32.js} +99 -96
- package/_internal/{Slides-01f513ce.js.map → Slides-b7a67f32.js.map} +1 -1
- package/_internal/{Thumbnail-30d2a781.js → Thumbnail-b5dea0af.js} +46 -45
- package/_internal/{Thumbnail-30d2a781.js.map → Thumbnail-b5dea0af.js.map} +1 -1
- package/_internal/components/{alert-dialog-8f1c163c.js → alert-dialog-b284b191.js} +50 -35
- package/_internal/components/{alert-dialog-8f1c163c.js.map → alert-dialog-b284b191.js.map} +1 -1
- package/_internal/components/{autocomplete-bfbdeb3c.js → autocomplete-8d3f37ea.js} +64 -67
- package/_internal/components/{autocomplete-bfbdeb3c.js.map → autocomplete-8d3f37ea.js.map} +1 -1
- package/_internal/components/{avatar-6990e3e9.js → avatar-5fc70e00.js} +28 -32
- package/_internal/components/{avatar-6990e3e9.js.map → avatar-5fc70e00.js.map} +1 -1
- package/_internal/components/{badge-81543bc7.js → badge-8390e590.js} +18 -18
- package/_internal/components/{badge-81543bc7.js.map → badge-8390e590.js.map} +1 -1
- package/_internal/components/{button-927abe71.js → button-e3c7f2eb.js} +11 -13
- package/_internal/components/{button-927abe71.js.map → button-e3c7f2eb.js.map} +1 -1
- package/_internal/components/{checkbox-dc4caec8.js → checkbox-d1ca9748.js} +53 -44
- package/_internal/components/{checkbox-dc4caec8.js.map → checkbox-d1ca9748.js.map} +1 -1
- package/_internal/components/{chip-fb3d0c76.js → chip-e40c5521.js} +10 -12
- package/_internal/components/{chip-fb3d0c76.js.map → chip-e40c5521.js.map} +1 -1
- package/_internal/components/comment-block-a3cf7b9b.js +138 -0
- package/_internal/components/{comment-block-b84c4694.js.map → comment-block-a3cf7b9b.js.map} +1 -1
- package/_internal/components/date-picker-6c1b14e4.js +2 -0
- package/_internal/components/date-picker-6c1b14e4.js.map +1 -0
- package/_internal/components/{dialog-7dbcb485.js → dialog-ebdb9500.js} +70 -58
- package/_internal/components/{dialog-7dbcb485.js.map → dialog-ebdb9500.js.map} +1 -1
- package/_internal/components/{divider-12e9b6a0.js → divider-116af6b9.js} +7 -10
- package/_internal/components/{divider-12e9b6a0.js.map → divider-116af6b9.js.map} +1 -1
- package/_internal/components/{drag-handle-a38ff757.js → drag-handle-5215cd21.js} +14 -16
- package/_internal/components/{drag-handle-a38ff757.js.map → drag-handle-5215cd21.js.map} +1 -1
- package/_internal/components/{dropdown-38b0b6a0.js → dropdown-0baed51b.js} +15 -16
- package/_internal/components/{dropdown-38b0b6a0.js.map → dropdown-0baed51b.js.map} +1 -1
- package/_internal/components/{expansion-panel-c4b93653.js → expansion-panel-5533a680.js} +48 -39
- package/_internal/components/{expansion-panel-c4b93653.js.map → expansion-panel-5533a680.js.map} +1 -1
- package/_internal/components/{flag-c5e2f5f0.js → flag-8d4a7e72.js} +20 -16
- package/_internal/components/{flag-c5e2f5f0.js.map → flag-8d4a7e72.js.map} +1 -1
- package/_internal/components/{flex-box-c8701a85.js → flex-box-55144e5f.js} +9 -11
- package/_internal/components/{flex-box-c8701a85.js.map → flex-box-55144e5f.js.map} +1 -1
- package/_internal/components/{generic-block-0d6ad5a6.js → generic-block-ff0509ee.js} +35 -26
- package/_internal/components/{generic-block-0d6ad5a6.js.map → generic-block-ff0509ee.js.map} +1 -1
- package/_internal/components/{grid-3b194fe8.js → grid-6f1b5a41.js} +15 -20
- package/_internal/components/{grid-3b194fe8.js.map → grid-6f1b5a41.js.map} +1 -1
- package/_internal/components/{grid-column-985b9327.js → grid-column-f01df853.js} +8 -9
- package/_internal/components/{grid-column-985b9327.js.map → grid-column-f01df853.js.map} +1 -1
- package/_internal/components/{heading-5e954dfc.js → heading-89239843.js} +11 -12
- package/_internal/components/{heading-5e954dfc.js.map → heading-89239843.js.map} +1 -1
- package/_internal/components/{icon-2e7345ad.js → icon-b708cca4.js} +24 -25
- package/_internal/components/{icon-2e7345ad.js.map → icon-b708cca4.js.map} +1 -1
- package/_internal/components/{image-block-8d21dd7e.js → image-block-7938422d.js} +35 -34
- package/_internal/components/{image-block-8d21dd7e.js.map → image-block-7938422d.js.map} +1 -1
- package/_internal/components/{image-lightbox-4a5ab962.js → image-lightbox-58331704.js} +113 -100
- package/_internal/components/{image-lightbox-4a5ab962.js.map → image-lightbox-58331704.js.map} +1 -1
- package/_internal/components/{inline-list-4884f004.js → inline-list-e6f19a98.js} +24 -24
- package/_internal/components/{inline-list-4884f004.js.map → inline-list-e6f19a98.js.map} +1 -1
- package/_internal/components/{input-helper-e644e05e.js → input-helper-64153099.js} +9 -11
- package/_internal/components/{input-helper-e644e05e.js.map → input-helper-64153099.js.map} +1 -1
- package/_internal/components/{input-label-5e509a1b.js → input-label-2feb0bb0.js} +9 -11
- package/_internal/components/{input-label-5e509a1b.js.map → input-label-2feb0bb0.js.map} +1 -1
- package/_internal/components/{lightbox-bec1b95f.js → lightbox-570ad9e5.js} +55 -49
- package/_internal/components/{lightbox-bec1b95f.js.map → lightbox-570ad9e5.js.map} +1 -1
- package/_internal/components/{link-9637b9e4.js → link-91f76477.js} +25 -23
- package/_internal/components/{link-9637b9e4.js.map → link-91f76477.js.map} +1 -1
- package/_internal/components/link-preview-fdd8d738.js +117 -0
- package/_internal/components/{link-preview-7a4a6e4b.js.map → link-preview-fdd8d738.js.map} +1 -1
- package/_internal/components/{list-5c8f7122.js → list-b08d8423.js} +14 -20
- package/_internal/components/{list-5c8f7122.js.map → list-b08d8423.js.map} +1 -1
- package/_internal/components/{message-a67067d9.js → message-29cb9181.js} +24 -24
- package/_internal/components/{message-a67067d9.js.map → message-29cb9181.js.map} +1 -1
- package/_internal/components/{mosaic-92b66c80.js → mosaic-cdb9f563.js} +36 -33
- package/_internal/components/{mosaic-92b66c80.js.map → mosaic-cdb9f563.js.map} +1 -1
- package/_internal/components/navigation-8b7d9bd8.js +225 -0
- package/_internal/components/{navigation-4fd3917d.js.map → navigation-8b7d9bd8.js.map} +1 -1
- package/_internal/components/{notification-9063c963.js → notification-a45fda96.js} +45 -40
- package/_internal/components/{notification-9063c963.js.map → notification-a45fda96.js.map} +1 -1
- package/_internal/components/popover-65bfbc57.js +3 -0
- package/_internal/components/popover-65bfbc57.js.map +1 -0
- package/_internal/components/post-block-52e58dd5.js +109 -0
- package/_internal/components/{post-block-0cfc2206.js.map → post-block-52e58dd5.js.map} +1 -1
- package/_internal/components/{progress-eaf5b33d.js → progress-f39c3fa2.js} +44 -50
- package/_internal/components/{progress-eaf5b33d.js.map → progress-f39c3fa2.js.map} +1 -1
- package/_internal/components/{progress-tracker-4a65718d.js → progress-tracker-512d7a08.js} +59 -63
- package/_internal/components/{progress-tracker-4a65718d.js.map → progress-tracker-512d7a08.js.map} +1 -1
- package/_internal/components/{radio-button-3ef8a325.js → radio-button-559a4863.js} +54 -53
- package/_internal/components/{radio-button-3ef8a325.js.map → radio-button-559a4863.js.map} +1 -1
- package/_internal/components/select-48d4fa8c.js +454 -0
- package/_internal/components/{select-d46cfe35.js.map → select-48d4fa8c.js.map} +1 -1
- package/_internal/components/{side-navigation-75b22f19.js → side-navigation-f9bc5b4e.js} +62 -56
- package/_internal/components/{side-navigation-75b22f19.js.map → side-navigation-f9bc5b4e.js.map} +1 -1
- package/_internal/components/{skeleton-361ce335.js → skeleton-c66516ee.js} +23 -31
- package/_internal/components/{skeleton-361ce335.js.map → skeleton-c66516ee.js.map} +1 -1
- package/_internal/components/{slider-8094cb5c.js → slider-efbfbc45.js} +62 -56
- package/_internal/components/{slider-8094cb5c.js.map → slider-efbfbc45.js.map} +1 -1
- package/_internal/components/{slideshow-2e8cd372.js → slideshow-dd312470.js} +39 -38
- package/_internal/components/{slideshow-2e8cd372.js.map → slideshow-dd312470.js.map} +1 -1
- package/_internal/components/{switch-5516949b.js → switch-769a2a04.js} +49 -45
- package/_internal/components/{switch-5516949b.js.map → switch-769a2a04.js.map} +1 -1
- package/_internal/components/{table-fa198ee6.js → table-8617b1ba.js} +68 -73
- package/_internal/components/{table-fa198ee6.js.map → table-8617b1ba.js.map} +1 -1
- package/_internal/components/{tabs-bb9bc2a5.js → tabs-884c57b6.js} +41 -41
- package/_internal/components/{tabs-bb9bc2a5.js.map → tabs-884c57b6.js.map} +1 -1
- package/_internal/components/text-c7b1e079.js +2 -0
- package/_internal/components/text-c7b1e079.js.map +1 -0
- package/_internal/components/{text-field-82733568.js → text-field-478acd86.js} +116 -103
- package/_internal/components/{text-field-82733568.js.map → text-field-478acd86.js.map} +1 -1
- package/_internal/components/{thumbnail-e3acff82.js → thumbnail-310a4c4b.js} +2 -2
- package/_internal/components/{thumbnail-e3acff82.js.map → thumbnail-310a4c4b.js.map} +1 -1
- package/_internal/components/{toolbar-155562be.js → toolbar-a43533a2.js} +18 -17
- package/_internal/components/{toolbar-155562be.js.map → toolbar-a43533a2.js.map} +1 -1
- package/_internal/components/{tooltip-84ffb4f9.js → tooltip-2885ab2e.js} +44 -35
- package/_internal/components/{tooltip-84ffb4f9.js.map → tooltip-2885ab2e.js.map} +1 -1
- package/_internal/components/{uploader-896a1d89.js → uploader-1e7f5bbb.js} +35 -32
- package/_internal/components/{uploader-896a1d89.js.map → uploader-1e7f5bbb.js.map} +1 -1
- package/_internal/components/{user-block-8fd15895.js → user-block-68a51ed0.js} +43 -41
- package/_internal/components/{user-block-8fd15895.js.map → user-block-68a51ed0.js.map} +1 -1
- package/_internal/{context-21aeb1c7.js → context-9d1336a1.js} +6 -6
- package/_internal/{context-21aeb1c7.js.map → context-9d1336a1.js.map} +1 -1
- package/_internal/{forwardRef-49d2bb84.js → forwardRef-15f62847.js} +2 -12
- package/_internal/{forwardRef-49d2bb84.js.map → forwardRef-15f62847.js.map} +1 -1
- package/_internal/{index-f415b08e.js → index-9df37c0d.js} +45 -39
- package/_internal/{index-f415b08e.js.map → index-9df37c0d.js.map} +1 -1
- package/_internal/{index-b4d256e7.js → index-a9c5cd69.js} +10 -11
- package/_internal/{index-b4d256e7.js.map → index-a9c5cd69.js.map} +1 -1
- package/_internal/{useDisableStateProps-fffc365f.js → useDisableStateProps-69e16b7c.js} +2 -2
- package/_internal/{useDisableStateProps-fffc365f.js.map → useDisableStateProps-69e16b7c.js.map} +1 -1
- package/_internal/{wrapChildrenIconWithSpaces-f86106ce.js → wrapChildrenIconWithSpaces-c1faaae4.js} +2 -2
- package/_internal/{wrapChildrenIconWithSpaces-f86106ce.js.map → wrapChildrenIconWithSpaces-c1faaae4.js.map} +1 -1
- package/index.js +61 -61
- package/package.json +3 -3
- package/utils/index.js +3 -3
- package/_internal/ImageCaption-4279b2b6.js +0 -65
- package/_internal/components/comment-block-b84c4694.js +0 -121
- package/_internal/components/date-picker-a425534c.js +0 -2
- package/_internal/components/date-picker-a425534c.js.map +0 -1
- package/_internal/components/link-preview-7a4a6e4b.js +0 -108
- package/_internal/components/navigation-4fd3917d.js +0 -210
- package/_internal/components/popover-3c4c54bd.js +0 -3
- package/_internal/components/popover-3c4c54bd.js.map +0 -1
- package/_internal/components/post-block-0cfc2206.js +0 -99
- package/_internal/components/select-d46cfe35.js +0 -404
- package/_internal/components/text-289c0526.js +0 -2
- package/_internal/components/text-289c0526.js.map +0 -1
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { f as forwardRef, c as classNames, _ as _extends } from '../forwardRef-49d2bb84.js';
|
|
2
1
|
import { useRef, useState, useEffect } from 'react';
|
|
2
|
+
import { f as forwardRef, c as classNames } from '../forwardRef-15f62847.js';
|
|
3
3
|
import get from 'lodash/get';
|
|
4
4
|
import { mdiAlertCircle, mdiCheckCircle, mdiCloseCircle } from '@lumx/icons';
|
|
5
5
|
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
6
6
|
import { m as mergeRefs } from '../mergeRefs-f0d7d6ea.js';
|
|
7
7
|
import { u as useId } from '../useId-3a1facc0.js';
|
|
8
8
|
import { u as useTheme } from '../ThemeContext-3181f000.js';
|
|
9
|
-
import { u as useDisableStateProps } from '../useDisableStateProps-
|
|
9
|
+
import { u as useDisableStateProps } from '../useDisableStateProps-69e16b7c.js';
|
|
10
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
10
11
|
import { Theme, Size, Emphasis, Kind } from '@lumx/core/js/constants';
|
|
11
|
-
import { InputLabel } from './input-label-
|
|
12
|
-
import { Icon } from './icon-
|
|
13
|
-
import { I as IconButton } from '../IconButton-
|
|
14
|
-
import { InputHelper } from './input-helper-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Defines the props of the component.
|
|
18
|
-
*/
|
|
12
|
+
import { InputLabel } from './input-label-2feb0bb0.js';
|
|
13
|
+
import { Icon } from './icon-b708cca4.js';
|
|
14
|
+
import { I as IconButton } from '../IconButton-f4df224c.js';
|
|
15
|
+
import { InputHelper } from './input-helper-64153099.js';
|
|
19
16
|
|
|
20
17
|
/**
|
|
21
18
|
* Component display name.
|
|
@@ -137,7 +134,9 @@ const renderInputNative = props => {
|
|
|
137
134
|
} else {
|
|
138
135
|
inputProps.type = type;
|
|
139
136
|
}
|
|
140
|
-
return /*#__PURE__*/
|
|
137
|
+
return /*#__PURE__*/jsx(Component, {
|
|
138
|
+
...inputProps
|
|
139
|
+
});
|
|
141
140
|
};
|
|
142
141
|
|
|
143
142
|
/**
|
|
@@ -230,7 +229,7 @@ const TextField = forwardRef((props, ref) => {
|
|
|
230
229
|
inputElement.current.focus();
|
|
231
230
|
}
|
|
232
231
|
};
|
|
233
|
-
return /*#__PURE__*/
|
|
232
|
+
return /*#__PURE__*/jsxs("div", {
|
|
234
233
|
ref: ref,
|
|
235
234
|
className: classNames(className, handleBasicClasses({
|
|
236
235
|
hasChips: Boolean(chips),
|
|
@@ -247,100 +246,114 @@ const TextField = forwardRef((props, ref) => {
|
|
|
247
246
|
isValid,
|
|
248
247
|
prefix: CLASSNAME,
|
|
249
248
|
theme
|
|
250
|
-
}))
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
249
|
+
})),
|
|
250
|
+
children: [(label || maxLength) && /*#__PURE__*/jsxs("div", {
|
|
251
|
+
className: `${CLASSNAME}__header`,
|
|
252
|
+
children: [label && /*#__PURE__*/jsx(InputLabel, {
|
|
253
|
+
...labelProps,
|
|
254
|
+
htmlFor: textFieldId,
|
|
255
|
+
className: `${CLASSNAME}__label`,
|
|
256
|
+
isRequired: isRequired,
|
|
257
|
+
theme: theme,
|
|
258
|
+
children: label
|
|
259
|
+
}), maxLength && /*#__PURE__*/jsxs("div", {
|
|
260
|
+
className: `${CLASSNAME}__char-counter`,
|
|
261
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
262
|
+
children: maxLength - valueLength
|
|
263
|
+
}), maxLength - valueLength === 0 && /*#__PURE__*/jsx(Icon, {
|
|
264
|
+
icon: mdiAlertCircle,
|
|
265
|
+
size: Size.xxs
|
|
266
|
+
})]
|
|
267
|
+
})]
|
|
268
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
269
|
+
className: `${CLASSNAME}__wrapper`,
|
|
270
|
+
ref: textFieldRef,
|
|
271
|
+
children: [icon && /*#__PURE__*/jsx(Icon, {
|
|
272
|
+
className: `${CLASSNAME}__input-icon`,
|
|
273
|
+
color: theme === Theme.dark ? 'light' : undefined,
|
|
274
|
+
icon: icon,
|
|
275
|
+
size: Size.xs
|
|
276
|
+
}), chips && /*#__PURE__*/jsxs("div", {
|
|
277
|
+
className: `${CLASSNAME}__chips`,
|
|
278
|
+
children: [chips, renderInputNative({
|
|
279
|
+
id: textFieldId,
|
|
280
|
+
inputRef,
|
|
281
|
+
...disabledStateProps,
|
|
282
|
+
isRequired,
|
|
283
|
+
maxLength,
|
|
284
|
+
multiline,
|
|
285
|
+
onBlur,
|
|
286
|
+
onChange,
|
|
287
|
+
onFocus,
|
|
288
|
+
placeholder,
|
|
289
|
+
recomputeNumberOfRows,
|
|
290
|
+
rows,
|
|
291
|
+
setFocus,
|
|
292
|
+
type,
|
|
293
|
+
value,
|
|
294
|
+
name,
|
|
295
|
+
hasError,
|
|
296
|
+
describedById,
|
|
297
|
+
...forwardedProps
|
|
298
|
+
})]
|
|
299
|
+
}), !chips && /*#__PURE__*/jsx("div", {
|
|
300
|
+
className: `${CLASSNAME}__input-wrapper`,
|
|
301
|
+
children: renderInputNative({
|
|
302
|
+
id: textFieldId,
|
|
303
|
+
inputRef,
|
|
304
|
+
...disabledStateProps,
|
|
305
|
+
isRequired,
|
|
306
|
+
maxLength,
|
|
307
|
+
multiline,
|
|
308
|
+
onBlur,
|
|
309
|
+
onChange,
|
|
310
|
+
onFocus,
|
|
311
|
+
placeholder,
|
|
312
|
+
recomputeNumberOfRows,
|
|
313
|
+
rows,
|
|
314
|
+
setFocus,
|
|
315
|
+
type,
|
|
316
|
+
value,
|
|
317
|
+
name,
|
|
318
|
+
hasError,
|
|
319
|
+
describedById,
|
|
320
|
+
...forwardedProps
|
|
321
|
+
})
|
|
322
|
+
}), (isValid || hasError) && /*#__PURE__*/jsx(Icon, {
|
|
323
|
+
className: `${CLASSNAME}__input-validity`,
|
|
324
|
+
color: theme === Theme.dark ? 'light' : undefined,
|
|
325
|
+
icon: isValid ? mdiCheckCircle : mdiAlertCircle,
|
|
326
|
+
size: Size.xxs
|
|
327
|
+
}), clearButtonProps && isNotEmpty && !isAnyDisabled && /*#__PURE__*/jsx(IconButton, {
|
|
328
|
+
...clearButtonProps,
|
|
329
|
+
className: `${CLASSNAME}__input-clear`,
|
|
330
|
+
icon: mdiCloseCircle,
|
|
331
|
+
emphasis: Emphasis.low,
|
|
332
|
+
size: Size.s,
|
|
333
|
+
theme: theme,
|
|
334
|
+
onClick: handleClear,
|
|
335
|
+
type: "button"
|
|
336
|
+
}), afterElement && /*#__PURE__*/jsx("div", {
|
|
337
|
+
className: `${CLASSNAME}__after-element`,
|
|
338
|
+
children: afterElement
|
|
339
|
+
})]
|
|
340
|
+
}), hasError && error && /*#__PURE__*/jsx(InputHelper, {
|
|
341
|
+
className: `${CLASSNAME}__helper`,
|
|
342
|
+
kind: Kind.error,
|
|
343
|
+
theme: theme,
|
|
344
|
+
id: errorId,
|
|
345
|
+
children: error
|
|
346
|
+
}), helper && /*#__PURE__*/jsx(InputHelper, {
|
|
347
|
+
className: `${CLASSNAME}__helper`,
|
|
348
|
+
theme: theme,
|
|
349
|
+
id: helperId,
|
|
350
|
+
children: helper
|
|
351
|
+
})]
|
|
352
|
+
});
|
|
340
353
|
});
|
|
341
354
|
TextField.displayName = COMPONENT_NAME;
|
|
342
355
|
TextField.className = CLASSNAME;
|
|
343
356
|
TextField.defaultProps = DEFAULT_PROPS;
|
|
344
357
|
|
|
345
358
|
export { TextField };
|
|
346
|
-
//# sourceMappingURL=text-field-
|
|
359
|
+
//# sourceMappingURL=text-field-478acd86.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-field-82733568.js","sources":["../../../src/components/text-field/TextField.tsx"],"sourcesContent":["import { ReactNode, Ref, RefObject, SyntheticEvent, useEffect, useRef, useState } from 'react';\n\nimport classNames from 'classnames';\nimport get from 'lodash/get';\n\nimport { mdiAlertCircle, mdiCheckCircle, mdiCloseCircle } from '@lumx/icons';\nimport {\n Emphasis,\n Icon,\n IconButton,\n IconButtonProps,\n InputHelper,\n InputLabel,\n InputLabelProps,\n Kind,\n Size,\n Theme,\n} from '@lumx/react';\nimport { GenericProps, HasTheme } from '@lumx/react/utils/type';\nimport { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';\nimport { mergeRefs } from '@lumx/react/utils/react/mergeRefs';\nimport { useId } from '@lumx/react/hooks/useId';\nimport { useTheme } from '@lumx/react/utils/theme/ThemeContext';\nimport { forwardRef } from '@lumx/react/utils/react/forwardRef';\nimport { useDisableStateProps } from '@lumx/react/utils/disabled/useDisableStateProps';\nimport { HasAriaDisabled } from '@lumx/react/utils/type/HasAriaDisabled';\n\n/**\n * Defines the props of the component.\n */\nexport interface TextFieldProps extends GenericProps, HasTheme, HasAriaDisabled {\n /** Chip Group to be rendered before the main text input. */\n chips?: ReactNode;\n /** Props to pass to the clear button (minus those already set by the TextField props). If not specified, the button won't be displayed. */\n clearButtonProps?: Pick<IconButtonProps, 'label'> &\n Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis'>;\n /** Error message. */\n error?: string | ReactNode;\n /** Whether we force the focus style or not. */\n forceFocusStyle?: boolean;\n /** Whether the text field is displayed with error style or not. */\n hasError?: boolean;\n /** Additional element to put at the end of the text field. */\n afterElement?: ReactNode;\n /** Helper text. */\n helper?: string | ReactNode;\n /** Icon (SVG path). */\n icon?: string;\n /** Native input id property (generated if not provided to link the label element). */\n id?: string;\n /** Reference to the <input> or <textarea> element. */\n inputRef?: Ref<HTMLInputElement | HTMLTextAreaElement>;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Whether the component is required or not. */\n isRequired?: boolean;\n /** Whether the text field is displayed with valid style or not. */\n isValid?: boolean;\n /** Label text. */\n label?: string;\n /** Additional label props. */\n labelProps?: InputLabelProps;\n /** Max string length the input accepts (constrains the input and displays a character counter). */\n maxLength?: number;\n /** Minimum number of rows displayed in multiline mode (requires `multiline` to be enabled). */\n minimumRows?: number;\n /** Whether the text field is a textarea or an input. */\n multiline?: boolean;\n /** Native input name property. */\n name?: string;\n /** Placeholder text. */\n placeholder?: string;\n /** Reference to the wrapper. */\n textFieldRef?: Ref<HTMLDivElement>;\n /** Native input type (only when `multiline` is disabled). */\n type?: React.ComponentProps<'input'>['type'];\n /** Value. */\n value?: string;\n /** On blur callback. */\n onBlur?(event: React.FocusEvent): void;\n /** On change callback. */\n onChange(value: string, name?: string, event?: SyntheticEvent): void;\n /** On clear callback. */\n onClear?(event?: SyntheticEvent): void;\n /** On focus callback. */\n onFocus?(event: React.FocusEvent): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'TextField';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Default minimum number of rows in the multiline mode.\n */\nconst DEFAULT_MIN_ROWS = 2;\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<TextFieldProps> = {\n type: 'text',\n};\n\n/**\n * Hook that allows to calculate the number of rows needed for a text area.\n * @param minimumRows Minimum number of rows that we want to display.\n * @return rows to be used and a callback to recalculate\n */\nconst useComputeNumberOfRows = (\n minimumRows: number,\n): {\n /** number of rows to be used on the text area */\n rows: number;\n /**\n * Callback in order to recalculate the number of rows due to a change on the text area\n */\n recomputeNumberOfRows(target: Element): void;\n} => {\n const [rows, setRows] = useState(minimumRows);\n\n const recompute = (target: Element) => {\n /**\n * HEAD's UP! This part is a little bit tricky. The idea here is to only\n * display the necessary rows on the textarea. In order to dynamically adjust\n * the height on that field, we need to:\n * 1. Set the current amount of rows to the minimum. That will make the scroll appear.\n * 2. With that, we will have the `scrollHeight`, meaning the height of the container adjusted to the current content\n * 3. With the scroll height, we can figure out how many rows we need to use by dividing the scroll height\n * by the line height.\n * 4. With that number, we can readjust the number of rows on the text area. We need to do that here, if we leave that to\n * the state change through React, there are some scenarios (resize, hitting ENTER or BACKSPACE which add or remove lines)\n * when we will not see the update and the rows will be resized to the minimum.\n * 5. In case there is any other update on the component that changes the UI, we need to keep the number of rows\n * on the state in order to allow React to re-render. Therefore, we save them using `useState`\n */\n // eslint-disable-next-line no-param-reassign\n (target as HTMLTextAreaElement).rows = minimumRows;\n let currentRows = target.scrollHeight / (target.clientHeight / minimumRows);\n currentRows = currentRows >= minimumRows ? currentRows : minimumRows;\n // eslint-disable-next-line no-param-reassign\n (target as HTMLTextAreaElement).rows = currentRows;\n\n setRows(currentRows);\n };\n\n return {\n recomputeNumberOfRows: recompute,\n rows,\n };\n};\n\ninterface InputNativeProps {\n id?: string;\n inputRef?: TextFieldProps['inputRef'];\n isDisabled?: boolean;\n 'aria-disabled'?: boolean;\n isRequired?: boolean;\n readOnly?: boolean;\n multiline?: boolean;\n maxLength?: number;\n placeholder?: string;\n rows: number;\n type: TextFieldProps['type'];\n name?: string;\n value?: string;\n setFocus(focus: boolean): void;\n recomputeNumberOfRows(target: Element): void;\n onChange(value: string, name?: string, event?: SyntheticEvent): void;\n onFocus?(value: React.FocusEvent): void;\n onBlur?(value: React.FocusEvent): void;\n hasError?: boolean;\n describedById?: string;\n}\n\nconst renderInputNative: React.FC<InputNativeProps> = (props) => {\n const {\n id,\n isRequired,\n placeholder,\n multiline,\n value,\n setFocus,\n onChange,\n onFocus,\n onBlur,\n inputRef,\n rows,\n recomputeNumberOfRows,\n type,\n name,\n hasError,\n describedById,\n ...forwardedProps\n } = props;\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const ref = useRef<HTMLElement>(null);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useEffect(() => {\n // Recompute the number of rows for the first rendering\n if (multiline && ref && ref.current) {\n recomputeNumberOfRows(ref.current);\n }\n }, [ref, multiline, recomputeNumberOfRows, value]);\n\n const onTextFieldFocus = (event: React.FocusEvent) => {\n onFocus?.(event);\n setFocus(true);\n };\n\n const onTextFieldBlur = (event: React.FocusEvent) => {\n onBlur?.(event);\n setFocus(false);\n };\n\n const handleChange = (event: React.ChangeEvent) => {\n onChange(get(event, 'target.value'), name, event);\n };\n\n const Component = multiline ? 'textarea' : 'input';\n const inputProps: any = {\n ...forwardedProps,\n id,\n className: multiline\n ? `${CLASSNAME}__input-native ${CLASSNAME}__input-native--textarea`\n : `${CLASSNAME}__input-native ${CLASSNAME}__input-native--text`,\n placeholder,\n value,\n name,\n required: isRequired,\n onFocus: onTextFieldFocus,\n onBlur: onTextFieldBlur,\n onChange: handleChange,\n 'aria-invalid': hasError ? 'true' : undefined,\n 'aria-describedby': describedById,\n readOnly: forwardedProps.readOnly || forwardedProps['aria-disabled'],\n ref: mergeRefs(inputRef as any, ref) as any,\n };\n if (multiline) {\n inputProps.rows = rows;\n } else {\n inputProps.type = type;\n }\n return <Component {...inputProps} />;\n};\n\n/**\n * TextField component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const TextField = forwardRef<TextFieldProps, HTMLDivElement>((props, ref) => {\n const { isAnyDisabled, disabledStateProps, otherProps } = useDisableStateProps(props);\n const defaultTheme = useTheme() || Theme.light;\n const {\n chips,\n className,\n clearButtonProps,\n error,\n forceFocusStyle,\n hasError,\n helper,\n icon,\n id,\n inputRef: inputRefProps,\n isRequired,\n isValid,\n label,\n labelProps,\n maxLength,\n minimumRows,\n multiline,\n name,\n onBlur,\n onChange,\n onClear,\n onFocus,\n placeholder,\n textFieldRef,\n theme = defaultTheme,\n type = DEFAULT_PROPS.type,\n value,\n afterElement,\n ...forwardedProps\n } = otherProps;\n const generatedTextFieldId = useId();\n const textFieldId = id || generatedTextFieldId;\n /** Keep a clean local input ref to manage focus */\n const localInputRef = useRef<HTMLInputElement | HTMLTextAreaElement | null>(null);\n /** Merge prop input ref and local input ref */\n const inputRef = mergeRefs(localInputRef, inputRefProps);\n /**\n * Generate unique ids for both the helper and error texts, in order to\n * later on add them to the input native as aria-describedby. If both the error and the helper are present,\n * we want to first use the most important one, which is the errorId. That way, screen readers will read first\n * the error and then the helper\n */\n const helperId = helper ? `text-field-helper-${generatedTextFieldId}` : undefined;\n const errorId = error ? `text-field-error-${generatedTextFieldId}` : undefined;\n const describedByIds = [errorId, helperId, forwardedProps['aria-describedby']].filter(Boolean);\n const describedById = describedByIds.length === 0 ? undefined : describedByIds.join(' ');\n\n const [isFocus, setFocus] = useState(false);\n const { rows, recomputeNumberOfRows } = useComputeNumberOfRows(multiline ? minimumRows || DEFAULT_MIN_ROWS : 0);\n const valueLength = (value || '').length;\n const isNotEmpty = valueLength > 0;\n\n /**\n * Function triggered when the Clear Button is clicked.\n * The idea is to execute the `onChange` callback with an empty string\n * and remove focus from the clear button.\n * @param evt On clear event.\n */\n const handleClear = (evt: React.ChangeEvent) => {\n evt.nativeEvent.preventDefault();\n evt.nativeEvent.stopPropagation();\n (evt.currentTarget as HTMLElement).blur();\n\n onChange('');\n\n if (onClear) {\n onClear(evt);\n }\n\n /** Use local inputRef in case the prop input ref is a `mergeRefs` function. */\n const inputElement = localInputRef as RefObject<HTMLInputElement | HTMLTextAreaElement>;\n\n if (inputElement && inputElement.current) {\n inputElement.current.focus();\n }\n };\n\n return (\n <div\n ref={ref}\n className={classNames(\n className,\n handleBasicClasses({\n hasChips: Boolean(chips),\n hasError: !isValid && hasError,\n hasIcon: Boolean(icon),\n hasInput: !multiline,\n hasInputClear: clearButtonProps && isNotEmpty,\n hasLabel: Boolean(label),\n hasPlaceholder: Boolean(placeholder),\n hasTextarea: multiline,\n hasValue: Boolean(value),\n isDisabled: isAnyDisabled,\n isFocus: isFocus || forceFocusStyle,\n isValid,\n prefix: CLASSNAME,\n theme,\n }),\n )}\n >\n {(label || maxLength) && (\n <div className={`${CLASSNAME}__header`}>\n {label && (\n <InputLabel\n {...labelProps}\n htmlFor={textFieldId}\n className={`${CLASSNAME}__label`}\n isRequired={isRequired}\n theme={theme}\n >\n {label}\n </InputLabel>\n )}\n\n {maxLength && (\n <div className={`${CLASSNAME}__char-counter`}>\n <span>{maxLength - valueLength}</span>\n {maxLength - valueLength === 0 && <Icon icon={mdiAlertCircle} size={Size.xxs} />}\n </div>\n )}\n </div>\n )}\n\n <div className={`${CLASSNAME}__wrapper`} ref={textFieldRef}>\n {icon && (\n <Icon\n className={`${CLASSNAME}__input-icon`}\n color={theme === Theme.dark ? 'light' : undefined}\n icon={icon}\n size={Size.xs}\n />\n )}\n\n {chips && (\n <div className={`${CLASSNAME}__chips`}>\n {chips}\n\n {renderInputNative({\n id: textFieldId,\n inputRef,\n ...disabledStateProps,\n isRequired,\n maxLength,\n multiline,\n onBlur,\n onChange,\n onFocus,\n placeholder,\n recomputeNumberOfRows,\n rows,\n setFocus,\n type,\n value,\n name,\n hasError,\n describedById,\n ...forwardedProps,\n })}\n </div>\n )}\n\n {!chips && (\n <div className={`${CLASSNAME}__input-wrapper`}>\n {renderInputNative({\n id: textFieldId,\n inputRef,\n ...disabledStateProps,\n isRequired,\n maxLength,\n multiline,\n onBlur,\n onChange,\n onFocus,\n placeholder,\n recomputeNumberOfRows,\n rows,\n setFocus,\n type,\n value,\n name,\n hasError,\n describedById,\n ...forwardedProps,\n })}\n </div>\n )}\n\n {(isValid || hasError) && (\n <Icon\n className={`${CLASSNAME}__input-validity`}\n color={theme === Theme.dark ? 'light' : undefined}\n icon={isValid ? mdiCheckCircle : mdiAlertCircle}\n size={Size.xxs}\n />\n )}\n\n {clearButtonProps && isNotEmpty && !isAnyDisabled && (\n <IconButton\n {...clearButtonProps}\n className={`${CLASSNAME}__input-clear`}\n icon={mdiCloseCircle}\n emphasis={Emphasis.low}\n size={Size.s}\n theme={theme}\n onClick={handleClear}\n type=\"button\"\n />\n )}\n\n {afterElement && <div className={`${CLASSNAME}__after-element`}>{afterElement}</div>}\n </div>\n\n {hasError && error && (\n <InputHelper className={`${CLASSNAME}__helper`} kind={Kind.error} theme={theme} id={errorId}>\n {error}\n </InputHelper>\n )}\n\n {helper && (\n <InputHelper className={`${CLASSNAME}__helper`} theme={theme} id={helperId}>\n {helper}\n </InputHelper>\n )}\n </div>\n );\n});\nTextField.displayName = COMPONENT_NAME;\nTextField.className = CLASSNAME;\nTextField.defaultProps = DEFAULT_PROPS;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_MIN_ROWS","DEFAULT_PROPS","type","useComputeNumberOfRows","minimumRows","rows","setRows","useState","recompute","target","currentRows","scrollHeight","clientHeight","recomputeNumberOfRows","renderInputNative","props","id","isRequired","placeholder","multiline","value","setFocus","onChange","onFocus","onBlur","inputRef","name","hasError","describedById","forwardedProps","ref","useRef","useEffect","current","onTextFieldFocus","event","onTextFieldBlur","handleChange","get","Component","inputProps","className","required","undefined","readOnly","mergeRefs","React","createElement","TextField","forwardRef","isAnyDisabled","disabledStateProps","otherProps","useDisableStateProps","defaultTheme","useTheme","Theme","light","chips","clearButtonProps","error","forceFocusStyle","helper","icon","inputRefProps","isValid","label","labelProps","maxLength","onClear","textFieldRef","theme","afterElement","generatedTextFieldId","useId","textFieldId","localInputRef","helperId","errorId","describedByIds","filter","Boolean","length","join","isFocus","valueLength","isNotEmpty","handleClear","evt","nativeEvent","preventDefault","stopPropagation","currentTarget","blur","inputElement","focus","classNames","handleBasicClasses","hasChips","hasIcon","hasInput","hasInputClear","hasLabel","hasPlaceholder","hasTextarea","hasValue","isDisabled","prefix","InputLabel","_extends","htmlFor","Icon","mdiAlertCircle","size","Size","xxs","color","dark","xs","mdiCheckCircle","IconButton","mdiCloseCircle","emphasis","Emphasis","low","s","onClick","InputHelper","kind","Kind","displayName","defaultProps"],"mappings":";;;;;;;;;;;;;;;AA2BA;AACA;AACA;;AA2DA;AACA;AACA;AACA,MAAMA,cAAc,GAAG,WAAW,CAAA;;AAElC;AACA;AACA;AACA,MAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAc,CAAC,CAAA;;AAElD;AACA;AACA;AACA,MAAMG,gBAAgB,GAAG,CAAC,CAAA;;AAE1B;AACA;AACA;AACA,MAAMC,aAAsC,GAAG;AAC3CC,EAAAA,IAAI,EAAE,MAAA;AACV,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMC,sBAAsB,GACxBC,WAAmB,IAQlB;EACD,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGC,QAAQ,CAACH,WAAW,CAAC,CAAA;EAE7C,MAAMI,SAAS,GAAIC,MAAe,IAAK;AACnC;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACQ;IACCA,MAAM,CAAyBJ,IAAI,GAAGD,WAAW,CAAA;IAClD,IAAIM,WAAW,GAAGD,MAAM,CAACE,YAAY,IAAIF,MAAM,CAACG,YAAY,GAAGR,WAAW,CAAC,CAAA;AAC3EM,IAAAA,WAAW,GAAGA,WAAW,IAAIN,WAAW,GAAGM,WAAW,GAAGN,WAAW,CAAA;AACpE;IACCK,MAAM,CAAyBJ,IAAI,GAAGK,WAAW,CAAA;IAElDJ,OAAO,CAACI,WAAW,CAAC,CAAA;GACvB,CAAA;EAED,OAAO;AACHG,IAAAA,qBAAqB,EAAEL,SAAS;AAChCH,IAAAA,IAAAA;GACH,CAAA;AACL,CAAC,CAAA;AAyB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AAACvD,IAAAA,EAAE,EAAE8D,OAAAA;GAC/ElB,EAAAA,KACQ,CAChB,EAEAE,MAAM,iBACHhB,KAAA,CAAAC,aAAA,CAACgF,WAAW,EAAA;IAACtF,SAAS,EAAE,CAAG3C,EAAAA,SAAS,CAAW,QAAA,CAAA;AAACyE,IAAAA,KAAK,EAAEA,KAAM;AAACvD,IAAAA,EAAE,EAAE6D,QAAAA;GAC7Df,EAAAA,MACQ,CAEhB,CAAC,CAAA;AAEd,CAAC,EAAC;AACFd,SAAS,CAACkF,WAAW,GAAGrI,cAAc,CAAA;AACtCmD,SAAS,CAACP,SAAS,GAAG3C,SAAS,CAAA;AAC/BkD,SAAS,CAACmF,YAAY,GAAGlI,aAAa;;;;"}
|
|
1
|
+
{"version":3,"file":"text-field-478acd86.js","sources":["../../../src/components/text-field/TextField.tsx"],"sourcesContent":["import { ReactNode, Ref, RefObject, SyntheticEvent, useEffect, useRef, useState } from 'react';\n\nimport classNames from 'classnames';\nimport get from 'lodash/get';\n\nimport { mdiAlertCircle, mdiCheckCircle, mdiCloseCircle } from '@lumx/icons';\nimport {\n Emphasis,\n Icon,\n IconButton,\n IconButtonProps,\n InputHelper,\n InputLabel,\n InputLabelProps,\n Kind,\n Size,\n Theme,\n} from '@lumx/react';\nimport { GenericProps, HasTheme } from '@lumx/react/utils/type';\nimport { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';\nimport { mergeRefs } from '@lumx/react/utils/react/mergeRefs';\nimport { useId } from '@lumx/react/hooks/useId';\nimport { useTheme } from '@lumx/react/utils/theme/ThemeContext';\nimport { forwardRef } from '@lumx/react/utils/react/forwardRef';\nimport { useDisableStateProps } from '@lumx/react/utils/disabled/useDisableStateProps';\nimport { HasAriaDisabled } from '@lumx/react/utils/type/HasAriaDisabled';\n\n/**\n * Defines the props of the component.\n */\nexport interface TextFieldProps extends GenericProps, HasTheme, HasAriaDisabled {\n /** Chip Group to be rendered before the main text input. */\n chips?: ReactNode;\n /** Props to pass to the clear button (minus those already set by the TextField props). If not specified, the button won't be displayed. */\n clearButtonProps?: Pick<IconButtonProps, 'label'> &\n Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis'>;\n /** Error message. */\n error?: string | ReactNode;\n /** Whether we force the focus style or not. */\n forceFocusStyle?: boolean;\n /** Whether the text field is displayed with error style or not. */\n hasError?: boolean;\n /** Additional element to put at the end of the text field. */\n afterElement?: ReactNode;\n /** Helper text. */\n helper?: string | ReactNode;\n /** Icon (SVG path). */\n icon?: string;\n /** Native input id property (generated if not provided to link the label element). */\n id?: string;\n /** Reference to the <input> or <textarea> element. */\n inputRef?: Ref<HTMLInputElement | HTMLTextAreaElement>;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Whether the component is required or not. */\n isRequired?: boolean;\n /** Whether the text field is displayed with valid style or not. */\n isValid?: boolean;\n /** Label text. */\n label?: string;\n /** Additional label props. */\n labelProps?: InputLabelProps;\n /** Max string length the input accepts (constrains the input and displays a character counter). */\n maxLength?: number;\n /** Minimum number of rows displayed in multiline mode (requires `multiline` to be enabled). */\n minimumRows?: number;\n /** Whether the text field is a textarea or an input. */\n multiline?: boolean;\n /** Native input name property. */\n name?: string;\n /** Placeholder text. */\n placeholder?: string;\n /** Reference to the wrapper. */\n textFieldRef?: Ref<HTMLDivElement>;\n /** Native input type (only when `multiline` is disabled). */\n type?: React.ComponentProps<'input'>['type'];\n /** Value. */\n value?: string;\n /** On blur callback. */\n onBlur?(event: React.FocusEvent): void;\n /** On change callback. */\n onChange(value: string, name?: string, event?: SyntheticEvent): void;\n /** On clear callback. */\n onClear?(event?: SyntheticEvent): void;\n /** On focus callback. */\n onFocus?(event: React.FocusEvent): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'TextField';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Default minimum number of rows in the multiline mode.\n */\nconst DEFAULT_MIN_ROWS = 2;\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<TextFieldProps> = {\n type: 'text',\n};\n\n/**\n * Hook that allows to calculate the number of rows needed for a text area.\n * @param minimumRows Minimum number of rows that we want to display.\n * @return rows to be used and a callback to recalculate\n */\nconst useComputeNumberOfRows = (\n minimumRows: number,\n): {\n /** number of rows to be used on the text area */\n rows: number;\n /**\n * Callback in order to recalculate the number of rows due to a change on the text area\n */\n recomputeNumberOfRows(target: Element): void;\n} => {\n const [rows, setRows] = useState(minimumRows);\n\n const recompute = (target: Element) => {\n /**\n * HEAD's UP! This part is a little bit tricky. The idea here is to only\n * display the necessary rows on the textarea. In order to dynamically adjust\n * the height on that field, we need to:\n * 1. Set the current amount of rows to the minimum. That will make the scroll appear.\n * 2. With that, we will have the `scrollHeight`, meaning the height of the container adjusted to the current content\n * 3. With the scroll height, we can figure out how many rows we need to use by dividing the scroll height\n * by the line height.\n * 4. With that number, we can readjust the number of rows on the text area. We need to do that here, if we leave that to\n * the state change through React, there are some scenarios (resize, hitting ENTER or BACKSPACE which add or remove lines)\n * when we will not see the update and the rows will be resized to the minimum.\n * 5. In case there is any other update on the component that changes the UI, we need to keep the number of rows\n * on the state in order to allow React to re-render. Therefore, we save them using `useState`\n */\n // eslint-disable-next-line no-param-reassign\n (target as HTMLTextAreaElement).rows = minimumRows;\n let currentRows = target.scrollHeight / (target.clientHeight / minimumRows);\n currentRows = currentRows >= minimumRows ? currentRows : minimumRows;\n // eslint-disable-next-line no-param-reassign\n (target as HTMLTextAreaElement).rows = currentRows;\n\n setRows(currentRows);\n };\n\n return {\n recomputeNumberOfRows: recompute,\n rows,\n };\n};\n\ninterface InputNativeProps {\n id?: string;\n inputRef?: TextFieldProps['inputRef'];\n isDisabled?: boolean;\n 'aria-disabled'?: boolean;\n isRequired?: boolean;\n readOnly?: boolean;\n multiline?: boolean;\n maxLength?: number;\n placeholder?: string;\n rows: number;\n type: TextFieldProps['type'];\n name?: string;\n value?: string;\n setFocus(focus: boolean): void;\n recomputeNumberOfRows(target: Element): void;\n onChange(value: string, name?: string, event?: SyntheticEvent): void;\n onFocus?(value: React.FocusEvent): void;\n onBlur?(value: React.FocusEvent): void;\n hasError?: boolean;\n describedById?: string;\n}\n\nconst renderInputNative: React.FC<InputNativeProps> = (props) => {\n const {\n id,\n isRequired,\n placeholder,\n multiline,\n value,\n setFocus,\n onChange,\n onFocus,\n onBlur,\n inputRef,\n rows,\n recomputeNumberOfRows,\n type,\n name,\n hasError,\n describedById,\n ...forwardedProps\n } = props;\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const ref = useRef<HTMLElement>(null);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useEffect(() => {\n // Recompute the number of rows for the first rendering\n if (multiline && ref && ref.current) {\n recomputeNumberOfRows(ref.current);\n }\n }, [ref, multiline, recomputeNumberOfRows, value]);\n\n const onTextFieldFocus = (event: React.FocusEvent) => {\n onFocus?.(event);\n setFocus(true);\n };\n\n const onTextFieldBlur = (event: React.FocusEvent) => {\n onBlur?.(event);\n setFocus(false);\n };\n\n const handleChange = (event: React.ChangeEvent) => {\n onChange(get(event, 'target.value'), name, event);\n };\n\n const Component = multiline ? 'textarea' : 'input';\n const inputProps: any = {\n ...forwardedProps,\n id,\n className: multiline\n ? `${CLASSNAME}__input-native ${CLASSNAME}__input-native--textarea`\n : `${CLASSNAME}__input-native ${CLASSNAME}__input-native--text`,\n placeholder,\n value,\n name,\n required: isRequired,\n onFocus: onTextFieldFocus,\n onBlur: onTextFieldBlur,\n onChange: handleChange,\n 'aria-invalid': hasError ? 'true' : undefined,\n 'aria-describedby': describedById,\n readOnly: forwardedProps.readOnly || forwardedProps['aria-disabled'],\n ref: mergeRefs(inputRef as any, ref) as any,\n };\n if (multiline) {\n inputProps.rows = rows;\n } else {\n inputProps.type = type;\n }\n return <Component {...inputProps} />;\n};\n\n/**\n * TextField component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const TextField = forwardRef<TextFieldProps, HTMLDivElement>((props, ref) => {\n const { isAnyDisabled, disabledStateProps, otherProps } = useDisableStateProps(props);\n const defaultTheme = useTheme() || Theme.light;\n const {\n chips,\n className,\n clearButtonProps,\n error,\n forceFocusStyle,\n hasError,\n helper,\n icon,\n id,\n inputRef: inputRefProps,\n isRequired,\n isValid,\n label,\n labelProps,\n maxLength,\n minimumRows,\n multiline,\n name,\n onBlur,\n onChange,\n onClear,\n onFocus,\n placeholder,\n textFieldRef,\n theme = defaultTheme,\n type = DEFAULT_PROPS.type,\n value,\n afterElement,\n ...forwardedProps\n } = otherProps;\n const generatedTextFieldId = useId();\n const textFieldId = id || generatedTextFieldId;\n /** Keep a clean local input ref to manage focus */\n const localInputRef = useRef<HTMLInputElement | HTMLTextAreaElement | null>(null);\n /** Merge prop input ref and local input ref */\n const inputRef = mergeRefs(localInputRef, inputRefProps);\n /**\n * Generate unique ids for both the helper and error texts, in order to\n * later on add them to the input native as aria-describedby. If both the error and the helper are present,\n * we want to first use the most important one, which is the errorId. That way, screen readers will read first\n * the error and then the helper\n */\n const helperId = helper ? `text-field-helper-${generatedTextFieldId}` : undefined;\n const errorId = error ? `text-field-error-${generatedTextFieldId}` : undefined;\n const describedByIds = [errorId, helperId, forwardedProps['aria-describedby']].filter(Boolean);\n const describedById = describedByIds.length === 0 ? undefined : describedByIds.join(' ');\n\n const [isFocus, setFocus] = useState(false);\n const { rows, recomputeNumberOfRows } = useComputeNumberOfRows(multiline ? minimumRows || DEFAULT_MIN_ROWS : 0);\n const valueLength = (value || '').length;\n const isNotEmpty = valueLength > 0;\n\n /**\n * Function triggered when the Clear Button is clicked.\n * The idea is to execute the `onChange` callback with an empty string\n * and remove focus from the clear button.\n * @param evt On clear event.\n */\n const handleClear = (evt: React.ChangeEvent) => {\n evt.nativeEvent.preventDefault();\n evt.nativeEvent.stopPropagation();\n (evt.currentTarget as HTMLElement).blur();\n\n onChange('');\n\n if (onClear) {\n onClear(evt);\n }\n\n /** Use local inputRef in case the prop input ref is a `mergeRefs` function. */\n const inputElement = localInputRef as RefObject<HTMLInputElement | HTMLTextAreaElement>;\n\n if (inputElement && inputElement.current) {\n inputElement.current.focus();\n }\n };\n\n return (\n <div\n ref={ref}\n className={classNames(\n className,\n handleBasicClasses({\n hasChips: Boolean(chips),\n hasError: !isValid && hasError,\n hasIcon: Boolean(icon),\n hasInput: !multiline,\n hasInputClear: clearButtonProps && isNotEmpty,\n hasLabel: Boolean(label),\n hasPlaceholder: Boolean(placeholder),\n hasTextarea: multiline,\n hasValue: Boolean(value),\n isDisabled: isAnyDisabled,\n isFocus: isFocus || forceFocusStyle,\n isValid,\n prefix: CLASSNAME,\n theme,\n }),\n )}\n >\n {(label || maxLength) && (\n <div className={`${CLASSNAME}__header`}>\n {label && (\n <InputLabel\n {...labelProps}\n htmlFor={textFieldId}\n className={`${CLASSNAME}__label`}\n isRequired={isRequired}\n theme={theme}\n >\n {label}\n </InputLabel>\n )}\n\n {maxLength && (\n <div className={`${CLASSNAME}__char-counter`}>\n <span>{maxLength - valueLength}</span>\n {maxLength - valueLength === 0 && <Icon icon={mdiAlertCircle} size={Size.xxs} />}\n </div>\n )}\n </div>\n )}\n\n <div className={`${CLASSNAME}__wrapper`} ref={textFieldRef}>\n {icon && (\n <Icon\n className={`${CLASSNAME}__input-icon`}\n color={theme === Theme.dark ? 'light' : undefined}\n icon={icon}\n size={Size.xs}\n />\n )}\n\n {chips && (\n <div className={`${CLASSNAME}__chips`}>\n {chips}\n\n {renderInputNative({\n id: textFieldId,\n inputRef,\n ...disabledStateProps,\n isRequired,\n maxLength,\n multiline,\n onBlur,\n onChange,\n onFocus,\n placeholder,\n recomputeNumberOfRows,\n rows,\n setFocus,\n type,\n value,\n name,\n hasError,\n describedById,\n ...forwardedProps,\n })}\n </div>\n )}\n\n {!chips && (\n <div className={`${CLASSNAME}__input-wrapper`}>\n {renderInputNative({\n id: textFieldId,\n inputRef,\n ...disabledStateProps,\n isRequired,\n maxLength,\n multiline,\n onBlur,\n onChange,\n onFocus,\n placeholder,\n recomputeNumberOfRows,\n rows,\n setFocus,\n type,\n value,\n name,\n hasError,\n describedById,\n ...forwardedProps,\n })}\n </div>\n )}\n\n {(isValid || hasError) && (\n <Icon\n className={`${CLASSNAME}__input-validity`}\n color={theme === Theme.dark ? 'light' : undefined}\n icon={isValid ? mdiCheckCircle : mdiAlertCircle}\n size={Size.xxs}\n />\n )}\n\n {clearButtonProps && isNotEmpty && !isAnyDisabled && (\n <IconButton\n {...clearButtonProps}\n className={`${CLASSNAME}__input-clear`}\n icon={mdiCloseCircle}\n emphasis={Emphasis.low}\n size={Size.s}\n theme={theme}\n onClick={handleClear}\n type=\"button\"\n />\n )}\n\n {afterElement && <div className={`${CLASSNAME}__after-element`}>{afterElement}</div>}\n </div>\n\n {hasError && error && (\n <InputHelper className={`${CLASSNAME}__helper`} kind={Kind.error} theme={theme} id={errorId}>\n {error}\n </InputHelper>\n )}\n\n {helper && (\n <InputHelper className={`${CLASSNAME}__helper`} theme={theme} id={helperId}>\n {helper}\n </InputHelper>\n )}\n </div>\n );\n});\nTextField.displayName = COMPONENT_NAME;\nTextField.className = CLASSNAME;\nTextField.defaultProps = DEFAULT_PROPS;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_MIN_ROWS","DEFAULT_PROPS","type","useComputeNumberOfRows","minimumRows","rows","setRows","useState","recompute","target","currentRows","scrollHeight","clientHeight","recomputeNumberOfRows","renderInputNative","props","id","isRequired","placeholder","multiline","value","setFocus","onChange","onFocus","onBlur","inputRef","name","hasError","describedById","forwardedProps","ref","useRef","useEffect","current","onTextFieldFocus","event","onTextFieldBlur","handleChange","get","Component","inputProps","className","required","undefined","readOnly","mergeRefs","_jsx","TextField","forwardRef","isAnyDisabled","disabledStateProps","otherProps","useDisableStateProps","defaultTheme","useTheme","Theme","light","chips","clearButtonProps","error","forceFocusStyle","helper","icon","inputRefProps","isValid","label","labelProps","maxLength","onClear","textFieldRef","theme","afterElement","generatedTextFieldId","useId","textFieldId","localInputRef","helperId","errorId","describedByIds","filter","Boolean","length","join","isFocus","valueLength","isNotEmpty","handleClear","evt","nativeEvent","preventDefault","stopPropagation","currentTarget","blur","inputElement","focus","_jsxs","classNames","handleBasicClasses","hasChips","hasIcon","hasInput","hasInputClear","hasLabel","hasPlaceholder","hasTextarea","hasValue","isDisabled","prefix","children","InputLabel","htmlFor","Icon","mdiAlertCircle","size","Size","xxs","color","dark","xs","mdiCheckCircle","IconButton","mdiCloseCircle","emphasis","Emphasis","low","s","onClick","InputHelper","kind","Kind","displayName","defaultProps"],"mappings":";;;;;;;;;;;;;;;;AAwFA;AACA;AACA;AACA,MAAMA,cAAc,GAAG,WAAW,CAAA;;AAElC;AACA;AACA;AACA,MAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAc,CAAC,CAAA;;AAElD;AACA;AACA;AACA,MAAMG,gBAAgB,GAAG,CAAC,CAAA;;AAE1B;AACA;AACA;AACA,MAAMC,aAAsC,GAAG;AAC3CC,EAAAA,IAAI,EAAE,MAAA;AACV,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMC,sBAAsB,GACxBC,WAAmB,IAQlB;EACD,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGC,QAAQ,CAACH,WAAW,CAAC,CAAA;EAE7C,MAAMI,SAAS,GAAIC,MAAe,IAAK;AACnC;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACQ;IACCA,MAAM,CAAyBJ,IAAI,GAAGD,WAAW,CAAA;IAClD,IAAIM,WAAW,GAAGD,MAAM,CAACE,YAAY,IAAIF,MAAM,CAACG,YAAY,GAAGR,WAAW,CAAC,CAAA;AAC3EM,IAAAA,WAAW,GAAGA,WAAW,IAAIN,WAAW,GAAGM,WAAW,GAAGN,WAAW,CAAA;AACpE;IACCK,MAAM,CAAyBJ,IAAI,GAAGK,WAAW,CAAA;IAElDJ,OAAO,CAACI,WAAW,CAAC,CAAA;GACvB,CAA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IgC,KAAK,iBACdb,GAAA,CAACiF,WAAW,EAAA;MAACtF,SAAS,EAAE,CAAG3C,EAAAA,SAAS,CAAW,QAAA,CAAA;MAACkI,IAAI,EAAEC,IAAI,CAACtE,KAAM;AAACW,MAAAA,KAAK,EAAEA,KAAM;AAACtD,MAAAA,EAAE,EAAE6D,OAAQ;AAAA+B,MAAAA,QAAA,EACvFjD,KAAAA;AAAK,KACG,CAChB,EAEAE,MAAM,iBACHf,GAAA,CAACiF,WAAW,EAAA;MAACtF,SAAS,EAAE,CAAG3C,EAAAA,SAAS,CAAW,QAAA,CAAA;AAACwE,MAAAA,KAAK,EAAEA,KAAM;AAACtD,MAAAA,EAAE,EAAE4D,QAAS;AAAAgC,MAAAA,QAAA,EACtE/C,MAAAA;AAAM,KACE,CAChB,CAAA;AAAA,GACA,CAAC,CAAA;AAEd,CAAC,EAAC;AACFd,SAAS,CAACmF,WAAW,GAAGrI,cAAc,CAAA;AACtCkD,SAAS,CAACN,SAAS,GAAG3C,SAAS,CAAA;AAC/BiD,SAAS,CAACoF,YAAY,GAAGlI,aAAa;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { T as Thumbnail, u as useFocusPointStyle } from '../Thumbnail-
|
|
1
|
+
export { T as Thumbnail, u as useFocusPointStyle } from '../Thumbnail-b5dea0af.js';
|
|
2
2
|
import { AspectRatio } from '@lumx/core/js/constants';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -39,4 +39,4 @@ const ThumbnailObjectFit = {
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
export { ThumbnailAspectRatio, ThumbnailObjectFit, ThumbnailVariant };
|
|
42
|
-
//# sourceMappingURL=thumbnail-
|
|
42
|
+
//# sourceMappingURL=thumbnail-310a4c4b.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thumbnail-
|
|
1
|
+
{"version":3,"file":"thumbnail-310a4c4b.js","sources":["../../../src/components/thumbnail/types.ts"],"sourcesContent":["import React from 'react';\nimport { AspectRatio, Size } from '@lumx/react';\nimport { ValueOf } from '@lumx/react/utils/type';\n\n/**\n * Focal point using vertical alignment, horizontal alignment or coordinates (from -1 to 1).\n */\nexport type FocusPoint = { x?: number; y?: number };\n\n/**\n * Loading attribute is not yet supported in typescript, so we need\n * to add it in order to avoid a ts error.\n * https://github.com/typescript-cheatsheets/react-typescript-cheatsheet/blob/master/ADVANCED.md#adding-non-standard-attributes\n */\ndeclare module 'react' {\n interface ImgHTMLAttributes<T> extends React.HTMLAttributes<T> {\n loading?: 'eager' | 'lazy';\n }\n}\n\n/**\n * All available aspect ratios.\n * @deprecated\n */\nexport const ThumbnailAspectRatio: Record<string, AspectRatio> = { ...AspectRatio };\n\n/**\n * Thumbnail sizes.\n */\nexport type ThumbnailSize = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;\n\n/**\n * Thumbnail variants.\n */\nexport const ThumbnailVariant = {\n squared: 'squared',\n rounded: 'rounded',\n} as const;\nexport type ThumbnailVariant = ValueOf<typeof ThumbnailVariant>;\n\n/**\n * Thumbnail object fit.\n */\nexport const ThumbnailObjectFit = {\n cover: 'cover',\n contain: 'contain',\n} as const;\nexport type ThumbnailObjectFit = ValueOf<typeof ThumbnailObjectFit>;\n"],"names":["ThumbnailAspectRatio","AspectRatio","ThumbnailVariant","squared","rounded","ThumbnailObjectFit","cover","contain"],"mappings":";;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACO,MAAMA,oBAAiD,GAAG;EAAE,GAAGC,WAAAA;AAAY,EAAC;;AAEnF;AACA;AACA;;AAGA;AACA;AACA;AACO,MAAMC,gBAAgB,GAAG;AAC5BC,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,OAAO,EAAE,SAAA;AACb,EAAU;AAGV;AACA;AACA;AACO,MAAMC,kBAAkB,GAAG;AAC9BC,EAAAA,KAAK,EAAE,OAAO;AACdC,EAAAA,OAAO,EAAE,SAAA;AACb;;;;"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { f as forwardRef,
|
|
1
|
+
import { f as forwardRef, c as classNames } from '../forwardRef-15f62847.js';
|
|
2
2
|
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Defines the props of the component.
|
|
6
|
-
*/
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* Component display name.
|
|
@@ -35,26 +32,30 @@ const Toolbar = forwardRef((props, ref) => {
|
|
|
35
32
|
label,
|
|
36
33
|
...forwardedProps
|
|
37
34
|
} = props;
|
|
38
|
-
return /*#__PURE__*/
|
|
39
|
-
ref: ref
|
|
40
|
-
|
|
35
|
+
return /*#__PURE__*/jsxs("div", {
|
|
36
|
+
ref: ref,
|
|
37
|
+
...forwardedProps,
|
|
41
38
|
className: classNames(className, handleBasicClasses({
|
|
42
39
|
hasAfter: Boolean(after),
|
|
43
40
|
hasBefore: Boolean(before),
|
|
44
41
|
hasLabel: Boolean(label),
|
|
45
42
|
prefix: CLASSNAME
|
|
46
|
-
}))
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
})),
|
|
44
|
+
children: [before && /*#__PURE__*/jsx("div", {
|
|
45
|
+
className: `${CLASSNAME}__before`,
|
|
46
|
+
children: before
|
|
47
|
+
}), label && /*#__PURE__*/jsx("div", {
|
|
48
|
+
className: `${CLASSNAME}__label`,
|
|
49
|
+
children: label
|
|
50
|
+
}), after && /*#__PURE__*/jsx("div", {
|
|
51
|
+
className: `${CLASSNAME}__after`,
|
|
52
|
+
children: after
|
|
53
|
+
})]
|
|
54
|
+
});
|
|
54
55
|
});
|
|
55
56
|
Toolbar.displayName = COMPONENT_NAME;
|
|
56
57
|
Toolbar.className = CLASSNAME;
|
|
57
58
|
Toolbar.defaultProps = DEFAULT_PROPS;
|
|
58
59
|
|
|
59
60
|
export { Toolbar };
|
|
60
|
-
//# sourceMappingURL=toolbar-
|
|
61
|
+
//# sourceMappingURL=toolbar-a43533a2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolbar-
|
|
1
|
+
{"version":3,"file":"toolbar-a43533a2.js","sources":["../../../src/components/toolbar/Toolbar.tsx"],"sourcesContent":["import { ReactNode } from 'react';\n\nimport classNames from 'classnames';\n\nimport { GenericProps } from '@lumx/react/utils/type';\nimport { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';\nimport { forwardRef } from '@lumx/react/utils/react/forwardRef';\n\n/**\n * Defines the props of the component.\n */\nexport interface ToolbarProps extends GenericProps {\n /** After content (placed after the label). */\n after?: ReactNode;\n /** Before content (placed before the label). */\n before?: ReactNode;\n /** Label content. */\n label?: ReactNode;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Toolbar';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<ToolbarProps> = {};\n\n/**\n * Toolbar component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Toolbar = forwardRef<ToolbarProps, HTMLDivElement>((props, ref) => {\n const { after, before, className, label, ...forwardedProps } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n hasAfter: Boolean(after),\n hasBefore: Boolean(before),\n hasLabel: Boolean(label),\n prefix: CLASSNAME,\n }),\n )}\n >\n {before && <div className={`${CLASSNAME}__before`}>{before}</div>}\n {label && <div className={`${CLASSNAME}__label`}>{label}</div>}\n {after && <div className={`${CLASSNAME}__after`}>{after}</div>}\n </div>\n );\n});\nToolbar.displayName = COMPONENT_NAME;\nToolbar.className = CLASSNAME;\nToolbar.defaultProps = DEFAULT_PROPS;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","Toolbar","forwardRef","props","ref","after","before","className","label","forwardedProps","_jsxs","classNames","handleBasicClasses","hasAfter","Boolean","hasBefore","hasLabel","prefix","children","_jsx","displayName","defaultProps"],"mappings":";;;;AAoBA;AACA;AACA;AACA,MAAMA,cAAc,GAAG,SAAS,CAAA;;AAEhC;AACA;AACA;AACA,MAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAc,CAAC,CAAA;;AAElD;AACA;AACA;AACA,MAAMG,aAAoC,GAAG,EAAE,CAAA;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,OAAO,GAAGC,UAAU,CAA+B,CAACC,KAAK,EAAEC,GAAG,KAAK;EAC5E,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC,SAAS;IAAEC,KAAK;IAAE,GAAGC,cAAAA;AAAe,GAAC,GAAGN,KAAK,CAAA;AAEpE,EAAA,oBACIO,IAAA,CAAA,KAAA,EAAA;AACIN,IAAAA,GAAG,EAAEA,GAAI;AAAA,IAAA,GACLK,cAAc;AAClBF,IAAAA,SAAS,EAAEI,UAAU,CACjBJ,SAAS,EACTK,kBAAkB,CAAC;AACfC,MAAAA,QAAQ,EAAEC,OAAO,CAACT,KAAK,CAAC;AACxBU,MAAAA,SAAS,EAAED,OAAO,CAACR,MAAM,CAAC;AAC1BU,MAAAA,QAAQ,EAAEF,OAAO,CAACN,KAAK,CAAC;AACxBS,MAAAA,MAAM,EAAEnB,SAAAA;AACZ,KAAC,CACL,CAAE;IAAAoB,QAAA,EAAA,CAEDZ,MAAM,iBAAIa,GAAA,CAAA,KAAA,EAAA;MAAKZ,SAAS,EAAE,CAAGT,EAAAA,SAAS,CAAW,QAAA,CAAA;AAAAoB,MAAAA,QAAA,EAAEZ,MAAAA;AAAM,KAAM,CAAC,EAChEE,KAAK,iBAAIW,GAAA,CAAA,KAAA,EAAA;MAAKZ,SAAS,EAAE,CAAGT,EAAAA,SAAS,CAAU,OAAA,CAAA;AAAAoB,MAAAA,QAAA,EAAEV,KAAAA;AAAK,KAAM,CAAC,EAC7DH,KAAK,iBAAIc,GAAA,CAAA,KAAA,EAAA;MAAKZ,SAAS,EAAE,CAAGT,EAAAA,SAAS,CAAU,OAAA,CAAA;AAAAoB,MAAAA,QAAA,EAAEb,KAAAA;AAAK,KAAM,CAAC,CAAA;AAAA,GAC7D,CAAC,CAAA;AAEd,CAAC,EAAC;AACFJ,OAAO,CAACmB,WAAW,GAAGvB,cAAc,CAAA;AACpCI,OAAO,CAACM,SAAS,GAAGT,SAAS,CAAA;AAC7BG,OAAO,CAACoB,YAAY,GAAGrB,aAAa;;;;"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { _ as _extends, f as forwardRef, c as classNames } from '../forwardRef-49d2bb84.js';
|
|
2
1
|
import React__default, { useMemo, cloneElement, useState, useRef, useEffect } from 'react';
|
|
2
|
+
import { f as forwardRef, c as classNames } from '../forwardRef-15f62847.js';
|
|
3
3
|
import { I as IS_BROWSER, D as DOCUMENT, V as VISUALLY_HIDDEN } from '../constants-d0e3f49e.js';
|
|
4
4
|
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
5
5
|
import { m as mergeRefs, u as useMergeRefs } from '../mergeRefs-f0d7d6ea.js';
|
|
6
|
-
import { T as TooltipContextProvider } from '../context-
|
|
6
|
+
import { T as TooltipContextProvider } from '../context-9d1336a1.js';
|
|
7
7
|
import { u as useId } from '../useId-3a1facc0.js';
|
|
8
8
|
import { a as POPOVER_ZINDEX, P as Placement, u as usePopper } from '../constants-b9e57936.js';
|
|
9
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
9
10
|
import { u as useCallbackOnEscape } from '../useCallbackOnEscape-ea4d9eb4.js';
|
|
10
11
|
import { TOOLTIP_LONG_PRESS_DELAY, TOOLTIP_HOVER_DELAY } from '@lumx/core/js/constants';
|
|
11
|
-
import { P as Portal } from '../Portal-
|
|
12
|
+
import { P as Portal } from '../Portal-3f86608e.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Make sure tooltip appear above popovers.
|
|
@@ -52,10 +53,12 @@ const useInjectTooltipRef = options => {
|
|
|
52
53
|
const aria = linkId ? {
|
|
53
54
|
[ariaLinkMode]: linkId
|
|
54
55
|
} : undefined;
|
|
55
|
-
return /*#__PURE__*/
|
|
56
|
+
return /*#__PURE__*/jsx("div", {
|
|
56
57
|
className: "lumx-tooltip-anchor-wrapper",
|
|
57
|
-
ref: setAnchorElement
|
|
58
|
-
|
|
58
|
+
ref: setAnchorElement,
|
|
59
|
+
...aria,
|
|
60
|
+
children: children
|
|
61
|
+
});
|
|
59
62
|
}, [label, children, setAnchorElement, linkId, ariaLinkMode]);
|
|
60
63
|
};
|
|
61
64
|
|
|
@@ -194,12 +197,7 @@ function useTooltipOpen(delay, anchorElement) {
|
|
|
194
197
|
};
|
|
195
198
|
}
|
|
196
199
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Defines the props of the component.
|
|
201
|
-
*/
|
|
202
|
-
|
|
200
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
203
201
|
/**
|
|
204
202
|
* Component display name.
|
|
205
203
|
*/
|
|
@@ -247,7 +245,9 @@ const Tooltip = forwardRef((props, ref) => {
|
|
|
247
245
|
} = props;
|
|
248
246
|
// Disable in SSR.
|
|
249
247
|
if (!DOCUMENT) {
|
|
250
|
-
return /*#__PURE__*/
|
|
248
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
249
|
+
children: children
|
|
250
|
+
});
|
|
251
251
|
}
|
|
252
252
|
const id = useId();
|
|
253
253
|
const [popperElement, setPopperElement] = useState(null);
|
|
@@ -288,31 +288,40 @@ const Tooltip = forwardRef((props, ref) => {
|
|
|
288
288
|
}, [isOpen, update, popperElement]);
|
|
289
289
|
const labelLines = label ? label.split('\n') : [];
|
|
290
290
|
const tooltipRef = useMergeRefs(ref, setPopperElement, onPopperMount);
|
|
291
|
-
return /*#__PURE__*/
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
291
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
292
|
+
children: [/*#__PURE__*/jsx(TooltipContextProvider, {
|
|
293
|
+
children: wrappedChildren
|
|
294
|
+
}), isMounted && /*#__PURE__*/jsx(Portal, {
|
|
295
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
296
|
+
ref: tooltipRef,
|
|
297
|
+
...forwardedProps,
|
|
298
|
+
id: id,
|
|
299
|
+
role: "tooltip",
|
|
300
|
+
className: classNames(className, handleBasicClasses({
|
|
301
|
+
prefix: CLASSNAME,
|
|
302
|
+
position,
|
|
303
|
+
isInitializing: !styles.popper?.transform
|
|
304
|
+
}), isHidden && VISUALLY_HIDDEN),
|
|
305
|
+
style: {
|
|
306
|
+
...(isHidden ? undefined : styles.popper),
|
|
307
|
+
zIndex
|
|
308
|
+
},
|
|
309
|
+
...attributes.popper,
|
|
310
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
311
|
+
className: `${CLASSNAME}__arrow`
|
|
312
|
+
}), /*#__PURE__*/jsx("div", {
|
|
313
|
+
className: `${CLASSNAME}__inner`,
|
|
314
|
+
children: labelLines.map(line => /*#__PURE__*/jsx("p", {
|
|
315
|
+
children: line
|
|
316
|
+
}, line))
|
|
317
|
+
})]
|
|
318
|
+
})
|
|
319
|
+
})]
|
|
320
|
+
});
|
|
312
321
|
});
|
|
313
322
|
Tooltip.displayName = COMPONENT_NAME;
|
|
314
323
|
Tooltip.className = CLASSNAME;
|
|
315
324
|
Tooltip.defaultProps = DEFAULT_PROPS;
|
|
316
325
|
|
|
317
326
|
export { Tooltip };
|
|
318
|
-
//# sourceMappingURL=tooltip-
|
|
327
|
+
//# sourceMappingURL=tooltip-2885ab2e.js.map
|