@equinor/eds-core-react 0.36.1 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eds-core-react.cjs +1319 -109
- package/dist/esm/components/Autocomplete/Autocomplete.js +76 -42
- package/dist/esm/components/Autocomplete/Autocomplete.tokens.js +1 -1
- package/dist/esm/components/Breadcrumbs/Breadcrumbs.js +1 -1
- package/dist/esm/components/Button/Button.js +1 -1
- package/dist/esm/components/Button/tokens/contained.js +1 -1
- package/dist/esm/components/Button/tokens/contained_icon.js +3 -3
- package/dist/esm/components/Button/tokens/ghost.js +1 -1
- package/dist/esm/components/Button/tokens/icon.js +2 -2
- package/dist/esm/components/Button/tokens/outlined.js +1 -1
- package/dist/esm/components/Datepicker/DatePicker.js +168 -0
- package/dist/esm/components/Datepicker/DateRangePicker.js +165 -0
- package/dist/esm/components/Datepicker/calendars/Calendar.js +83 -0
- package/dist/esm/components/Datepicker/calendars/CalendarCell.js +144 -0
- package/dist/esm/components/Datepicker/calendars/CalendarGrid.js +65 -0
- package/dist/esm/components/Datepicker/calendars/CalendarHeader.js +90 -0
- package/dist/esm/components/Datepicker/calendars/CalendarWrapper.js +8 -0
- package/dist/esm/components/Datepicker/calendars/RangeCalendar.js +72 -0
- package/dist/esm/components/Datepicker/calendars/YearGrid.js +90 -0
- package/dist/esm/components/Datepicker/fields/DateField.js +40 -0
- package/dist/esm/components/Datepicker/fields/DateFieldSegments.js +43 -0
- package/dist/esm/components/Datepicker/fields/DateRangeField.js +43 -0
- package/dist/esm/components/Datepicker/fields/DateSegment.js +65 -0
- package/dist/esm/components/Datepicker/fields/FieldWrapper.js +136 -0
- package/dist/esm/components/Datepicker/fields/Toggle.js +61 -0
- package/dist/esm/components/Datepicker/utils/context.js +24 -0
- package/dist/esm/components/Datepicker/utils/get-calendar-date.js +8 -0
- package/dist/esm/components/Datepicker/utils/useConvertedValidationFunctions.js +20 -0
- package/dist/esm/components/Input/Input.tokens.js +1 -1
- package/dist/esm/components/InputWrapper/InputWrapper.tokens.js +1 -1
- package/dist/esm/components/Label/Label.js +1 -1
- package/dist/esm/components/Menu/MenuItem.js +1 -1
- package/dist/esm/components/Table/DataCell/DataCell.tokens.js +1 -1
- package/dist/esm/components/TextField/TextField.js +2 -1
- package/dist/esm/components/Textarea/Textarea.js +9 -3
- package/dist/esm/index.js +2 -0
- package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/internal/_curry1.js +0 -1
- package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/internal/_curry2.js +0 -1
- package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/internal/_curry3.js +0 -1
- package/dist/esm/node_modules/.pnpm/ramda@0.30.0/node_modules/ramda/es/internal/_isPlaceholder.js +7 -0
- package/dist/esm/node_modules/.pnpm/ramda@0.30.0/node_modules/ramda/es/internal/_placeholder.js +5 -0
- package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/mergeDeepRight.js +2 -5
- package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/mergeDeepWithKey.js +2 -5
- package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/mergeWith.js +2 -5
- package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/mergeWithKey.js +2 -5
- package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/pickBy.js +2 -5
- package/dist/types/components/Autocomplete/Autocomplete.d.ts +29 -18
- package/dist/types/components/Chip/Icon.d.ts +3 -5
- package/dist/types/components/Datepicker/DatePicker.d.ts +24 -0
- package/dist/types/components/Datepicker/DatePicker.spec.d.ts +1 -0
- package/dist/types/components/Datepicker/DateRangePicker.d.ts +40 -0
- package/dist/types/components/Datepicker/DateRangePicker.spec.d.ts +1 -0
- package/dist/types/components/Datepicker/calendars/Calendar.d.ts +17 -0
- package/dist/types/components/Datepicker/calendars/CalendarCell.d.ts +9 -0
- package/dist/types/components/Datepicker/calendars/CalendarGrid.d.ts +10 -0
- package/dist/types/components/Datepicker/calendars/CalendarHeader.d.ts +12 -0
- package/dist/types/components/Datepicker/calendars/CalendarWrapper.d.ts +2 -0
- package/dist/types/components/Datepicker/calendars/RangeCalendar.d.ts +11 -0
- package/dist/types/components/Datepicker/calendars/YearGrid.d.ts +4 -0
- package/dist/types/components/Datepicker/fields/DateField.d.ts +20 -0
- package/dist/types/components/Datepicker/fields/DateFieldSegments.d.ts +6 -0
- package/dist/types/components/Datepicker/fields/DateRangeField.d.ts +12 -0
- package/dist/types/components/Datepicker/fields/DateSegment.d.ts +8 -0
- package/dist/types/components/Datepicker/fields/FieldWrapper.d.ts +31 -0
- package/dist/types/components/Datepicker/fields/Toggle.d.ts +15 -0
- package/dist/types/components/Datepicker/index.d.ts +2 -0
- package/dist/types/components/Datepicker/props.d.ts +111 -0
- package/dist/types/components/Datepicker/utils/context.d.ts +14 -0
- package/dist/types/components/Datepicker/utils/get-calendar-date.d.ts +1 -0
- package/dist/types/components/Datepicker/utils/types.d.ts +6 -0
- package/dist/types/components/Datepicker/utils/useConvertedValidationFunctions.d.ts +8 -0
- package/dist/types/components/Label/Label.d.ts +2 -2
- package/dist/types/components/Select/NativeSelect.d.ts +3 -3
- package/dist/types/components/Switch/Switch.styles.d.ts +4 -845
- package/dist/types/components/Tabs/TabList.d.ts +2 -13
- package/dist/types/components/TextField/TextField.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +25 -22
- package/dist/esm/node_modules/.pnpm/ramda@0.29.1/node_modules/ramda/es/internal/_isPlaceholder.js +0 -5
- /package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/internal/_has.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{ramda@0.29.1 → ramda@0.30.0}/node_modules/ramda/es/internal/_isObject.js +0 -0
package/dist/eds-core-react.cjs
CHANGED
|
@@ -10,6 +10,11 @@ var edsIcons = require('@equinor/eds-icons');
|
|
|
10
10
|
var ReactDom = require('react-dom');
|
|
11
11
|
var downshift = require('downshift');
|
|
12
12
|
var reactVirtual = require('@tanstack/react-virtual');
|
|
13
|
+
var reactAria = require('react-aria');
|
|
14
|
+
var calendar = require('@react-stately/calendar');
|
|
15
|
+
var date = require('@internationalized/date');
|
|
16
|
+
var datepicker = require('@react-stately/datepicker');
|
|
17
|
+
var utils = require('@react-aria/utils');
|
|
13
18
|
|
|
14
19
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
20
|
|
|
@@ -167,8 +172,12 @@ const button = {
|
|
|
167
172
|
}
|
|
168
173
|
};
|
|
169
174
|
|
|
175
|
+
var _placeholder = {
|
|
176
|
+
'@@functional/placeholder': true
|
|
177
|
+
};
|
|
178
|
+
|
|
170
179
|
function _isPlaceholder(a) {
|
|
171
|
-
return a
|
|
180
|
+
return a === _placeholder;
|
|
172
181
|
}
|
|
173
182
|
|
|
174
183
|
/**
|
|
@@ -179,7 +188,6 @@ function _isPlaceholder(a) {
|
|
|
179
188
|
* @param {Function} fn The function to curry.
|
|
180
189
|
* @return {Function} The curried function.
|
|
181
190
|
*/
|
|
182
|
-
|
|
183
191
|
function _curry1(fn) {
|
|
184
192
|
return function f1(a) {
|
|
185
193
|
if (arguments.length === 0 || _isPlaceholder(a)) {
|
|
@@ -198,7 +206,6 @@ function _curry1(fn) {
|
|
|
198
206
|
* @param {Function} fn The function to curry.
|
|
199
207
|
* @return {Function} The curried function.
|
|
200
208
|
*/
|
|
201
|
-
|
|
202
209
|
function _curry2(fn) {
|
|
203
210
|
return function f2(a, b) {
|
|
204
211
|
switch (arguments.length) {
|
|
@@ -226,7 +233,6 @@ function _curry2(fn) {
|
|
|
226
233
|
* @param {Function} fn The function to curry.
|
|
227
234
|
* @return {Function} The curried function.
|
|
228
235
|
*/
|
|
229
|
-
|
|
230
236
|
function _curry3(fn) {
|
|
231
237
|
return function f3(a, b, c) {
|
|
232
238
|
switch (arguments.length) {
|
|
@@ -295,9 +301,7 @@ function _isObject(x) {
|
|
|
295
301
|
* //=> { a: true, b: true, thing: 'bar', values: [10, 20, 15, 35] }
|
|
296
302
|
* @symb R.mergeWithKey(f, { x: 1, y: 2 }, { y: 5, z: 3 }) = { x: 1, y: f('y', 2, 5), z: 3 }
|
|
297
303
|
*/
|
|
298
|
-
|
|
299
|
-
var mergeWithKey = /*#__PURE__*/
|
|
300
|
-
_curry3(function mergeWithKey(fn, l, r) {
|
|
304
|
+
var mergeWithKey = /*#__PURE__*/_curry3(function mergeWithKey(fn, l, r) {
|
|
301
305
|
var result = {};
|
|
302
306
|
var k;
|
|
303
307
|
l = l || {};
|
|
@@ -314,7 +318,6 @@ _curry3(function mergeWithKey(fn, l, r) {
|
|
|
314
318
|
}
|
|
315
319
|
return result;
|
|
316
320
|
});
|
|
317
|
-
var mergeWithKey$1 = mergeWithKey;
|
|
318
321
|
|
|
319
322
|
/**
|
|
320
323
|
* Creates a new object with the own properties of the two provided objects.
|
|
@@ -344,10 +347,8 @@ var mergeWithKey$1 = mergeWithKey;
|
|
|
344
347
|
* { b: true, c: { thing: 'bar', values: [15, 35] }});
|
|
345
348
|
* //=> { a: true, b: true, c: { thing: 'bar', values: [10, 20, 15, 35] }}
|
|
346
349
|
*/
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
_curry3(function mergeDeepWithKey(fn, lObj, rObj) {
|
|
350
|
-
return mergeWithKey$1(function (k, lVal, rVal) {
|
|
350
|
+
var mergeDeepWithKey = /*#__PURE__*/_curry3(function mergeDeepWithKey(fn, lObj, rObj) {
|
|
351
|
+
return mergeWithKey(function (k, lVal, rVal) {
|
|
351
352
|
if (_isObject(lVal) && _isObject(rVal)) {
|
|
352
353
|
return mergeDeepWithKey(fn, lVal, rVal);
|
|
353
354
|
} else {
|
|
@@ -355,7 +356,6 @@ _curry3(function mergeDeepWithKey(fn, lObj, rObj) {
|
|
|
355
356
|
}
|
|
356
357
|
}, lObj, rObj);
|
|
357
358
|
});
|
|
358
|
-
var mergeDeepWithKey$1 = mergeDeepWithKey;
|
|
359
359
|
|
|
360
360
|
/**
|
|
361
361
|
* Creates a new object with the own properties of the first object merged with
|
|
@@ -378,14 +378,11 @@ var mergeDeepWithKey$1 = mergeDeepWithKey;
|
|
|
378
378
|
* { age: 40, contact: { email: 'baa@example.com' }});
|
|
379
379
|
* //=> { name: 'fred', age: 40, contact: { email: 'baa@example.com' }}
|
|
380
380
|
*/
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
_curry2(function mergeDeepRight(lObj, rObj) {
|
|
384
|
-
return mergeDeepWithKey$1(function (k, lVal, rVal) {
|
|
381
|
+
var mergeDeepRight = /*#__PURE__*/_curry2(function mergeDeepRight(lObj, rObj) {
|
|
382
|
+
return mergeDeepWithKey(function (k, lVal, rVal) {
|
|
385
383
|
return rVal;
|
|
386
384
|
}, lObj, rObj);
|
|
387
385
|
});
|
|
388
|
-
var mergeDeepRight$1 = mergeDeepRight;
|
|
389
386
|
|
|
390
387
|
/**
|
|
391
388
|
* Creates a new object with the own properties of the two provided objects. If
|
|
@@ -410,14 +407,11 @@ var mergeDeepRight$1 = mergeDeepRight;
|
|
|
410
407
|
* { b: true, values: [15, 35] });
|
|
411
408
|
* //=> { a: true, b: true, values: [10, 20, 15, 35] }
|
|
412
409
|
*/
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
_curry3(function mergeWith(fn, l, r) {
|
|
416
|
-
return mergeWithKey$1(function (_, _l, _r) {
|
|
410
|
+
var mergeWith = /*#__PURE__*/_curry3(function mergeWith(fn, l, r) {
|
|
411
|
+
return mergeWithKey(function (_, _l, _r) {
|
|
417
412
|
return fn(_l, _r);
|
|
418
413
|
}, l, r);
|
|
419
414
|
});
|
|
420
|
-
var mergeWith$1 = mergeWith;
|
|
421
415
|
|
|
422
416
|
/**
|
|
423
417
|
* Returns a partial copy of an object containing only the keys that satisfy
|
|
@@ -439,9 +433,7 @@ var mergeWith$1 = mergeWith;
|
|
|
439
433
|
* const isUpperCase = (val, key) => key.toUpperCase() === key;
|
|
440
434
|
* R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4}
|
|
441
435
|
*/
|
|
442
|
-
|
|
443
|
-
var pickBy = /*#__PURE__*/
|
|
444
|
-
_curry2(function pickBy(test, obj) {
|
|
436
|
+
var pickBy = /*#__PURE__*/_curry2(function pickBy(test, obj) {
|
|
445
437
|
var result = {};
|
|
446
438
|
for (var prop in obj) {
|
|
447
439
|
if (test(obj[prop], prop, obj)) {
|
|
@@ -450,7 +442,6 @@ _curry2(function pickBy(test, obj) {
|
|
|
450
442
|
}
|
|
451
443
|
return result;
|
|
452
444
|
});
|
|
453
|
-
var pickBy$1 = pickBy;
|
|
454
445
|
|
|
455
446
|
const {
|
|
456
447
|
colors: {
|
|
@@ -486,7 +477,7 @@ const {
|
|
|
486
477
|
}
|
|
487
478
|
}
|
|
488
479
|
} = edsTokens.tokens;
|
|
489
|
-
const primary$a = mergeDeepRight
|
|
480
|
+
const primary$a = mergeDeepRight(button, {
|
|
490
481
|
background: primaryColor$7,
|
|
491
482
|
typography: {
|
|
492
483
|
color: primaryWhite$2
|
|
@@ -504,7 +495,7 @@ const primary$a = mergeDeepRight$1(button, {
|
|
|
504
495
|
}
|
|
505
496
|
}
|
|
506
497
|
});
|
|
507
|
-
const secondary$5 = mergeDeepRight
|
|
498
|
+
const secondary$5 = mergeDeepRight(primary$a, {
|
|
508
499
|
background: secondaryColor$3,
|
|
509
500
|
border: {
|
|
510
501
|
color: secondaryColor$3
|
|
@@ -518,7 +509,7 @@ const secondary$5 = mergeDeepRight$1(primary$a, {
|
|
|
518
509
|
}
|
|
519
510
|
}
|
|
520
511
|
});
|
|
521
|
-
const danger$6 = mergeDeepRight
|
|
512
|
+
const danger$6 = mergeDeepRight(primary$a, {
|
|
522
513
|
background: dangerColor$3,
|
|
523
514
|
border: {
|
|
524
515
|
color: dangerColor$3
|
|
@@ -571,7 +562,7 @@ const {
|
|
|
571
562
|
}
|
|
572
563
|
}
|
|
573
564
|
} = edsTokens.tokens;
|
|
574
|
-
const primary$9 = mergeDeepRight
|
|
565
|
+
const primary$9 = mergeDeepRight(button, {
|
|
575
566
|
typography: {
|
|
576
567
|
color: primaryColor$6
|
|
577
568
|
},
|
|
@@ -600,7 +591,7 @@ const primary$9 = mergeDeepRight$1(button, {
|
|
|
600
591
|
}
|
|
601
592
|
}
|
|
602
593
|
});
|
|
603
|
-
const secondary$4 = mergeDeepRight
|
|
594
|
+
const secondary$4 = mergeDeepRight(primary$9, {
|
|
604
595
|
typography: {
|
|
605
596
|
color: secondaryColor$2
|
|
606
597
|
},
|
|
@@ -619,7 +610,7 @@ const secondary$4 = mergeDeepRight$1(primary$9, {
|
|
|
619
610
|
}
|
|
620
611
|
}
|
|
621
612
|
});
|
|
622
|
-
const danger$5 = mergeDeepRight
|
|
613
|
+
const danger$5 = mergeDeepRight(primary$9, {
|
|
623
614
|
typography: {
|
|
624
615
|
color: dangerColor$2
|
|
625
616
|
},
|
|
@@ -672,7 +663,7 @@ const {
|
|
|
672
663
|
}
|
|
673
664
|
}
|
|
674
665
|
} = edsTokens.tokens;
|
|
675
|
-
const primary$8 = mergeDeepRight
|
|
666
|
+
const primary$8 = mergeDeepRight(button, {
|
|
676
667
|
typography: {
|
|
677
668
|
color: primaryColor$5
|
|
678
669
|
},
|
|
@@ -691,7 +682,7 @@ const primary$8 = mergeDeepRight$1(button, {
|
|
|
691
682
|
}
|
|
692
683
|
}
|
|
693
684
|
});
|
|
694
|
-
const secondary$3 = mergeDeepRight
|
|
685
|
+
const secondary$3 = mergeDeepRight(primary$8, {
|
|
695
686
|
typography: {
|
|
696
687
|
color: secondaryColor$1
|
|
697
688
|
},
|
|
@@ -704,7 +695,7 @@ const secondary$3 = mergeDeepRight$1(primary$8, {
|
|
|
704
695
|
}
|
|
705
696
|
}
|
|
706
697
|
});
|
|
707
|
-
const danger$4 = mergeDeepRight
|
|
698
|
+
const danger$4 = mergeDeepRight(primary$8, {
|
|
708
699
|
typography: {
|
|
709
700
|
color: dangerColor$1
|
|
710
701
|
},
|
|
@@ -758,7 +749,7 @@ const {
|
|
|
758
749
|
}
|
|
759
750
|
}
|
|
760
751
|
} = edsTokens.tokens;
|
|
761
|
-
const primary$7 = mergeDeepRight
|
|
752
|
+
const primary$7 = mergeDeepRight(button, {
|
|
762
753
|
height: shape$4.icon_button.minHeight,
|
|
763
754
|
width: shape$4.icon_button.minWidth,
|
|
764
755
|
typography: {
|
|
@@ -776,7 +767,7 @@ const primary$7 = mergeDeepRight$1(button, {
|
|
|
776
767
|
clickbound: {
|
|
777
768
|
width: clicboundHeight$1,
|
|
778
769
|
offset: {
|
|
779
|
-
top:
|
|
770
|
+
top: `${(parseInt(clicboundHeight$1) - parseInt(shape$4.icon_button.minWidth)) / 2}px`,
|
|
780
771
|
left: `${(parseInt(clicboundHeight$1) - parseInt(shape$4.icon_button.minWidth)) / 2}px`
|
|
781
772
|
}
|
|
782
773
|
},
|
|
@@ -814,7 +805,7 @@ const primary$7 = mergeDeepRight$1(button, {
|
|
|
814
805
|
}
|
|
815
806
|
}
|
|
816
807
|
});
|
|
817
|
-
const secondary$2 = mergeDeepRight
|
|
808
|
+
const secondary$2 = mergeDeepRight(primary$7, {
|
|
818
809
|
typography: {
|
|
819
810
|
color: secondaryColor
|
|
820
811
|
},
|
|
@@ -827,7 +818,7 @@ const secondary$2 = mergeDeepRight$1(primary$7, {
|
|
|
827
818
|
}
|
|
828
819
|
}
|
|
829
820
|
});
|
|
830
|
-
const danger$3 = mergeDeepRight
|
|
821
|
+
const danger$3 = mergeDeepRight(primary$7, {
|
|
831
822
|
typography: {
|
|
832
823
|
color: dangerColor
|
|
833
824
|
},
|
|
@@ -862,8 +853,8 @@ const contained_icon = {
|
|
|
862
853
|
clickbound: {
|
|
863
854
|
width: clicboundHeight,
|
|
864
855
|
offset: {
|
|
865
|
-
top:
|
|
866
|
-
left: `${(parseInt(clicboundHeight) - parseInt(
|
|
856
|
+
top: `${(parseInt(clicboundHeight) - parseInt(shape$3.icon_button.minWidth)) / 2}px`,
|
|
857
|
+
left: `${(parseInt(clicboundHeight) - parseInt(shape$3.icon_button.minWidth)) / 2}px`
|
|
867
858
|
}
|
|
868
859
|
},
|
|
869
860
|
states: {
|
|
@@ -888,9 +879,9 @@ const contained_icon = {
|
|
|
888
879
|
}
|
|
889
880
|
}
|
|
890
881
|
};
|
|
891
|
-
const primary$6 = mergeDeepRight
|
|
892
|
-
const secondary$1 = mergeDeepRight
|
|
893
|
-
const danger$2 = mergeDeepRight
|
|
882
|
+
const primary$6 = mergeDeepRight(primary$a, contained_icon);
|
|
883
|
+
const secondary$1 = mergeDeepRight(secondary$5, contained_icon);
|
|
884
|
+
const danger$2 = mergeDeepRight(danger$6, contained_icon);
|
|
894
885
|
|
|
895
886
|
const token$5 = {
|
|
896
887
|
primary: {
|
|
@@ -970,7 +961,7 @@ const EdsProvider = ({
|
|
|
970
961
|
};
|
|
971
962
|
const useEds = () => react.useContext(EdsContext);
|
|
972
963
|
|
|
973
|
-
const getVariant = (tokenSet, variant) => {
|
|
964
|
+
const getVariant$1 = (tokenSet, variant) => {
|
|
974
965
|
switch (variant) {
|
|
975
966
|
case 'ghost':
|
|
976
967
|
return tokenSet.ghost;
|
|
@@ -988,12 +979,12 @@ const getVariant = (tokenSet, variant) => {
|
|
|
988
979
|
const getToken$1 = (variant, color) => {
|
|
989
980
|
switch (color) {
|
|
990
981
|
case 'danger':
|
|
991
|
-
return getVariant(token$5.danger, variant);
|
|
982
|
+
return getVariant$1(token$5.danger, variant);
|
|
992
983
|
case 'secondary':
|
|
993
|
-
return getVariant(token$5.secondary, variant);
|
|
984
|
+
return getVariant$1(token$5.secondary, variant);
|
|
994
985
|
case 'primary':
|
|
995
986
|
default:
|
|
996
|
-
return getVariant(token$5.primary, variant);
|
|
987
|
+
return getVariant$1(token$5.primary, variant);
|
|
997
988
|
}
|
|
998
989
|
};
|
|
999
990
|
const Inner = styled__default.default.span.withConfig({
|
|
@@ -1015,7 +1006,7 @@ const ButtonBase = styled__default.default.button.withConfig({
|
|
|
1015
1006
|
hover,
|
|
1016
1007
|
disabled
|
|
1017
1008
|
} = states;
|
|
1018
|
-
return styled.css(["box-sizing:border-box;margin:0;padding:0;text-decoration:none;position:relative;cursor:pointer;display:inline-block;background:", ";height:", ";width:", ";svg{justify-self:center;}", " ", " ", " &::
|
|
1009
|
+
return styled.css(["box-sizing:border-box;margin:0;padding:0;text-decoration:none;position:relative;cursor:pointer;display:inline-block;background:", ";height:", ";width:", ";svg{justify-self:center;}", " ", " ", " &::after{position:absolute;top:-", ";left:-", ";width:", ";height:", ";content:'';}@media (hover:hover) and (pointer:fine){&:hover{background:", ";color:", ";", ";}}&:focus{outline:none;}&[data-focus-visible-added]:focus{", "}&:focus-visible{", "}&::-moz-focus-inner{border:0;}&:disabled,&[aria-disabled='true']{cursor:not-allowed;background:", ";", ";", ";@media (hover:hover) and (pointer:fine){&:hover{background:", ";}}}"], theme.background, theme.height, theme.width, edsUtils.spacingsTemplate(theme.spacings), edsUtils.bordersTemplate(theme.border), edsUtils.typographyTemplate(theme.typography), clickbound?.offset?.top, clickbound?.offset?.left, clickbound?.width, clickbound?.height, hover.background, hover.typography?.color, edsUtils.bordersTemplate(hover?.border), edsUtils.outlineTemplate(focus.outline), edsUtils.outlineTemplate(focus.outline), disabled.background, edsUtils.bordersTemplate(disabled.border), edsUtils.typographyTemplate(disabled.typography), disabled.background);
|
|
1019
1010
|
});
|
|
1020
1011
|
const Button$2 = /*#__PURE__*/react.forwardRef(function Button({
|
|
1021
1012
|
color = 'primary',
|
|
@@ -1656,7 +1647,7 @@ const tableCell = {
|
|
|
1656
1647
|
const applyVariant = (variant, token) => {
|
|
1657
1648
|
switch (variant) {
|
|
1658
1649
|
case 'numeric':
|
|
1659
|
-
return mergeDeepRight
|
|
1650
|
+
return mergeDeepRight(token, token.variants.numeric);
|
|
1660
1651
|
default:
|
|
1661
1652
|
return token;
|
|
1662
1653
|
}
|
|
@@ -2195,7 +2186,7 @@ const label = {
|
|
|
2195
2186
|
const LabelBase = styled__default.default.label.withConfig({
|
|
2196
2187
|
displayName: "Label__LabelBase",
|
|
2197
2188
|
componentId: "sc-1gi2bcn-0"
|
|
2198
|
-
})(["display:flex;justify-content:space-between;position:relative;", " margin-left:", ";margin-right:", ";color:", ";"], edsUtils.typographyTemplate(label.typography), label.spacings.left, label.spacings.right, ({
|
|
2189
|
+
})(["display:flex;justify-content:space-between;align-items:flex-end;position:relative;", " margin-left:", ";margin-right:", ";color:", ";"], edsUtils.typographyTemplate(label.typography), label.spacings.left, label.spacings.right, ({
|
|
2199
2190
|
$disabledText
|
|
2200
2191
|
}) => $disabledText ? label.states.disabled.typography.color : label.typography.color);
|
|
2201
2192
|
const Text$3 = styled__default.default.span.withConfig({
|
|
@@ -2398,7 +2389,7 @@ const input$2 = {
|
|
|
2398
2389
|
}
|
|
2399
2390
|
}
|
|
2400
2391
|
};
|
|
2401
|
-
const error$4 = mergeDeepRight
|
|
2392
|
+
const error$4 = mergeDeepRight(input$2, {
|
|
2402
2393
|
boxShadow: 'none',
|
|
2403
2394
|
outline: {
|
|
2404
2395
|
color: danger__resting$1.rgba
|
|
@@ -2419,7 +2410,7 @@ const error$4 = mergeDeepRight$1(input$2, {
|
|
|
2419
2410
|
}
|
|
2420
2411
|
}
|
|
2421
2412
|
});
|
|
2422
|
-
const warning$4 = mergeDeepRight
|
|
2413
|
+
const warning$4 = mergeDeepRight(input$2, {
|
|
2423
2414
|
boxShadow: 'none',
|
|
2424
2415
|
outline: {
|
|
2425
2416
|
color: warning__resting$1.rgba
|
|
@@ -2440,7 +2431,7 @@ const warning$4 = mergeDeepRight$1(input$2, {
|
|
|
2440
2431
|
}
|
|
2441
2432
|
}
|
|
2442
2433
|
});
|
|
2443
|
-
const success$1 = mergeDeepRight
|
|
2434
|
+
const success$1 = mergeDeepRight(input$2, {
|
|
2444
2435
|
boxShadow: 'none',
|
|
2445
2436
|
outline: {
|
|
2446
2437
|
color: success__resting$1.rgba
|
|
@@ -2633,7 +2624,7 @@ const input$1 = {
|
|
|
2633
2624
|
}
|
|
2634
2625
|
}
|
|
2635
2626
|
};
|
|
2636
|
-
const error$3 = mergeDeepRight
|
|
2627
|
+
const error$3 = mergeDeepRight(input$1, {
|
|
2637
2628
|
boxShadow: 'none',
|
|
2638
2629
|
outline: {
|
|
2639
2630
|
color: danger__resting.rgba
|
|
@@ -2661,7 +2652,7 @@ const error$3 = mergeDeepRight$1(input$1, {
|
|
|
2661
2652
|
}
|
|
2662
2653
|
}
|
|
2663
2654
|
});
|
|
2664
|
-
const warning$3 = mergeDeepRight
|
|
2655
|
+
const warning$3 = mergeDeepRight(input$1, {
|
|
2665
2656
|
boxShadow: 'none',
|
|
2666
2657
|
outline: {
|
|
2667
2658
|
color: warning__resting.rgba
|
|
@@ -2689,7 +2680,7 @@ const warning$3 = mergeDeepRight$1(input$1, {
|
|
|
2689
2680
|
}
|
|
2690
2681
|
}
|
|
2691
2682
|
});
|
|
2692
|
-
const success = mergeDeepRight
|
|
2683
|
+
const success = mergeDeepRight(input$1, {
|
|
2693
2684
|
boxShadow: 'none',
|
|
2694
2685
|
outline: {
|
|
2695
2686
|
color: success__resting.rgba
|
|
@@ -2901,15 +2892,21 @@ const Textarea = /*#__PURE__*/react.forwardRef(function Textarea({
|
|
|
2901
2892
|
variant,
|
|
2902
2893
|
...other
|
|
2903
2894
|
};
|
|
2904
|
-
const
|
|
2895
|
+
const leftAdornmentStyles = {
|
|
2905
2896
|
style: {
|
|
2906
2897
|
alignItems: 'flex-start'
|
|
2907
2898
|
}
|
|
2908
2899
|
};
|
|
2900
|
+
const rigthAdornmentStyles = {
|
|
2901
|
+
style: {
|
|
2902
|
+
alignItems: 'flex-start',
|
|
2903
|
+
pointerEvents: 'none'
|
|
2904
|
+
}
|
|
2905
|
+
};
|
|
2909
2906
|
return /*#__PURE__*/jsxRuntime.jsx(Input$4, {
|
|
2910
2907
|
as: "textarea",
|
|
2911
|
-
rightAdornmentsProps:
|
|
2912
|
-
leftAdornmentsProps:
|
|
2908
|
+
rightAdornmentsProps: rigthAdornmentStyles,
|
|
2909
|
+
leftAdornmentsProps: leftAdornmentStyles,
|
|
2913
2910
|
style: {
|
|
2914
2911
|
height: 'auto'
|
|
2915
2912
|
},
|
|
@@ -2947,13 +2944,14 @@ const TextField = /*#__PURE__*/react.forwardRef(function TextField({
|
|
|
2947
2944
|
...other
|
|
2948
2945
|
}, ref) {
|
|
2949
2946
|
const helperTextId = edsUtils.useId(null, 'helpertext');
|
|
2947
|
+
const hasRightAdornments = Boolean(unit || inputIcon);
|
|
2950
2948
|
let fieldProps = {
|
|
2951
2949
|
'aria-invalid': variant === 'error' || undefined,
|
|
2952
2950
|
disabled,
|
|
2953
2951
|
placeholder,
|
|
2954
2952
|
id,
|
|
2955
2953
|
variant,
|
|
2956
|
-
rightAdornments: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2954
|
+
rightAdornments: hasRightAdornments && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2957
2955
|
children: [inputIcon, /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
2958
2956
|
children: unit
|
|
2959
2957
|
})]
|
|
@@ -7349,7 +7347,7 @@ const Breadcrumbs$1 = /*#__PURE__*/react.forwardRef(function Breadcrumbs({
|
|
|
7349
7347
|
}, "collapsed"), allCrumbs[allCrumbs.length - 1]];
|
|
7350
7348
|
};
|
|
7351
7349
|
const allCrumbs = react.Children.toArray(children).map((child, index) =>
|
|
7352
|
-
|
|
7350
|
+
/*#__PURE__*/
|
|
7353
7351
|
// eslint-disable-next-line react/no-array-index-key
|
|
7354
7352
|
jsxRuntime.jsxs(react.Fragment, {
|
|
7355
7353
|
children: [/*#__PURE__*/jsxRuntime.jsx(ListItem$1, {
|
|
@@ -7634,7 +7632,7 @@ const Item = styled__default.default.button.attrs(({
|
|
|
7634
7632
|
$active
|
|
7635
7633
|
}) => $active && styled.css(["background:", ";*{color:", ";}"], activeToken.background, activeToken.typography.color), ({
|
|
7636
7634
|
disabled
|
|
7637
|
-
}) => disabled ? styled.css(["*{color:", ";}svg{fill:", ";}
|
|
7635
|
+
}) => disabled ? styled.css(["*{color:", ";}svg{fill:", ";}@media (hover:hover) and (pointer:fine){&:hover{cursor:not-allowed;}}"], disabledToken.typography.color, icon.states.disabled.typography.color) : styled.css(["@media (hover:hover) and (pointer:fine){&:hover{cursor:pointer;background:", ";}}&:focus-visible{z-index:3;", "}"], hover.background, edsUtils.outlineTemplate(focus$2.outline)));
|
|
7638
7636
|
const Content = styled__default.default.div.withConfig({
|
|
7639
7637
|
displayName: "MenuItem__Content",
|
|
7640
7638
|
componentId: "sc-1g9fpbe-1"
|
|
@@ -9335,7 +9333,7 @@ const selectTokens = {
|
|
|
9335
9333
|
}
|
|
9336
9334
|
}
|
|
9337
9335
|
};
|
|
9338
|
-
const multiSelect = mergeDeepRight
|
|
9336
|
+
const multiSelect = mergeDeepRight(selectTokens, {
|
|
9339
9337
|
spacings: {
|
|
9340
9338
|
top: '0',
|
|
9341
9339
|
bottom: '0',
|
|
@@ -9428,19 +9426,25 @@ const StyledList = styled__default.default(List$1).withConfig({
|
|
|
9428
9426
|
})(({
|
|
9429
9427
|
theme
|
|
9430
9428
|
}) => styled.css(["background-color:", ";box-shadow:", ";", " overflow-y:auto;overflow-x:hidden;padding:0;display:grid;@supports (-moz-appearance:none){scrollbar-width:thin;}"], theme.background, theme.boxShadow, edsUtils.bordersTemplate(theme.border)));
|
|
9429
|
+
const StyledPopover = styled__default.default('div').withConfig({
|
|
9430
|
+
shouldForwardProp: () => true //workaround to avoid warning until popover gets added to react types
|
|
9431
|
+
}).withConfig({
|
|
9432
|
+
displayName: "Autocomplete__StyledPopover",
|
|
9433
|
+
componentId: "sc-yvif0e-2"
|
|
9434
|
+
})(["inset:unset;border:0;padding:0;margin:0;overflow:visible;"]);
|
|
9431
9435
|
const HelperText = styled__default.default(TextfieldHelperText).withConfig({
|
|
9432
9436
|
displayName: "Autocomplete__HelperText",
|
|
9433
|
-
componentId: "sc-yvif0e-
|
|
9437
|
+
componentId: "sc-yvif0e-3"
|
|
9434
9438
|
})(["margin-top:8px;margin-left:8px;"]);
|
|
9435
9439
|
const AutocompleteNoOptions = styled__default.default(AutocompleteOption).withConfig({
|
|
9436
9440
|
displayName: "Autocomplete__AutocompleteNoOptions",
|
|
9437
|
-
componentId: "sc-yvif0e-
|
|
9441
|
+
componentId: "sc-yvif0e-4"
|
|
9438
9442
|
})(({
|
|
9439
9443
|
theme
|
|
9440
9444
|
}) => styled.css(["color:", ";"], theme.entities.noOptions.typography.color));
|
|
9441
|
-
const StyledButton = styled__default.default(Button$1).withConfig({
|
|
9445
|
+
const StyledButton$1 = styled__default.default(Button$1).withConfig({
|
|
9442
9446
|
displayName: "Autocomplete__StyledButton",
|
|
9443
|
-
componentId: "sc-yvif0e-
|
|
9447
|
+
componentId: "sc-yvif0e-5"
|
|
9444
9448
|
})(({
|
|
9445
9449
|
theme: {
|
|
9446
9450
|
entities: {
|
|
@@ -9473,9 +9477,9 @@ const findIndex = ({
|
|
|
9473
9477
|
};
|
|
9474
9478
|
const isEvent = (val, key) => /^on[A-Z](.*)/.test(key) && typeof val === 'function';
|
|
9475
9479
|
function mergeEventsFromRight(props1, props2) {
|
|
9476
|
-
const events1 = pickBy
|
|
9477
|
-
const events2 = pickBy
|
|
9478
|
-
return mergeWith
|
|
9480
|
+
const events1 = pickBy(isEvent, props1);
|
|
9481
|
+
const events2 = pickBy(isEvent, props2);
|
|
9482
|
+
return mergeWith((event1, event2) => {
|
|
9479
9483
|
return (...args) => {
|
|
9480
9484
|
event1(...args);
|
|
9481
9485
|
event2(...args);
|
|
@@ -9524,6 +9528,20 @@ const findPrevIndex = ({
|
|
|
9524
9528
|
}
|
|
9525
9529
|
return prevIndex;
|
|
9526
9530
|
};
|
|
9531
|
+
|
|
9532
|
+
/*When a user clicks the StyledList scrollbar, the input looses focus which breaks downshift
|
|
9533
|
+
* keyboard navigation in the list. This code returns focus to the input on mouseUp
|
|
9534
|
+
*/
|
|
9535
|
+
const handleListFocus = e => {
|
|
9536
|
+
e.preventDefault();
|
|
9537
|
+
e.stopPropagation();
|
|
9538
|
+
window?.addEventListener('mouseup', () => {
|
|
9539
|
+
e.relatedTarget?.focus();
|
|
9540
|
+
}, {
|
|
9541
|
+
once: true
|
|
9542
|
+
});
|
|
9543
|
+
};
|
|
9544
|
+
const defaultOptionDisabled = () => false;
|
|
9527
9545
|
function AutocompleteInner(props, ref) {
|
|
9528
9546
|
const {
|
|
9529
9547
|
options = [],
|
|
@@ -9542,7 +9560,7 @@ function AutocompleteInner(props, ref) {
|
|
|
9542
9560
|
allowSelectAll,
|
|
9543
9561
|
initialSelectedOptions = [],
|
|
9544
9562
|
disablePortal,
|
|
9545
|
-
optionDisabled =
|
|
9563
|
+
optionDisabled = defaultOptionDisabled,
|
|
9546
9564
|
optionsFilter,
|
|
9547
9565
|
autoWidth,
|
|
9548
9566
|
placeholder,
|
|
@@ -9557,6 +9575,9 @@ function AutocompleteInner(props, ref) {
|
|
|
9557
9575
|
variant,
|
|
9558
9576
|
...other
|
|
9559
9577
|
} = props;
|
|
9578
|
+
if (disablePortal) {
|
|
9579
|
+
console.warn('Autocomplete "disablePortal" prop has been deprecated. Autocomplete now uses the native popover api');
|
|
9580
|
+
}
|
|
9560
9581
|
const isControlled = Boolean(selectedOptions);
|
|
9561
9582
|
const [inputOptions, setInputOptions] = react.useState(options);
|
|
9562
9583
|
const [_availableItems, setAvailableItems] = react.useState(inputOptions);
|
|
@@ -9571,13 +9592,8 @@ function AutocompleteInner(props, ref) {
|
|
|
9571
9592
|
if (showSelectAll) return [AllSymbol, ..._availableItems];
|
|
9572
9593
|
return _availableItems;
|
|
9573
9594
|
}, [_availableItems, showSelectAll]);
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
setSelectedItems([]);
|
|
9577
|
-
} else {
|
|
9578
|
-
setSelectedItems(inputOptions);
|
|
9579
|
-
}
|
|
9580
|
-
};
|
|
9595
|
+
|
|
9596
|
+
//issue 2304, update dataset when options are added dynamically
|
|
9581
9597
|
react.useEffect(() => {
|
|
9582
9598
|
const availableHash = JSON.stringify(inputOptions);
|
|
9583
9599
|
const optionsHash = JSON.stringify(options);
|
|
@@ -9588,7 +9604,6 @@ function AutocompleteInner(props, ref) {
|
|
|
9588
9604
|
react.useEffect(() => {
|
|
9589
9605
|
setAvailableItems(inputOptions);
|
|
9590
9606
|
}, [inputOptions]);
|
|
9591
|
-
const disabledItems = react.useMemo(() => options.filter(optionDisabled), [options, optionDisabled]);
|
|
9592
9607
|
const {
|
|
9593
9608
|
density
|
|
9594
9609
|
} = useEds();
|
|
@@ -9624,15 +9639,27 @@ function AutocompleteInner(props, ref) {
|
|
|
9624
9639
|
addSelectedItem,
|
|
9625
9640
|
removeSelectedItem,
|
|
9626
9641
|
selectedItems,
|
|
9627
|
-
reset: resetSelection,
|
|
9628
9642
|
setSelectedItems
|
|
9629
9643
|
} = downshift.useMultipleSelection(multipleSelectionProps);
|
|
9644
|
+
const enabledItems = react.useMemo(() => {
|
|
9645
|
+
const disabledItemsSet = new Set(inputOptions.filter(optionDisabled));
|
|
9646
|
+
return inputOptions.filter(x => !disabledItemsSet.has(x));
|
|
9647
|
+
}, [inputOptions, optionDisabled]);
|
|
9648
|
+
const selectedDisabledItemsSet = react.useMemo(() => new Set(selectedItems.filter(optionDisabled)), [selectedItems, optionDisabled]);
|
|
9649
|
+
const selectedEnabledItems = react.useMemo(() => selectedItems.filter(x => !selectedDisabledItemsSet.has(x)), [selectedItems, selectedDisabledItemsSet]);
|
|
9630
9650
|
const allSelectedState = react.useMemo(() => {
|
|
9631
|
-
if (!
|
|
9632
|
-
if (
|
|
9633
|
-
if (
|
|
9651
|
+
if (!enabledItems || !selectedEnabledItems) return 'NONE';
|
|
9652
|
+
if (enabledItems.length === selectedEnabledItems.length) return 'ALL';
|
|
9653
|
+
if (enabledItems.length != selectedEnabledItems.length && selectedEnabledItems.length > 0) return 'SOME';
|
|
9634
9654
|
return 'NONE';
|
|
9635
|
-
}, [
|
|
9655
|
+
}, [enabledItems, selectedEnabledItems]);
|
|
9656
|
+
const toggleAllSelected = () => {
|
|
9657
|
+
if (selectedEnabledItems.length === enabledItems.length) {
|
|
9658
|
+
setSelectedItems([...selectedDisabledItemsSet]);
|
|
9659
|
+
} else {
|
|
9660
|
+
setSelectedItems([...enabledItems, ...selectedDisabledItemsSet]);
|
|
9661
|
+
}
|
|
9662
|
+
};
|
|
9636
9663
|
const getLabel = react.useCallback(item => {
|
|
9637
9664
|
//note: non strict check for null or undefined to allow 0
|
|
9638
9665
|
if (item == null) {
|
|
@@ -9691,7 +9718,14 @@ function AutocompleteInner(props, ref) {
|
|
|
9691
9718
|
highlightedIndex,
|
|
9692
9719
|
type
|
|
9693
9720
|
}) {
|
|
9694
|
-
if (type
|
|
9721
|
+
if (type == downshift.useCombobox.stateChangeTypes.InputClick || type == downshift.useCombobox.stateChangeTypes.InputKeyDownArrowDown && !isOpen || type == downshift.useCombobox.stateChangeTypes.InputKeyDownArrowUp && !isOpen) {
|
|
9722
|
+
//needs delay for dropdown to render before calling scroll
|
|
9723
|
+
setTimeout(() => {
|
|
9724
|
+
rowVirtualizer.scrollToIndex(highlightedIndex, {
|
|
9725
|
+
align: allowSelectAll ? 'center' : 'auto'
|
|
9726
|
+
});
|
|
9727
|
+
}, 1);
|
|
9728
|
+
} else if (type !== downshift.useCombobox.stateChangeTypes.ItemMouseMove && type !== downshift.useCombobox.stateChangeTypes.MenuMouseLeave && highlightedIndex >= 0) {
|
|
9695
9729
|
rowVirtualizer.scrollToIndex(highlightedIndex, {
|
|
9696
9730
|
align: allowSelectAll ? 'center' : 'auto'
|
|
9697
9731
|
});
|
|
@@ -9802,7 +9836,7 @@ function AutocompleteInner(props, ref) {
|
|
|
9802
9836
|
}
|
|
9803
9837
|
}
|
|
9804
9838
|
if (multiple) {
|
|
9805
|
-
placeholderText = typeof placeholderText !== 'undefined' ? placeholderText : `${selectedItems.length}/${
|
|
9839
|
+
placeholderText = typeof placeholderText !== 'undefined' ? placeholderText : `${selectedItems.length}/${inputOptions.length} selected`;
|
|
9806
9840
|
comboBoxProps = {
|
|
9807
9841
|
...comboBoxProps,
|
|
9808
9842
|
selectedItem: null,
|
|
@@ -9894,11 +9928,6 @@ function AutocompleteInner(props, ref) {
|
|
|
9894
9928
|
inputValue,
|
|
9895
9929
|
reset: resetCombobox
|
|
9896
9930
|
} = downshift.useCombobox(comboBoxProps);
|
|
9897
|
-
react.useEffect(() => {
|
|
9898
|
-
if (isControlled) {
|
|
9899
|
-
setSelectedItems(selectedOptions);
|
|
9900
|
-
}
|
|
9901
|
-
}, [isControlled, selectedOptions, setSelectedItems]);
|
|
9902
9931
|
const {
|
|
9903
9932
|
x,
|
|
9904
9933
|
y,
|
|
@@ -9907,8 +9936,8 @@ function AutocompleteInner(props, ref) {
|
|
|
9907
9936
|
strategy
|
|
9908
9937
|
} = react$1.useFloating({
|
|
9909
9938
|
placement: 'bottom-start',
|
|
9910
|
-
middleware: [react$1.offset(4), react$1.flip(
|
|
9911
|
-
|
|
9939
|
+
middleware: [react$1.offset(4), react$1.flip({
|
|
9940
|
+
boundary: document?.body
|
|
9912
9941
|
}), react$1.size({
|
|
9913
9942
|
apply({
|
|
9914
9943
|
rects,
|
|
@@ -9930,25 +9959,31 @@ function AutocompleteInner(props, ref) {
|
|
|
9930
9959
|
return react$1.autoUpdate(refs.reference.current, refs.floating.current, update);
|
|
9931
9960
|
}
|
|
9932
9961
|
}, [refs.reference, refs.floating, update, isOpen]);
|
|
9962
|
+
edsUtils.useIsomorphicLayoutEffect(() => {
|
|
9963
|
+
if (isOpen) {
|
|
9964
|
+
refs.floating.current.showPopover();
|
|
9965
|
+
} else {
|
|
9966
|
+
refs.floating.current.hidePopover();
|
|
9967
|
+
}
|
|
9968
|
+
}, [isOpen, refs.floating]);
|
|
9933
9969
|
const clear = () => {
|
|
9934
9970
|
resetCombobox();
|
|
9935
|
-
|
|
9971
|
+
//dont clear items if they are selected and disabled
|
|
9972
|
+
setSelectedItems([...selectedDisabledItemsSet]);
|
|
9936
9973
|
setTypedInputValue('');
|
|
9937
9974
|
};
|
|
9938
9975
|
const showClearButton = (selectedItems.length > 0 || inputValue) && !readOnly && !hideClearButton;
|
|
9939
|
-
const showNoOptions = isOpen && !availableItems.length &&
|
|
9976
|
+
const showNoOptions = isOpen && !availableItems.length && noOptionsText.length > 0;
|
|
9940
9977
|
const selectedItemsLabels = react.useMemo(() => selectedItems.map(getLabel), [selectedItems, getLabel]);
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
const inDialog = edsUtils.useIsInDialog(refs.domReference.current);
|
|
9944
|
-
const optionsList = /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
9978
|
+
const optionsList = /*#__PURE__*/jsxRuntime.jsx(StyledPopover, {
|
|
9979
|
+
popover: "manual",
|
|
9945
9980
|
...getFloatingProps({
|
|
9946
9981
|
ref: refs.setFloating,
|
|
9982
|
+
onFocus: handleListFocus,
|
|
9947
9983
|
style: {
|
|
9948
9984
|
position: strategy,
|
|
9949
9985
|
top: y || 0,
|
|
9950
|
-
left: x || 0
|
|
9951
|
-
zIndex: 1500
|
|
9986
|
+
left: x || 0
|
|
9952
9987
|
}
|
|
9953
9988
|
}),
|
|
9954
9989
|
children: /*#__PURE__*/jsxRuntime.jsxs(StyledList, {
|
|
@@ -10063,7 +10098,7 @@ function AutocompleteInner(props, ref) {
|
|
|
10063
10098
|
rightAdornments: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
10064
10099
|
children: [loading && /*#__PURE__*/jsxRuntime.jsx(Progress.Circular, {
|
|
10065
10100
|
size: 16
|
|
10066
|
-
}), showClearButton && /*#__PURE__*/jsxRuntime.jsx(StyledButton, {
|
|
10101
|
+
}), showClearButton && /*#__PURE__*/jsxRuntime.jsx(StyledButton$1, {
|
|
10067
10102
|
variant: "ghost_icon",
|
|
10068
10103
|
disabled: disabled || readOnly,
|
|
10069
10104
|
"aria-label": 'clear options',
|
|
@@ -10073,7 +10108,7 @@ function AutocompleteInner(props, ref) {
|
|
|
10073
10108
|
data: edsIcons.close,
|
|
10074
10109
|
size: 16
|
|
10075
10110
|
})
|
|
10076
|
-
}), !readOnly && /*#__PURE__*/jsxRuntime.jsx(StyledButton, {
|
|
10111
|
+
}), !readOnly && /*#__PURE__*/jsxRuntime.jsx(StyledButton$1, {
|
|
10077
10112
|
variant: "ghost_icon",
|
|
10078
10113
|
...getToggleButtonProps({
|
|
10079
10114
|
disabled: disabled || readOnly
|
|
@@ -10092,10 +10127,7 @@ function AutocompleteInner(props, ref) {
|
|
|
10092
10127
|
color: variant ? tokens.variants[variant].typography.color : undefined,
|
|
10093
10128
|
text: helperText,
|
|
10094
10129
|
icon: helperIcon
|
|
10095
|
-
}),
|
|
10096
|
-
id: "eds-autocomplete-container",
|
|
10097
|
-
children: optionsList
|
|
10098
|
-
})]
|
|
10130
|
+
}), optionsList]
|
|
10099
10131
|
})
|
|
10100
10132
|
});
|
|
10101
10133
|
}
|
|
@@ -10973,6 +11005,1182 @@ SideBar.Button.displayName = 'SideBar.Button';
|
|
|
10973
11005
|
SideBar.Accordion.displayName = 'SideBar.Accordion';
|
|
10974
11006
|
SideBar.AccordionItem.displayName = 'SideBar.AccordionItem';
|
|
10975
11007
|
|
|
11008
|
+
const StyledCell = styled__default.default(Typography).withConfig({
|
|
11009
|
+
displayName: "CalendarCell__StyledCell",
|
|
11010
|
+
componentId: "sc-y5ycmg-0"
|
|
11011
|
+
})(["display:flex;justify-content:center;align-items:center;cursor:pointer;&:hover{background-color:", ";}&:focus{outline:2px dashed rgba(0,112,121,1);}", " ", " ", " ", " ", " ", ""], edsTokens.tokens.colors.interactive.table__cell__fill_hover.rgba, ({
|
|
11012
|
+
$selected
|
|
11013
|
+
}) => $selected && `background-color: ${edsTokens.tokens.colors.interactive.primary__selected_highlight.rgba};`, ({
|
|
11014
|
+
$hidden
|
|
11015
|
+
}) => $hidden && `visibility: hidden;`, ({
|
|
11016
|
+
$highlight
|
|
11017
|
+
}) => {
|
|
11018
|
+
switch ($highlight) {
|
|
11019
|
+
case 'SINGLE':
|
|
11020
|
+
case 'NONE':
|
|
11021
|
+
case 'BOTH':
|
|
11022
|
+
return 'border-radius: 50%;';
|
|
11023
|
+
case 'END':
|
|
11024
|
+
return 'border-radius: 0% 50% 50% 0;';
|
|
11025
|
+
case 'START':
|
|
11026
|
+
return 'border-radius: 50% 0% 0% 50%;';
|
|
11027
|
+
case 'RANGE':
|
|
11028
|
+
return '';
|
|
11029
|
+
}
|
|
11030
|
+
}, ({
|
|
11031
|
+
$disabled
|
|
11032
|
+
}) => $disabled && `
|
|
11033
|
+
|
|
11034
|
+
color: ${edsTokens.tokens.colors.interactive.disabled__text.rgba};
|
|
11035
|
+
&:hover {
|
|
11036
|
+
background-color: transparent;
|
|
11037
|
+
cursor: not-allowed;
|
|
11038
|
+
}
|
|
11039
|
+
`, ({
|
|
11040
|
+
$selected,
|
|
11041
|
+
$disabled
|
|
11042
|
+
}) => {
|
|
11043
|
+
if ($selected && $disabled) {
|
|
11044
|
+
return `background-color: ${edsTokens.tokens.colors.interactive.warning__highlight.rgba};
|
|
11045
|
+
&:hover {
|
|
11046
|
+
background-color: ${edsTokens.tokens.colors.interactive.warning__highlight.rgba};
|
|
11047
|
+
}`;
|
|
11048
|
+
}
|
|
11049
|
+
}, ({
|
|
11050
|
+
$density
|
|
11051
|
+
}) => {
|
|
11052
|
+
switch ($density) {
|
|
11053
|
+
case 'compact':
|
|
11054
|
+
return `
|
|
11055
|
+
height: 32px;
|
|
11056
|
+
width: 32px;
|
|
11057
|
+
padding: 2px;
|
|
11058
|
+
`;
|
|
11059
|
+
case 'comfortable':
|
|
11060
|
+
return `
|
|
11061
|
+
height: 40px;
|
|
11062
|
+
width: 40px;
|
|
11063
|
+
padding: 4px;
|
|
11064
|
+
`;
|
|
11065
|
+
}
|
|
11066
|
+
});
|
|
11067
|
+
const StyledTd = styled__default.default.td.withConfig({
|
|
11068
|
+
displayName: "CalendarCell__StyledTd",
|
|
11069
|
+
componentId: "sc-y5ycmg-1"
|
|
11070
|
+
})(["border:0;border-spacing:0;"]);
|
|
11071
|
+
|
|
11072
|
+
/**
|
|
11073
|
+
* CalendarCell is used to represent a single cell in {@link Calendar} and {@link RangeCalendar}
|
|
11074
|
+
*/
|
|
11075
|
+
function CalendarCell({
|
|
11076
|
+
state,
|
|
11077
|
+
date
|
|
11078
|
+
}) {
|
|
11079
|
+
const ref = react.useRef(null);
|
|
11080
|
+
const {
|
|
11081
|
+
density
|
|
11082
|
+
} = useEds();
|
|
11083
|
+
const {
|
|
11084
|
+
cellProps,
|
|
11085
|
+
buttonProps,
|
|
11086
|
+
isSelected,
|
|
11087
|
+
isOutsideVisibleRange,
|
|
11088
|
+
isDisabled,
|
|
11089
|
+
isUnavailable,
|
|
11090
|
+
formattedDate
|
|
11091
|
+
} = reactAria.useCalendarCell({
|
|
11092
|
+
date
|
|
11093
|
+
}, state, ref);
|
|
11094
|
+
|
|
11095
|
+
/**
|
|
11096
|
+
* Determines how the selection should be highlighted
|
|
11097
|
+
* If range is selected, it will highlight start - end, with differing border-radius
|
|
11098
|
+
*/
|
|
11099
|
+
const isHighlight = react.useMemo(() => {
|
|
11100
|
+
if (isSelected && 'highlightedRange' in state) {
|
|
11101
|
+
const start = state.highlightedRange.start;
|
|
11102
|
+
const end = state.highlightedRange.end;
|
|
11103
|
+
const startSame = start.day === date.day && start.month === date.month && start.year === date.year;
|
|
11104
|
+
const endSame = end.day === date.day && end.month === date.month && end.year === date.year;
|
|
11105
|
+
if (startSame && endSame) {
|
|
11106
|
+
return 'BOTH';
|
|
11107
|
+
}
|
|
11108
|
+
if (startSame) {
|
|
11109
|
+
return 'START';
|
|
11110
|
+
} else if (endSame) {
|
|
11111
|
+
return 'END';
|
|
11112
|
+
} else {
|
|
11113
|
+
return 'RANGE';
|
|
11114
|
+
}
|
|
11115
|
+
} else if (isSelected) {
|
|
11116
|
+
return 'SINGLE';
|
|
11117
|
+
}
|
|
11118
|
+
return 'NONE';
|
|
11119
|
+
}, [date.day, date.month, date.year, isSelected, state]);
|
|
11120
|
+
return /*#__PURE__*/jsxRuntime.jsx(StyledTd, {
|
|
11121
|
+
...cellProps,
|
|
11122
|
+
style: {
|
|
11123
|
+
border: 0,
|
|
11124
|
+
borderSpacing: 0,
|
|
11125
|
+
padding: 0
|
|
11126
|
+
},
|
|
11127
|
+
children: /*#__PURE__*/jsxRuntime.jsx(StyledCell, {
|
|
11128
|
+
...buttonProps,
|
|
11129
|
+
as: 'div',
|
|
11130
|
+
ref: ref,
|
|
11131
|
+
tabIndex: 0,
|
|
11132
|
+
$hidden: isOutsideVisibleRange,
|
|
11133
|
+
className: `cell ${isSelected ? 'selected' : ''} ${isUnavailable ? 'unavailable' : ''}${isDisabled ? 'disabled' : ''}`,
|
|
11134
|
+
$selected: isSelected,
|
|
11135
|
+
$highlight: isHighlight,
|
|
11136
|
+
$disabled: isDisabled || isUnavailable,
|
|
11137
|
+
$density: density,
|
|
11138
|
+
children: formattedDate
|
|
11139
|
+
})
|
|
11140
|
+
});
|
|
11141
|
+
}
|
|
11142
|
+
|
|
11143
|
+
// Disable no-autofocus - it's not the native autofocus attribute, but react-aria's autoFocus prop
|
|
11144
|
+
/* eslint-disable jsx-a11y/no-autofocus */
|
|
11145
|
+
const Grid = styled__default.default.div.withConfig({
|
|
11146
|
+
displayName: "YearGrid__Grid",
|
|
11147
|
+
componentId: "sc-1l9jho8-0"
|
|
11148
|
+
})(["display:grid;grid-template-columns:repeat(6,1fr);grid-gap:8px;margin:8px;"]);
|
|
11149
|
+
const GridColumn = styled__default.default.button.withConfig({
|
|
11150
|
+
displayName: "YearGrid__GridColumn",
|
|
11151
|
+
componentId: "sc-1l9jho8-1"
|
|
11152
|
+
})(["background-color:transparent;outline:none;border:none;display:flex;justify-content:center;cursor:pointer;padding:8px;font-size:", ";font-family:", ";font-weight:", ";line-height:", ";color:", ";border-radius:999px;", ";&:hover{background-color:#f0f0f0;}&:focus{outline:2px dashed ", ";}"], edsTokens.tokens.typography.navigation.button.fontSize, edsTokens.tokens.typography.navigation.button.fontFamily, edsTokens.tokens.typography.navigation.button.fontWeight, edsTokens.tokens.typography.navigation.button.lineHeight, edsTokens.tokens.colors.text.static_icons__default.rgba, ({
|
|
11153
|
+
$active
|
|
11154
|
+
}) => $active ? `background-color: ${edsTokens.tokens.colors.interactive.primary__selected_highlight.rgba}` : '', edsTokens.tokens.colors.interactive.primary__resting.rgba);
|
|
11155
|
+
const GridFocusManager = ({
|
|
11156
|
+
year: selectedYear,
|
|
11157
|
+
setFocusedYear
|
|
11158
|
+
}) => {
|
|
11159
|
+
const focusManager = reactAria.useFocusManager();
|
|
11160
|
+
const onKeyDown = e => {
|
|
11161
|
+
const target = e.currentTarget;
|
|
11162
|
+
const parent = target.parentElement;
|
|
11163
|
+
switch (e.key) {
|
|
11164
|
+
case 'ArrowRight':
|
|
11165
|
+
e.preventDefault();
|
|
11166
|
+
focusManager.focusNext({
|
|
11167
|
+
wrap: true
|
|
11168
|
+
});
|
|
11169
|
+
break;
|
|
11170
|
+
case 'ArrowLeft':
|
|
11171
|
+
e.preventDefault();
|
|
11172
|
+
focusManager.focusPrevious({
|
|
11173
|
+
wrap: true
|
|
11174
|
+
});
|
|
11175
|
+
break;
|
|
11176
|
+
case 'ArrowDown':
|
|
11177
|
+
{
|
|
11178
|
+
e.preventDefault();
|
|
11179
|
+
const selfIndex = Array.from(parent.children).indexOf(target);
|
|
11180
|
+
const focusElement = Array.from(parent.children).at(selfIndex + 5);
|
|
11181
|
+
focusManager.focusNext({
|
|
11182
|
+
from: focusElement
|
|
11183
|
+
});
|
|
11184
|
+
break;
|
|
11185
|
+
}
|
|
11186
|
+
case 'ArrowUp':
|
|
11187
|
+
{
|
|
11188
|
+
e.preventDefault();
|
|
11189
|
+
const selfIndex = Array.from(parent.children).indexOf(target);
|
|
11190
|
+
const focusElement = Array.from(parent.children).at(selfIndex - 5);
|
|
11191
|
+
focusManager.focusPrevious({
|
|
11192
|
+
from: focusElement
|
|
11193
|
+
});
|
|
11194
|
+
break;
|
|
11195
|
+
}
|
|
11196
|
+
}
|
|
11197
|
+
};
|
|
11198
|
+
const years = Array.from({
|
|
11199
|
+
length: 36
|
|
11200
|
+
}, (_, i) => i + (selectedYear - 30 / 2));
|
|
11201
|
+
return years.map(year => /*#__PURE__*/jsxRuntime.jsx(GridColumn, {
|
|
11202
|
+
$active: selectedYear === year,
|
|
11203
|
+
onKeyDown: onKeyDown,
|
|
11204
|
+
onClick: () => setFocusedYear(year),
|
|
11205
|
+
"aria-label": `Set year to ${year}`,
|
|
11206
|
+
tabIndex: 0,
|
|
11207
|
+
children: year
|
|
11208
|
+
}, year));
|
|
11209
|
+
};
|
|
11210
|
+
const YearGrid = ({
|
|
11211
|
+
setFocusedYear,
|
|
11212
|
+
year: selectedYear
|
|
11213
|
+
}) => {
|
|
11214
|
+
return /*#__PURE__*/jsxRuntime.jsx(Grid, {
|
|
11215
|
+
children: /*#__PURE__*/jsxRuntime.jsx(reactAria.FocusScope, {
|
|
11216
|
+
contain: true,
|
|
11217
|
+
restoreFocus: true,
|
|
11218
|
+
autoFocus: true,
|
|
11219
|
+
children: /*#__PURE__*/jsxRuntime.jsx(GridFocusManager, {
|
|
11220
|
+
year: selectedYear,
|
|
11221
|
+
setFocusedYear: setFocusedYear
|
|
11222
|
+
})
|
|
11223
|
+
})
|
|
11224
|
+
});
|
|
11225
|
+
};
|
|
11226
|
+
|
|
11227
|
+
/* eslint-disable react/no-array-index-key */
|
|
11228
|
+
|
|
11229
|
+
function CalendarGrid({
|
|
11230
|
+
state,
|
|
11231
|
+
showYearPicker,
|
|
11232
|
+
setShowYearPicker,
|
|
11233
|
+
...props
|
|
11234
|
+
}) {
|
|
11235
|
+
const {
|
|
11236
|
+
locale
|
|
11237
|
+
} = reactAria.useLocale();
|
|
11238
|
+
const {
|
|
11239
|
+
gridProps,
|
|
11240
|
+
headerProps,
|
|
11241
|
+
weekDays
|
|
11242
|
+
} = reactAria.useCalendarGrid({
|
|
11243
|
+
...props,
|
|
11244
|
+
weekdayStyle: 'long'
|
|
11245
|
+
}, state);
|
|
11246
|
+
|
|
11247
|
+
// Get the number of weeks in the month so that we can render the proper number of rows.
|
|
11248
|
+
const howManyWeeksInMonth = date.getWeeksInMonth(state.visibleRange.start, locale);
|
|
11249
|
+
const weeksInMonthArray = [...new Array(howManyWeeksInMonth).keys()];
|
|
11250
|
+
return showYearPicker ? /*#__PURE__*/jsxRuntime.jsx(YearGrid, {
|
|
11251
|
+
year: state.focusedDate.year,
|
|
11252
|
+
setFocusedYear: year => {
|
|
11253
|
+
state.setFocusedDate(state.focusedDate.set({
|
|
11254
|
+
year
|
|
11255
|
+
}));
|
|
11256
|
+
setShowYearPicker(false);
|
|
11257
|
+
}
|
|
11258
|
+
}) : /*#__PURE__*/jsxRuntime.jsxs("table", {
|
|
11259
|
+
...gridProps,
|
|
11260
|
+
style: {
|
|
11261
|
+
borderSpacing: '0px'
|
|
11262
|
+
},
|
|
11263
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("thead", {
|
|
11264
|
+
...headerProps,
|
|
11265
|
+
children: /*#__PURE__*/jsxRuntime.jsx("tr", {
|
|
11266
|
+
children: weekDays.map((day, index) => /*#__PURE__*/jsxRuntime.jsx("th", {
|
|
11267
|
+
style: {
|
|
11268
|
+
textAlign: 'center'
|
|
11269
|
+
},
|
|
11270
|
+
abbr: day,
|
|
11271
|
+
children: day.charAt(0).toLocaleUpperCase()
|
|
11272
|
+
}, `${day}-${index}`))
|
|
11273
|
+
})
|
|
11274
|
+
}), /*#__PURE__*/jsxRuntime.jsx("tbody", {
|
|
11275
|
+
children: weeksInMonthArray.map(weekIndex => /*#__PURE__*/jsxRuntime.jsx("tr", {
|
|
11276
|
+
children: state.getDatesInWeek(weekIndex).map((date, i) => date ? /*#__PURE__*/jsxRuntime.jsx(CalendarCell, {
|
|
11277
|
+
state: state,
|
|
11278
|
+
date: date
|
|
11279
|
+
}, date.toString()) : /*#__PURE__*/jsxRuntime.jsx("td", {}, `placeholder-${i}`))
|
|
11280
|
+
}, weekIndex))
|
|
11281
|
+
})]
|
|
11282
|
+
});
|
|
11283
|
+
}
|
|
11284
|
+
|
|
11285
|
+
const HeaderWrapper = styled__default.default.div.withConfig({
|
|
11286
|
+
displayName: "CalendarHeader__HeaderWrapper",
|
|
11287
|
+
componentId: "sc-kuy15-0"
|
|
11288
|
+
})(["display:flex;justify-content:space-between;align-items:center;text-transform:capitalize;width:100%;"]);
|
|
11289
|
+
function TodayPicker({
|
|
11290
|
+
onClick,
|
|
11291
|
+
disabled
|
|
11292
|
+
}) {
|
|
11293
|
+
const today = new Date();
|
|
11294
|
+
return /*#__PURE__*/jsxRuntime.jsx(Button$1, {
|
|
11295
|
+
disabled: disabled,
|
|
11296
|
+
onClick: () => onClick(new date.CalendarDate(today.getFullYear(), today.getMonth() + 1, today.getDate())),
|
|
11297
|
+
variant: 'ghost',
|
|
11298
|
+
style: {
|
|
11299
|
+
marginLeft: 16
|
|
11300
|
+
},
|
|
11301
|
+
children: "Today"
|
|
11302
|
+
});
|
|
11303
|
+
}
|
|
11304
|
+
const HeaderActions = styled__default.default.div.withConfig({
|
|
11305
|
+
displayName: "CalendarHeader__HeaderActions",
|
|
11306
|
+
componentId: "sc-kuy15-1"
|
|
11307
|
+
})(["display:flex;align-items:center;width:100%;"]);
|
|
11308
|
+
|
|
11309
|
+
/**
|
|
11310
|
+
* The default header for the calendar components if no custom header is provided
|
|
11311
|
+
*/
|
|
11312
|
+
function CalendarHeader({
|
|
11313
|
+
state,
|
|
11314
|
+
title,
|
|
11315
|
+
previousMonthDisabled,
|
|
11316
|
+
nextMonthDisabled,
|
|
11317
|
+
showYearPicker,
|
|
11318
|
+
setShowYearPicker
|
|
11319
|
+
}) {
|
|
11320
|
+
return /*#__PURE__*/jsxRuntime.jsx(HeaderWrapper, {
|
|
11321
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(HeaderActions, {
|
|
11322
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Button$1, {
|
|
11323
|
+
variant: 'ghost_icon',
|
|
11324
|
+
"aria-label": 'Previous month',
|
|
11325
|
+
disabled: previousMonthDisabled || showYearPicker,
|
|
11326
|
+
onClick: () => state.focusPreviousPage(),
|
|
11327
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Icon$1, {
|
|
11328
|
+
data: edsIcons.chevron_left
|
|
11329
|
+
})
|
|
11330
|
+
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
11331
|
+
style: {
|
|
11332
|
+
flex: '1 1 auto'
|
|
11333
|
+
}
|
|
11334
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(Button$1, {
|
|
11335
|
+
onClick: () => setShowYearPicker(!showYearPicker),
|
|
11336
|
+
"data-testid": 'heading',
|
|
11337
|
+
"aria-live": 'polite',
|
|
11338
|
+
variant: 'ghost',
|
|
11339
|
+
style: {
|
|
11340
|
+
fontSize: edsTokens.tokens.typography.heading.h5.fontSize,
|
|
11341
|
+
textTransform: 'capitalize'
|
|
11342
|
+
},
|
|
11343
|
+
children: [title, /*#__PURE__*/jsxRuntime.jsx(Icon$1, {
|
|
11344
|
+
data: showYearPicker ? edsIcons.chevron_up : edsIcons.chevron_down
|
|
11345
|
+
})]
|
|
11346
|
+
}), /*#__PURE__*/jsxRuntime.jsx(TodayPicker, {
|
|
11347
|
+
disabled: showYearPicker,
|
|
11348
|
+
onClick: v => state.setFocusedDate(v)
|
|
11349
|
+
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
11350
|
+
style: {
|
|
11351
|
+
flex: '1 1 auto'
|
|
11352
|
+
}
|
|
11353
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Button$1, {
|
|
11354
|
+
variant: 'ghost_icon',
|
|
11355
|
+
onClick: () => state.focusNextPage(),
|
|
11356
|
+
disabled: nextMonthDisabled || showYearPicker,
|
|
11357
|
+
"aria-label": 'Next month',
|
|
11358
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Icon$1, {
|
|
11359
|
+
data: edsIcons.chevron_right
|
|
11360
|
+
})
|
|
11361
|
+
})]
|
|
11362
|
+
})
|
|
11363
|
+
});
|
|
11364
|
+
}
|
|
11365
|
+
|
|
11366
|
+
const CalendarWrapper = styled__default.default.div.withConfig({
|
|
11367
|
+
displayName: "CalendarWrapper",
|
|
11368
|
+
componentId: "sc-14hqwiu-0"
|
|
11369
|
+
})(["display:grid;grid-gap:16px;max-height:80vh;width:max-content;max-width:560px;overflow:auto;"]);
|
|
11370
|
+
|
|
11371
|
+
const Calendar = /*#__PURE__*/react.forwardRef(({
|
|
11372
|
+
Header,
|
|
11373
|
+
Footer,
|
|
11374
|
+
...props
|
|
11375
|
+
}, ref) => {
|
|
11376
|
+
const [showYearPicker, setShowYearPicker] = react.useState(false);
|
|
11377
|
+
const {
|
|
11378
|
+
locale
|
|
11379
|
+
} = reactAria.useLocale();
|
|
11380
|
+
const calendarState = calendar.useCalendarState({
|
|
11381
|
+
...props,
|
|
11382
|
+
locale,
|
|
11383
|
+
createCalendar: date.createCalendar
|
|
11384
|
+
});
|
|
11385
|
+
const {
|
|
11386
|
+
calendarProps,
|
|
11387
|
+
prevButtonProps,
|
|
11388
|
+
nextButtonProps,
|
|
11389
|
+
title
|
|
11390
|
+
} = reactAria.useCalendar(props, calendarState);
|
|
11391
|
+
return /*#__PURE__*/jsxRuntime.jsxs(CalendarWrapper, {
|
|
11392
|
+
ref: ref,
|
|
11393
|
+
...calendarProps,
|
|
11394
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Popover.Header, {
|
|
11395
|
+
style: {
|
|
11396
|
+
width: '100%'
|
|
11397
|
+
},
|
|
11398
|
+
children: Header ? /*#__PURE__*/jsxRuntime.jsx(Header, {
|
|
11399
|
+
month: calendarState.focusedDate.month,
|
|
11400
|
+
state: calendarState,
|
|
11401
|
+
setMonth: month => calendarState.setFocusedDate(calendarState.focusedDate.set({
|
|
11402
|
+
month
|
|
11403
|
+
})),
|
|
11404
|
+
setYear: year => calendarState.setFocusedDate(calendarState.focusedDate.set({
|
|
11405
|
+
year
|
|
11406
|
+
})),
|
|
11407
|
+
year: calendarState.focusedDate.year
|
|
11408
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(CalendarHeader, {
|
|
11409
|
+
state: calendarState,
|
|
11410
|
+
title: title,
|
|
11411
|
+
previousMonthDisabled: prevButtonProps.isDisabled,
|
|
11412
|
+
nextMonthDisabled: nextButtonProps.isDisabled,
|
|
11413
|
+
setShowYearPicker: setShowYearPicker,
|
|
11414
|
+
showYearPicker: showYearPicker
|
|
11415
|
+
})
|
|
11416
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Popover.Content, {
|
|
11417
|
+
className: "calendar",
|
|
11418
|
+
style: {
|
|
11419
|
+
height: 'fit-content'
|
|
11420
|
+
},
|
|
11421
|
+
children: /*#__PURE__*/jsxRuntime.jsx(CalendarGrid, {
|
|
11422
|
+
state: calendarState,
|
|
11423
|
+
setShowYearPicker: setShowYearPicker,
|
|
11424
|
+
showYearPicker: showYearPicker
|
|
11425
|
+
})
|
|
11426
|
+
}), Footer && /*#__PURE__*/jsxRuntime.jsx(Popover.Actions, {
|
|
11427
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Footer, {
|
|
11428
|
+
month: calendarState.focusedDate.month,
|
|
11429
|
+
state: calendarState,
|
|
11430
|
+
setMonth: month => calendarState.setFocusedDate(calendarState.focusedDate.set({
|
|
11431
|
+
month
|
|
11432
|
+
})),
|
|
11433
|
+
setYear: year => calendarState.setFocusedDate(calendarState.focusedDate.set({
|
|
11434
|
+
year
|
|
11435
|
+
})),
|
|
11436
|
+
year: calendarState.focusedDate.year
|
|
11437
|
+
})
|
|
11438
|
+
})]
|
|
11439
|
+
});
|
|
11440
|
+
});
|
|
11441
|
+
Calendar.displayName = 'Calendar';
|
|
11442
|
+
|
|
11443
|
+
const getVariant = variant => {
|
|
11444
|
+
if (variant === 'error') {
|
|
11445
|
+
return edsTokens.tokens.colors.interactive.danger__resting.rgba;
|
|
11446
|
+
}
|
|
11447
|
+
if (variant === 'success') {
|
|
11448
|
+
return edsTokens.tokens.colors.interactive.success__resting.rgba;
|
|
11449
|
+
}
|
|
11450
|
+
if (variant === 'warning') {
|
|
11451
|
+
return edsTokens.tokens.colors.interactive.warning__resting.rgba;
|
|
11452
|
+
}
|
|
11453
|
+
return edsTokens.tokens.colors.interactive.primary__resting.rgba;
|
|
11454
|
+
};
|
|
11455
|
+
const getVariantText = variant => {
|
|
11456
|
+
if (variant === 'error') {
|
|
11457
|
+
return edsTokens.tokens.colors.interactive.danger__text.rgba;
|
|
11458
|
+
}
|
|
11459
|
+
if (variant === 'success') {
|
|
11460
|
+
return edsTokens.tokens.colors.interactive.success__text.rgba;
|
|
11461
|
+
}
|
|
11462
|
+
if (variant === 'warning') {
|
|
11463
|
+
return edsTokens.tokens.colors.interactive.warning__text.rgba;
|
|
11464
|
+
}
|
|
11465
|
+
return edsTokens.tokens.typography.input.text.color;
|
|
11466
|
+
};
|
|
11467
|
+
const StyledInputFieldWrapper = styled__default.default.div.withConfig({
|
|
11468
|
+
displayName: "FieldWrapper__StyledInputFieldWrapper",
|
|
11469
|
+
componentId: "sc-1h0kqs9-0"
|
|
11470
|
+
})(["display:flex;align-items:center;background-color:", ";height:", ";padding:0 8px;", " ", " color:", ";cursor:default;"], edsTokens.tokens.colors.ui.background__light.rgba, ({
|
|
11471
|
+
$density
|
|
11472
|
+
}) => $density === 'compact' ? '24px' : '36px', ({
|
|
11473
|
+
$variant,
|
|
11474
|
+
$disabled,
|
|
11475
|
+
$readonly
|
|
11476
|
+
}) => {
|
|
11477
|
+
if (!$variant && !$readonly) {
|
|
11478
|
+
return `&:focus-within:not(.invalid) {
|
|
11479
|
+
outline: 2px solid
|
|
11480
|
+
${edsTokens.tokens.colors.interactive.primary__resting.rgba};
|
|
11481
|
+
}
|
|
11482
|
+
|
|
11483
|
+
${!$disabled && `&:not(:focus-within) {
|
|
11484
|
+
box-shadow: inset 0 -1px 0 0 ${edsTokens.tokens.colors.text.static_icons__tertiary.rgba};`}
|
|
11485
|
+
}
|
|
11486
|
+
`;
|
|
11487
|
+
}
|
|
11488
|
+
return `outline: 2px solid ${getVariant($variant)};`;
|
|
11489
|
+
}, ({
|
|
11490
|
+
$readonly
|
|
11491
|
+
}) => {
|
|
11492
|
+
return $readonly && `background-color: ${edsTokens.tokens.colors.ui.background__default.rgba};
|
|
11493
|
+
outline: none;`;
|
|
11494
|
+
}, p => getVariantText(p.$variant));
|
|
11495
|
+
/**
|
|
11496
|
+
* Applies styles around the date input fields (density, color etc.)
|
|
11497
|
+
*/
|
|
11498
|
+
const InputFieldWrapper = /*#__PURE__*/react.forwardRef(({
|
|
11499
|
+
children,
|
|
11500
|
+
color,
|
|
11501
|
+
disabled,
|
|
11502
|
+
readonly,
|
|
11503
|
+
...props
|
|
11504
|
+
}, ref) => {
|
|
11505
|
+
const {
|
|
11506
|
+
density
|
|
11507
|
+
} = useEds();
|
|
11508
|
+
// As the props returned are designed for react-aria, some of them are not valid DOM props (i.e. onPress).
|
|
11509
|
+
// The filterDOMProps-method strips out the invalid props, but it also removes event listeners due to casing
|
|
11510
|
+
const filteredProps = utils.filterDOMProps(props);
|
|
11511
|
+
// filterDOMProps also strips event handlers
|
|
11512
|
+
const eventHandlers = Object.keys(props).filter(k => k.startsWith('on')).reduce((a, b) => ({
|
|
11513
|
+
...a,
|
|
11514
|
+
[b]: props[b]
|
|
11515
|
+
}), {});
|
|
11516
|
+
return /*#__PURE__*/jsxRuntime.jsx(StyledInputFieldWrapper, {
|
|
11517
|
+
ref: ref,
|
|
11518
|
+
$density: density,
|
|
11519
|
+
$variant: color,
|
|
11520
|
+
$disabled: disabled ?? false,
|
|
11521
|
+
$readonly: readonly ?? false,
|
|
11522
|
+
...filteredProps,
|
|
11523
|
+
...eventHandlers,
|
|
11524
|
+
children: children
|
|
11525
|
+
});
|
|
11526
|
+
});
|
|
11527
|
+
const FieldWrapper = /*#__PURE__*/react.forwardRef(({
|
|
11528
|
+
children,
|
|
11529
|
+
pickerRef,
|
|
11530
|
+
calendar,
|
|
11531
|
+
isOpen,
|
|
11532
|
+
setIsOpen,
|
|
11533
|
+
label,
|
|
11534
|
+
readonly,
|
|
11535
|
+
...props
|
|
11536
|
+
}, ref) => {
|
|
11537
|
+
react.useEffect(() => {
|
|
11538
|
+
if (isOpen === false) {
|
|
11539
|
+
// Focus the first segment in the input field
|
|
11540
|
+
const segment = ref.current?.querySelector('.segment');
|
|
11541
|
+
segment?.focus();
|
|
11542
|
+
}
|
|
11543
|
+
}, [ref, isOpen, pickerRef]);
|
|
11544
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
11545
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(InputWrapper$2, {
|
|
11546
|
+
readOnly: readonly,
|
|
11547
|
+
label: label,
|
|
11548
|
+
onKeyDownCapture: event => {
|
|
11549
|
+
const isIconTarget = event.target instanceof SVGSVGElement;
|
|
11550
|
+
if (!isIconTarget && (event.code === 'Space' || event.code === 'Enter')) {
|
|
11551
|
+
setIsOpen(true);
|
|
11552
|
+
}
|
|
11553
|
+
},
|
|
11554
|
+
...props,
|
|
11555
|
+
children: children
|
|
11556
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Popover, {
|
|
11557
|
+
open: isOpen ?? false,
|
|
11558
|
+
onClose: () => setIsOpen(false),
|
|
11559
|
+
anchorEl: ref.current,
|
|
11560
|
+
placement: 'bottom-start',
|
|
11561
|
+
withinPortal: true,
|
|
11562
|
+
children: calendar
|
|
11563
|
+
})]
|
|
11564
|
+
});
|
|
11565
|
+
});
|
|
11566
|
+
InputFieldWrapper.displayName = 'InputFieldWrapper';
|
|
11567
|
+
FieldWrapper.displayName = 'FieldWrapper';
|
|
11568
|
+
|
|
11569
|
+
const intl = new Intl.DateTimeFormat();
|
|
11570
|
+
const defaultTimezone = intl.resolvedOptions().timeZone;
|
|
11571
|
+
const DatePickerContext = /*#__PURE__*/react.createContext({
|
|
11572
|
+
timezone: defaultTimezone
|
|
11573
|
+
});
|
|
11574
|
+
const DatePickerProvider = ({
|
|
11575
|
+
timezone,
|
|
11576
|
+
formatOptions,
|
|
11577
|
+
children
|
|
11578
|
+
}) => {
|
|
11579
|
+
return /*#__PURE__*/jsxRuntime.jsx(DatePickerContext.Provider, {
|
|
11580
|
+
value: {
|
|
11581
|
+
timezone: timezone ?? defaultTimezone,
|
|
11582
|
+
formatOptions
|
|
11583
|
+
},
|
|
11584
|
+
children: children
|
|
11585
|
+
});
|
|
11586
|
+
};
|
|
11587
|
+
const useDatePickerContext = () => react.useContext(DatePickerContext);
|
|
11588
|
+
|
|
11589
|
+
const Segment = styled__default.default.div.withConfig({
|
|
11590
|
+
displayName: "DateSegment__Segment",
|
|
11591
|
+
componentId: "sc-19uidpx-0"
|
|
11592
|
+
})(["color:", ";font-family:", ";&:focus-visible{outline:2px solid ", ";background-color:", ";}", ""], edsTokens.tokens.typography.input.text.color, edsTokens.tokens.typography.input.text.fontFamily, edsTokens.tokens.colors.interactive.primary__resting.rgba, edsTokens.tokens.colors.ui.background__medium.rgba, ({
|
|
11593
|
+
$disabled
|
|
11594
|
+
}) => $disabled && `color: ${edsTokens.tokens.colors.interactive.disabled__text.rgba};`);
|
|
11595
|
+
|
|
11596
|
+
/**
|
|
11597
|
+
* DateSegment is used to represent a single segment of a date in the DateField (i.e. day, month, year)
|
|
11598
|
+
*/
|
|
11599
|
+
function DateSegment({
|
|
11600
|
+
segment,
|
|
11601
|
+
state
|
|
11602
|
+
}) {
|
|
11603
|
+
const {
|
|
11604
|
+
formatOptions,
|
|
11605
|
+
timezone
|
|
11606
|
+
} = useDatePickerContext();
|
|
11607
|
+
const formatter = reactAria.useDateFormatter(formatOptions);
|
|
11608
|
+
const parts = state.value ? formatter.formatToParts(state.value.toDate(timezone)) : [];
|
|
11609
|
+
const part = parts.find(p => p.type === segment.type);
|
|
11610
|
+
const value = part?.value ?? segment.text;
|
|
11611
|
+
const [focus, setFocus] = react.useState(false);
|
|
11612
|
+
const ref = react.useRef(null);
|
|
11613
|
+
const {
|
|
11614
|
+
segmentProps
|
|
11615
|
+
} = reactAria.useDateSegment(segment, state, ref);
|
|
11616
|
+
return /*#__PURE__*/jsxRuntime.jsx(Segment, {
|
|
11617
|
+
...segmentProps,
|
|
11618
|
+
onFocus: e => {
|
|
11619
|
+
setFocus(true);
|
|
11620
|
+
segmentProps.onFocus(e);
|
|
11621
|
+
},
|
|
11622
|
+
onBlur: e => {
|
|
11623
|
+
setFocus(false);
|
|
11624
|
+
segmentProps.onBlur(e);
|
|
11625
|
+
},
|
|
11626
|
+
$invalid: state.isInvalid,
|
|
11627
|
+
$disabled: state.isDisabled,
|
|
11628
|
+
$placeholder: segment.isPlaceholder,
|
|
11629
|
+
style: {
|
|
11630
|
+
padding: segment.type === 'literal' ? '0 2px' : '0'
|
|
11631
|
+
},
|
|
11632
|
+
onKeyDown: e => {
|
|
11633
|
+
if (e.code === 'Enter' || e.code === 'Space') {
|
|
11634
|
+
e.stopPropagation();
|
|
11635
|
+
e.preventDefault();
|
|
11636
|
+
} else if (segmentProps.onKeyDown) {
|
|
11637
|
+
segmentProps.onKeyDown(e);
|
|
11638
|
+
}
|
|
11639
|
+
},
|
|
11640
|
+
ref: ref,
|
|
11641
|
+
className: `segment ${segment.isPlaceholder ? 'placeholder' : ''}`,
|
|
11642
|
+
children: focus ? segment.isPlaceholder || segment.type === 'literal' ? segment.text : segment.text.padStart(segment.type === 'year' ? 4 : 2, '0') : value
|
|
11643
|
+
});
|
|
11644
|
+
}
|
|
11645
|
+
|
|
11646
|
+
// In some cases we need to use the index as key
|
|
11647
|
+
/* eslint-disable react/no-array-index-key */
|
|
11648
|
+
/**
|
|
11649
|
+
* A field that wraps segments for inputting a date / date-time
|
|
11650
|
+
*/
|
|
11651
|
+
const DateFieldSegments = /*#__PURE__*/react.forwardRef((props, ref) => {
|
|
11652
|
+
const {
|
|
11653
|
+
locale
|
|
11654
|
+
} = reactAria.useLocale();
|
|
11655
|
+
const state = datepicker.useDateFieldState({
|
|
11656
|
+
...props,
|
|
11657
|
+
locale,
|
|
11658
|
+
createCalendar: date.createCalendar
|
|
11659
|
+
});
|
|
11660
|
+
const {
|
|
11661
|
+
fieldProps
|
|
11662
|
+
} = reactAria.useDateField({
|
|
11663
|
+
...props,
|
|
11664
|
+
// Type-casting as react-aria expects string | ReactNode, but we only pass strings
|
|
11665
|
+
'aria-label': props.label ?? 'Date input field'
|
|
11666
|
+
}, state, ref);
|
|
11667
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
11668
|
+
...fieldProps,
|
|
11669
|
+
style: {
|
|
11670
|
+
display: 'flex'
|
|
11671
|
+
},
|
|
11672
|
+
ref: ref,
|
|
11673
|
+
children: state.segments.map((segment, i) => /*#__PURE__*/jsxRuntime.jsx(DateSegment, {
|
|
11674
|
+
segment: segment,
|
|
11675
|
+
state: state
|
|
11676
|
+
}, i))
|
|
11677
|
+
});
|
|
11678
|
+
});
|
|
11679
|
+
DateFieldSegments.displayName = 'SingleDateField';
|
|
11680
|
+
|
|
11681
|
+
/**
|
|
11682
|
+
* Datefield is the input field used in {@link DatePicker} to type in a single date.
|
|
11683
|
+
* Encapsulates styling / functionality for typing a date
|
|
11684
|
+
*/
|
|
11685
|
+
const DateField = /*#__PURE__*/react.forwardRef(function ({
|
|
11686
|
+
fieldProps,
|
|
11687
|
+
groupProps,
|
|
11688
|
+
variant,
|
|
11689
|
+
dateCreateProps,
|
|
11690
|
+
...props
|
|
11691
|
+
}, ref) {
|
|
11692
|
+
const state = datepicker.useDateFieldState(dateCreateProps);
|
|
11693
|
+
const inputRef = react.useRef(null);
|
|
11694
|
+
return /*#__PURE__*/jsxRuntime.jsxs(InputFieldWrapper, {
|
|
11695
|
+
...groupProps,
|
|
11696
|
+
readonly: fieldProps.isReadOnly,
|
|
11697
|
+
disabled: state.isDisabled,
|
|
11698
|
+
color: state.isInvalid ? 'warning' : variant,
|
|
11699
|
+
ref: ref,
|
|
11700
|
+
className: `field ${state.isInvalid ? 'invalid' : 'valid'}`,
|
|
11701
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(DateFieldSegments, {
|
|
11702
|
+
...state,
|
|
11703
|
+
...fieldProps,
|
|
11704
|
+
ref: inputRef
|
|
11705
|
+
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
11706
|
+
style: {
|
|
11707
|
+
flex: '1 1 auto'
|
|
11708
|
+
}
|
|
11709
|
+
}), props.rightAdornments]
|
|
11710
|
+
});
|
|
11711
|
+
});
|
|
11712
|
+
DateField.displayName = 'DateField';
|
|
11713
|
+
|
|
11714
|
+
const useConvertedValidationFunctions = (minValue, maxValue, isDateUnavailable, timezone) => {
|
|
11715
|
+
const tz = timezone ?? defaultTimezone;
|
|
11716
|
+
const _minValue = minValue ? date.toCalendarDate(date.fromDate(minValue, tz)) : undefined;
|
|
11717
|
+
const _maxValue = maxValue ? date.toCalendarDate(date.fromDate(maxValue, tz)) : undefined;
|
|
11718
|
+
const _minTimeValue = minValue ? date.fromDate(minValue, tz) : undefined;
|
|
11719
|
+
const _maxTimeValue = maxValue ? date.fromDate(maxValue, tz) : undefined;
|
|
11720
|
+
const _isDateUnavailable = value => isDateUnavailable ? isDateUnavailable(value.toDate(tz)) : false;
|
|
11721
|
+
return {
|
|
11722
|
+
_minValue,
|
|
11723
|
+
_maxValue,
|
|
11724
|
+
_isDateUnavailable,
|
|
11725
|
+
_minTimeValue,
|
|
11726
|
+
_maxTimeValue
|
|
11727
|
+
};
|
|
11728
|
+
};
|
|
11729
|
+
|
|
11730
|
+
const StyledButton = styled__default.default(Button$2).withConfig({
|
|
11731
|
+
displayName: "Toggle__StyledButton",
|
|
11732
|
+
componentId: "sc-1bwqcj7-0"
|
|
11733
|
+
})(["height:24px;width:24px;"]);
|
|
11734
|
+
|
|
11735
|
+
/**
|
|
11736
|
+
* Toggle component encapsulates the reset and open calendar buttons
|
|
11737
|
+
*/
|
|
11738
|
+
const Toggle = ({
|
|
11739
|
+
reset,
|
|
11740
|
+
setOpen,
|
|
11741
|
+
open,
|
|
11742
|
+
icon,
|
|
11743
|
+
disabled,
|
|
11744
|
+
buttonProps,
|
|
11745
|
+
valueString,
|
|
11746
|
+
readonly
|
|
11747
|
+
}) => {
|
|
11748
|
+
return readonly || disabled ? null : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
11749
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(StyledButton, {
|
|
11750
|
+
disabled: disabled,
|
|
11751
|
+
variant: 'ghost_icon',
|
|
11752
|
+
"aria-label": 'Reset',
|
|
11753
|
+
onClick: () => {
|
|
11754
|
+
reset();
|
|
11755
|
+
},
|
|
11756
|
+
onKeyDown: e => {
|
|
11757
|
+
if (e.code === 'Enter' || e.code === 'Space') {
|
|
11758
|
+
e.preventDefault();
|
|
11759
|
+
e.stopPropagation();
|
|
11760
|
+
reset();
|
|
11761
|
+
}
|
|
11762
|
+
},
|
|
11763
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Icon$1, {
|
|
11764
|
+
data: edsIcons.close
|
|
11765
|
+
})
|
|
11766
|
+
}), /*#__PURE__*/jsxRuntime.jsx(StyledButton, {
|
|
11767
|
+
...utils.filterDOMProps(buttonProps),
|
|
11768
|
+
disabled: disabled,
|
|
11769
|
+
"aria-label": valueString ? `Change date, ${valueString}` : `Change date`,
|
|
11770
|
+
variant: 'ghost_icon',
|
|
11771
|
+
onClick: e => {
|
|
11772
|
+
e.preventDefault();
|
|
11773
|
+
e.stopPropagation();
|
|
11774
|
+
setOpen(!open);
|
|
11775
|
+
},
|
|
11776
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Icon$1, {
|
|
11777
|
+
data: icon
|
|
11778
|
+
})
|
|
11779
|
+
})]
|
|
11780
|
+
});
|
|
11781
|
+
};
|
|
11782
|
+
|
|
11783
|
+
const getCalendarDate = (value, timezone, showTimeInput = false) => {
|
|
11784
|
+
if (!value) return null;
|
|
11785
|
+
return showTimeInput ? date.toCalendarDateTime(date.fromDate(value, timezone)) : date.toCalendarDate(date.fromDate(value, timezone));
|
|
11786
|
+
};
|
|
11787
|
+
|
|
11788
|
+
const DatePicker = /*#__PURE__*/react.forwardRef(({
|
|
11789
|
+
onChange,
|
|
11790
|
+
label,
|
|
11791
|
+
value,
|
|
11792
|
+
isDateUnavailable,
|
|
11793
|
+
minValue,
|
|
11794
|
+
maxValue,
|
|
11795
|
+
Footer,
|
|
11796
|
+
Header,
|
|
11797
|
+
timezone,
|
|
11798
|
+
defaultValue,
|
|
11799
|
+
showTimeInput,
|
|
11800
|
+
granularity,
|
|
11801
|
+
disabled: isDisabled,
|
|
11802
|
+
readOnly: isReadOnly,
|
|
11803
|
+
formatOptions,
|
|
11804
|
+
...props
|
|
11805
|
+
}, forwardedRef) => {
|
|
11806
|
+
timezone = timezone ?? defaultTimezone;
|
|
11807
|
+
formatOptions = formatOptions ?? {
|
|
11808
|
+
year: 'numeric',
|
|
11809
|
+
month: '2-digit',
|
|
11810
|
+
day: '2-digit'
|
|
11811
|
+
};
|
|
11812
|
+
const [innerValue, setInnerValue] = react.useState(() => {
|
|
11813
|
+
const initialValue = value ?? defaultValue;
|
|
11814
|
+
if (initialValue) {
|
|
11815
|
+
if (showTimeInput) {
|
|
11816
|
+
return date.toCalendarDateTime(date.fromDate(initialValue, timezone));
|
|
11817
|
+
} else {
|
|
11818
|
+
return date.toCalendarDate(date.fromDate(initialValue, timezone));
|
|
11819
|
+
}
|
|
11820
|
+
}
|
|
11821
|
+
return null;
|
|
11822
|
+
});
|
|
11823
|
+
const [isOpen, setIsOpen] = react.useState(null);
|
|
11824
|
+
const inputRef = react.useRef(null);
|
|
11825
|
+
const pickerRef = react.useRef(null);
|
|
11826
|
+
const ref = forwardedRef || inputRef;
|
|
11827
|
+
const {
|
|
11828
|
+
_minValue,
|
|
11829
|
+
_maxValue,
|
|
11830
|
+
_isDateUnavailable
|
|
11831
|
+
} = useConvertedValidationFunctions(minValue, maxValue, isDateUnavailable, timezone);
|
|
11832
|
+
const _onChange = react.useCallback(value => {
|
|
11833
|
+
// Set internal value
|
|
11834
|
+
if (value) {
|
|
11835
|
+
setInnerValue(showTimeInput ? date.toCalendarDateTime(value) : date.toCalendarDate(value));
|
|
11836
|
+
} else {
|
|
11837
|
+
setInnerValue(null);
|
|
11838
|
+
}
|
|
11839
|
+
// Close the picker after selecting a date
|
|
11840
|
+
if (isOpen) {
|
|
11841
|
+
setIsOpen(false);
|
|
11842
|
+
}
|
|
11843
|
+
// Call onChange callback from props
|
|
11844
|
+
if (onChange) {
|
|
11845
|
+
if (!value) {
|
|
11846
|
+
onChange(null);
|
|
11847
|
+
} else {
|
|
11848
|
+
const date = value.toDate(timezone);
|
|
11849
|
+
onChange(date);
|
|
11850
|
+
}
|
|
11851
|
+
}
|
|
11852
|
+
}, [onChange, isOpen, showTimeInput, timezone]);
|
|
11853
|
+
const _value = getCalendarDate(value, timezone, showTimeInput) ?? innerValue;
|
|
11854
|
+
const {
|
|
11855
|
+
locale
|
|
11856
|
+
} = reactAria.useLocale();
|
|
11857
|
+
const dateCreateProps = {
|
|
11858
|
+
...props,
|
|
11859
|
+
isDisabled,
|
|
11860
|
+
value: _value,
|
|
11861
|
+
hideTimeZone: true,
|
|
11862
|
+
locale,
|
|
11863
|
+
createCalendar: date.createCalendar,
|
|
11864
|
+
onChange: _onChange,
|
|
11865
|
+
minValue: _minValue,
|
|
11866
|
+
maxValue: _maxValue,
|
|
11867
|
+
isDateUnavailable: _isDateUnavailable,
|
|
11868
|
+
label: label || 'Date picker',
|
|
11869
|
+
isReadOnly,
|
|
11870
|
+
granularity
|
|
11871
|
+
};
|
|
11872
|
+
const pickerState = datepicker.useDatePickerState(dateCreateProps);
|
|
11873
|
+
const {
|
|
11874
|
+
groupProps,
|
|
11875
|
+
buttonProps,
|
|
11876
|
+
fieldProps,
|
|
11877
|
+
calendarProps
|
|
11878
|
+
} = reactAria.useDatePicker(dateCreateProps, pickerState, ref);
|
|
11879
|
+
const helperProps = pickerState.displayValidation.isInvalid ? {
|
|
11880
|
+
text: pickerState.displayValidation.validationErrors.join('\n'),
|
|
11881
|
+
color: edsTokens.tokens.colors.interactive.warning__text.rgba,
|
|
11882
|
+
icon: /*#__PURE__*/jsxRuntime.jsx(Icon$1, {
|
|
11883
|
+
size: 16,
|
|
11884
|
+
data: edsIcons.warning_outlined
|
|
11885
|
+
})
|
|
11886
|
+
} : undefined;
|
|
11887
|
+
|
|
11888
|
+
// innerValue is used as a fallback, especially for uncontrolled inputs, so it needs to be reset when value / defaultValue is reset
|
|
11889
|
+
react.useEffect(() => {
|
|
11890
|
+
if (!defaultValue && !value) setInnerValue(null);
|
|
11891
|
+
}, [defaultValue, value]);
|
|
11892
|
+
return /*#__PURE__*/jsxRuntime.jsx(DatePickerProvider, {
|
|
11893
|
+
timezone: timezone,
|
|
11894
|
+
formatOptions: formatOptions,
|
|
11895
|
+
children: /*#__PURE__*/jsxRuntime.jsx(FieldWrapper, {
|
|
11896
|
+
isOpen: isOpen,
|
|
11897
|
+
readonly: fieldProps.isReadOnly,
|
|
11898
|
+
pickerRef: pickerRef,
|
|
11899
|
+
ref: ref,
|
|
11900
|
+
setIsOpen: setIsOpen,
|
|
11901
|
+
label: label,
|
|
11902
|
+
calendar: /*#__PURE__*/jsxRuntime.jsx(Calendar, {
|
|
11903
|
+
ref: pickerRef,
|
|
11904
|
+
Footer: Footer,
|
|
11905
|
+
Header: Header,
|
|
11906
|
+
...calendarProps
|
|
11907
|
+
}),
|
|
11908
|
+
disabled: isDisabled,
|
|
11909
|
+
readOnly: isReadOnly,
|
|
11910
|
+
color: pickerState.isInvalid ? 'warning' : props.variant,
|
|
11911
|
+
helperProps: helperProps ?? props.helperProps,
|
|
11912
|
+
children: /*#__PURE__*/jsxRuntime.jsx(DateField, {
|
|
11913
|
+
fieldProps: fieldProps,
|
|
11914
|
+
groupProps: groupProps,
|
|
11915
|
+
dateCreateProps: dateCreateProps,
|
|
11916
|
+
ref: ref,
|
|
11917
|
+
onChange: _onChange,
|
|
11918
|
+
rightAdornments: /*#__PURE__*/jsxRuntime.jsx(Toggle, {
|
|
11919
|
+
setOpen: setIsOpen,
|
|
11920
|
+
open: isOpen,
|
|
11921
|
+
icon: edsIcons.calendar,
|
|
11922
|
+
disabled: isDisabled,
|
|
11923
|
+
readonly: isReadOnly,
|
|
11924
|
+
reset: () => _onChange(null),
|
|
11925
|
+
buttonProps: buttonProps,
|
|
11926
|
+
valueString: pickerState.formatValue(locale, {
|
|
11927
|
+
year: 'numeric',
|
|
11928
|
+
month: 'short',
|
|
11929
|
+
day: '2-digit'
|
|
11930
|
+
})
|
|
11931
|
+
}),
|
|
11932
|
+
variant: props.variant
|
|
11933
|
+
})
|
|
11934
|
+
})
|
|
11935
|
+
});
|
|
11936
|
+
});
|
|
11937
|
+
DatePicker.displayName = 'DatePicker';
|
|
11938
|
+
|
|
11939
|
+
const RangeCalendar = /*#__PURE__*/react.forwardRef(({
|
|
11940
|
+
Header,
|
|
11941
|
+
Footer,
|
|
11942
|
+
...props
|
|
11943
|
+
}, ref) => {
|
|
11944
|
+
const [showYearPicker, setShowYearPicker] = react.useState(false);
|
|
11945
|
+
const {
|
|
11946
|
+
locale
|
|
11947
|
+
} = reactAria.useLocale();
|
|
11948
|
+
const state = calendar.useRangeCalendarState({
|
|
11949
|
+
...props,
|
|
11950
|
+
locale,
|
|
11951
|
+
createCalendar: date.createCalendar
|
|
11952
|
+
});
|
|
11953
|
+
const {
|
|
11954
|
+
calendarProps,
|
|
11955
|
+
title
|
|
11956
|
+
} = reactAria.useRangeCalendar(props, state, ref);
|
|
11957
|
+
return /*#__PURE__*/jsxRuntime.jsxs(CalendarWrapper, {
|
|
11958
|
+
...calendarProps,
|
|
11959
|
+
ref: ref,
|
|
11960
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Popover.Header, {
|
|
11961
|
+
children: Header ? /*#__PURE__*/jsxRuntime.jsx(Header, {
|
|
11962
|
+
month: state.focusedDate.month,
|
|
11963
|
+
state: state,
|
|
11964
|
+
setMonth: month => state.setFocusedDate(state.focusedDate.set({
|
|
11965
|
+
month
|
|
11966
|
+
})),
|
|
11967
|
+
setYear: year => state.setFocusedDate(state.focusedDate.set({
|
|
11968
|
+
year
|
|
11969
|
+
})),
|
|
11970
|
+
year: state.focusedDate.year
|
|
11971
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(CalendarHeader, {
|
|
11972
|
+
state: state,
|
|
11973
|
+
title: title,
|
|
11974
|
+
setShowYearPicker: setShowYearPicker,
|
|
11975
|
+
showYearPicker: showYearPicker
|
|
11976
|
+
})
|
|
11977
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Popover.Content, {
|
|
11978
|
+
children: /*#__PURE__*/jsxRuntime.jsx(CalendarGrid, {
|
|
11979
|
+
state: state,
|
|
11980
|
+
setShowYearPicker: setShowYearPicker,
|
|
11981
|
+
showYearPicker: showYearPicker
|
|
11982
|
+
})
|
|
11983
|
+
}), Footer && /*#__PURE__*/jsxRuntime.jsx(Popover.Actions, {
|
|
11984
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Footer, {
|
|
11985
|
+
month: state.focusedDate.month,
|
|
11986
|
+
state: state,
|
|
11987
|
+
setMonth: month => state.setFocusedDate(state.focusedDate.set({
|
|
11988
|
+
month
|
|
11989
|
+
})),
|
|
11990
|
+
setYear: year => state.setFocusedDate(state.focusedDate.set({
|
|
11991
|
+
year
|
|
11992
|
+
})),
|
|
11993
|
+
year: state.focusedDate.year
|
|
11994
|
+
})
|
|
11995
|
+
})]
|
|
11996
|
+
});
|
|
11997
|
+
});
|
|
11998
|
+
RangeCalendar.displayName = 'RangeCalendar';
|
|
11999
|
+
|
|
12000
|
+
/**
|
|
12001
|
+
* DateRangeField is the input field used in {@link DateRangePicker} to type in a date range.
|
|
12002
|
+
*/
|
|
12003
|
+
const DateRangeField = /*#__PURE__*/react.forwardRef(function (props, ref) {
|
|
12004
|
+
const fromRef = react.useRef(null);
|
|
12005
|
+
const toRef = react.useRef(null);
|
|
12006
|
+
return /*#__PURE__*/jsxRuntime.jsxs(InputFieldWrapper, {
|
|
12007
|
+
ref: ref,
|
|
12008
|
+
readonly: props.startFieldProps.isReadOnly,
|
|
12009
|
+
className: "field",
|
|
12010
|
+
disabled: props.disabled,
|
|
12011
|
+
color: props.variant,
|
|
12012
|
+
...props.groupProps,
|
|
12013
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(DateFieldSegments, {
|
|
12014
|
+
...props.startFieldProps,
|
|
12015
|
+
ref: fromRef
|
|
12016
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
12017
|
+
as: 'span',
|
|
12018
|
+
variant: 'text',
|
|
12019
|
+
group: 'input',
|
|
12020
|
+
style: {
|
|
12021
|
+
padding: '0 4px'
|
|
12022
|
+
},
|
|
12023
|
+
children: "\u2014"
|
|
12024
|
+
}), /*#__PURE__*/jsxRuntime.jsx(DateFieldSegments, {
|
|
12025
|
+
...props.endFieldProps,
|
|
12026
|
+
ref: toRef
|
|
12027
|
+
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
12028
|
+
style: {
|
|
12029
|
+
flex: '1 1 auto'
|
|
12030
|
+
}
|
|
12031
|
+
}), props.rightAdornments]
|
|
12032
|
+
});
|
|
12033
|
+
});
|
|
12034
|
+
DateRangeField.displayName = 'DateRangeField';
|
|
12035
|
+
|
|
12036
|
+
const DateRangePicker = /*#__PURE__*/react.forwardRef(({
|
|
12037
|
+
onChange,
|
|
12038
|
+
label,
|
|
12039
|
+
value,
|
|
12040
|
+
isDateUnavailable,
|
|
12041
|
+
minValue,
|
|
12042
|
+
maxValue,
|
|
12043
|
+
Footer,
|
|
12044
|
+
Header,
|
|
12045
|
+
timezone,
|
|
12046
|
+
defaultValue,
|
|
12047
|
+
formatOptions,
|
|
12048
|
+
disabled: isDisabled,
|
|
12049
|
+
readOnly: isReadOnly,
|
|
12050
|
+
...props
|
|
12051
|
+
}, forwardedRef) => {
|
|
12052
|
+
timezone = timezone ?? defaultTimezone;
|
|
12053
|
+
formatOptions = formatOptions ?? {
|
|
12054
|
+
year: 'numeric',
|
|
12055
|
+
month: '2-digit',
|
|
12056
|
+
day: '2-digit'
|
|
12057
|
+
};
|
|
12058
|
+
const [innerValue, setInnerValue] = react.useState(() => {
|
|
12059
|
+
const initialValue = value ?? defaultValue;
|
|
12060
|
+
if (initialValue) {
|
|
12061
|
+
return {
|
|
12062
|
+
start: initialValue.from ? date.toCalendarDate(date.fromDate(initialValue.from, timezone)) : null,
|
|
12063
|
+
end: initialValue.to ? date.toCalendarDate(date.fromDate(initialValue.to, timezone)) : null
|
|
12064
|
+
};
|
|
12065
|
+
}
|
|
12066
|
+
});
|
|
12067
|
+
const [isOpen, setIsOpen] = react.useState(null);
|
|
12068
|
+
const inputRef = react.useRef(null);
|
|
12069
|
+
const pickerRef = react.useRef(null);
|
|
12070
|
+
const ref = forwardedRef || inputRef;
|
|
12071
|
+
const {
|
|
12072
|
+
locale
|
|
12073
|
+
} = reactAria.useLocale();
|
|
12074
|
+
const {
|
|
12075
|
+
_minValue,
|
|
12076
|
+
_maxValue,
|
|
12077
|
+
_isDateUnavailable
|
|
12078
|
+
} = useConvertedValidationFunctions(minValue, maxValue, isDateUnavailable, timezone);
|
|
12079
|
+
const _onChange = react.useCallback(rangeValue => {
|
|
12080
|
+
setInnerValue(rangeValue);
|
|
12081
|
+
// Close picker on selecting date
|
|
12082
|
+
if (isOpen) {
|
|
12083
|
+
setIsOpen(false);
|
|
12084
|
+
}
|
|
12085
|
+
// Propagate change
|
|
12086
|
+
if (onChange) {
|
|
12087
|
+
if (!rangeValue) onChange(null);else {
|
|
12088
|
+
onChange({
|
|
12089
|
+
from: rangeValue.start?.toDate(timezone) ?? null,
|
|
12090
|
+
to: rangeValue.end?.toDate(timezone) ?? null
|
|
12091
|
+
});
|
|
12092
|
+
}
|
|
12093
|
+
}
|
|
12094
|
+
}, [onChange, isOpen, timezone]);
|
|
12095
|
+
const _value = value ? {
|
|
12096
|
+
start: getCalendarDate(value.from, timezone),
|
|
12097
|
+
end: getCalendarDate(value.to, timezone)
|
|
12098
|
+
} : innerValue;
|
|
12099
|
+
const dateRangePickerStateProps = {
|
|
12100
|
+
maxValue: _maxValue,
|
|
12101
|
+
minValue: _minValue,
|
|
12102
|
+
isDateUnavailable: _isDateUnavailable,
|
|
12103
|
+
onChange: _onChange,
|
|
12104
|
+
label: label ?? 'Date-range',
|
|
12105
|
+
value: _value,
|
|
12106
|
+
isDisabled: isDisabled,
|
|
12107
|
+
isReadOnly: isReadOnly
|
|
12108
|
+
};
|
|
12109
|
+
const state = datepicker.useDateRangePickerState(dateRangePickerStateProps);
|
|
12110
|
+
const {
|
|
12111
|
+
groupProps,
|
|
12112
|
+
startFieldProps,
|
|
12113
|
+
endFieldProps,
|
|
12114
|
+
buttonProps,
|
|
12115
|
+
calendarProps
|
|
12116
|
+
} = reactAria.useDateRangePicker(dateRangePickerStateProps, state, ref);
|
|
12117
|
+
const helperProps = state.displayValidation.isInvalid ? {
|
|
12118
|
+
text: state.displayValidation.validationErrors.join('\n'),
|
|
12119
|
+
color: edsTokens.tokens.colors.interactive.warning__text.rgba,
|
|
12120
|
+
icon: /*#__PURE__*/jsxRuntime.jsx(Icon$1, {
|
|
12121
|
+
size: 16,
|
|
12122
|
+
data: edsIcons.warning_outlined
|
|
12123
|
+
})
|
|
12124
|
+
} : undefined;
|
|
12125
|
+
const formattedValue = state.formatValue(locale, {
|
|
12126
|
+
year: 'numeric',
|
|
12127
|
+
month: 'short',
|
|
12128
|
+
day: '2-digit'
|
|
12129
|
+
});
|
|
12130
|
+
const valueString = formattedValue ? Object.values(formattedValue).join(' - ') : null;
|
|
12131
|
+
|
|
12132
|
+
// innerValue is used as a fallback, especially for uncontrolled inputs, so it needs to be reset when value / defaultValue is reset
|
|
12133
|
+
react.useEffect(() => {
|
|
12134
|
+
const val = defaultValue ?? value;
|
|
12135
|
+
if (!defaultValue && !value) setInnerValue(null);
|
|
12136
|
+
if (!val?.from && !val?.to) setInnerValue(null);
|
|
12137
|
+
}, [defaultValue, value]);
|
|
12138
|
+
return /*#__PURE__*/jsxRuntime.jsx(DatePickerProvider, {
|
|
12139
|
+
timezone: timezone,
|
|
12140
|
+
formatOptions: formatOptions,
|
|
12141
|
+
children: /*#__PURE__*/jsxRuntime.jsx(FieldWrapper, {
|
|
12142
|
+
isOpen: isOpen,
|
|
12143
|
+
color: state.isInvalid ? 'warning' : props.variant,
|
|
12144
|
+
helperProps: helperProps ?? props.helperProps,
|
|
12145
|
+
readonly: startFieldProps.isReadOnly,
|
|
12146
|
+
ref: ref,
|
|
12147
|
+
pickerRef: pickerRef,
|
|
12148
|
+
setIsOpen: setIsOpen,
|
|
12149
|
+
label: label,
|
|
12150
|
+
calendar: /*#__PURE__*/jsxRuntime.jsx(RangeCalendar, {
|
|
12151
|
+
ref: pickerRef,
|
|
12152
|
+
maxValue: _maxValue,
|
|
12153
|
+
minValue: _minValue,
|
|
12154
|
+
isDateUnavailable: _isDateUnavailable,
|
|
12155
|
+
Footer: Footer,
|
|
12156
|
+
Header: Header,
|
|
12157
|
+
...calendarProps
|
|
12158
|
+
}),
|
|
12159
|
+
children: /*#__PURE__*/jsxRuntime.jsx(DateRangeField, {
|
|
12160
|
+
startFieldProps: startFieldProps,
|
|
12161
|
+
endFieldProps: endFieldProps,
|
|
12162
|
+
groupProps: groupProps,
|
|
12163
|
+
ref: ref,
|
|
12164
|
+
variant: props.variant,
|
|
12165
|
+
disabled: isDisabled,
|
|
12166
|
+
rightAdornments: /*#__PURE__*/jsxRuntime.jsx(Toggle, {
|
|
12167
|
+
buttonProps: buttonProps,
|
|
12168
|
+
disabled: isDisabled,
|
|
12169
|
+
readonly: isReadOnly,
|
|
12170
|
+
reset: () => {
|
|
12171
|
+
_onChange(null);
|
|
12172
|
+
},
|
|
12173
|
+
setOpen: setIsOpen,
|
|
12174
|
+
open: isOpen,
|
|
12175
|
+
icon: edsIcons.calendar_date_range,
|
|
12176
|
+
valueString: valueString
|
|
12177
|
+
})
|
|
12178
|
+
})
|
|
12179
|
+
})
|
|
12180
|
+
});
|
|
12181
|
+
});
|
|
12182
|
+
DateRangePicker.displayName = 'DateRangePicker';
|
|
12183
|
+
|
|
10976
12184
|
exports.Accordion = Accordion;
|
|
10977
12185
|
exports.Autocomplete = Autocomplete;
|
|
10978
12186
|
exports.Avatar = Avatar;
|
|
@@ -10983,6 +12191,8 @@ exports.Card = Card;
|
|
|
10983
12191
|
exports.Checkbox = Checkbox;
|
|
10984
12192
|
exports.Chip = Chip;
|
|
10985
12193
|
exports.CircularProgress = CircularProgress;
|
|
12194
|
+
exports.DatePicker = DatePicker;
|
|
12195
|
+
exports.DateRangePicker = DateRangePicker;
|
|
10986
12196
|
exports.Dialog = Dialog;
|
|
10987
12197
|
exports.Divider = Divider;
|
|
10988
12198
|
exports.DotProgress = DotProgress;
|