@dynamic-framework/ui-react 1.34.0 → 1.35.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.
Files changed (63) hide show
  1. package/README.md +1 -1
  2. package/dist/css/bootstrap-icons.css +3 -3
  3. package/dist/css/bootstrap-icons.min.css +2 -2
  4. package/dist/css/bootstrap-icons.scss +1 -1
  5. package/dist/css/dynamic-ui-non-root.css +720 -963
  6. package/dist/css/dynamic-ui-non-root.min.css +2 -2
  7. package/dist/css/dynamic-ui-root.css +1 -1
  8. package/dist/css/dynamic-ui-root.min.css +1 -1
  9. package/dist/css/dynamic-ui.css +720 -963
  10. package/dist/css/dynamic-ui.min.css +2 -2
  11. package/dist/css/fonts/bootstrap-icons.woff +0 -0
  12. package/dist/css/fonts/bootstrap-icons.woff2 +0 -0
  13. package/dist/index.esm.js +576 -146
  14. package/dist/index.esm.js.map +1 -1
  15. package/dist/index.js +573 -143
  16. package/dist/index.js.map +1 -1
  17. package/dist/js/bootstrap.bundle.js +19 -18
  18. package/dist/js/bootstrap.bundle.min.js +3 -3
  19. package/dist/js/bootstrap.esm.js +19 -16
  20. package/dist/js/bootstrap.esm.min.js +3 -3
  21. package/dist/js/bootstrap.js +19 -16
  22. package/dist/js/bootstrap.min.js +3 -3
  23. package/dist/types/components/DBoxFile/DBoxFile.d.ts +6 -5
  24. package/dist/types/components/DBoxFile/useDBoxFile.d.ts +37 -0
  25. package/dist/types/components/DBoxFile/utils.d.ts +39 -0
  26. package/dist/types/components/DDatePicker/DDatePicker.d.ts +6 -12
  27. package/dist/types/components/DDatePicker/components/DDatePickerHeaderSelector.d.ts +38 -0
  28. package/dist/types/components/{DDatePickerInput → DDatePicker/components}/DDatePickerInput.d.ts +2 -2
  29. package/dist/types/components/{DDatePickerTime → DDatePicker/components}/DDatePickerTime.d.ts +2 -2
  30. package/dist/types/components/DInput/DInput.d.ts +1 -1
  31. package/dist/types/components/DInputCounter/DInputCounter.d.ts +2 -2
  32. package/dist/types/components/DInputCurrency/DInputCurrency.d.ts +2 -2
  33. package/dist/types/components/DInputCurrencyBase/DInputCurrencyBase.d.ts +2 -2
  34. package/dist/types/components/DInputMask/DInputMask.d.ts +1 -1
  35. package/dist/types/components/DInputRange/DInputRange.d.ts +1 -1
  36. package/dist/types/components/DInputSearch/DInputSearch.d.ts +1 -1
  37. package/dist/types/components/DPopover/DPopover.d.ts +0 -3
  38. package/dist/types/utils/attr-accept.d.ts +11 -0
  39. package/dist/types/utils/getKeyboardFocusableElements.d.ts +1 -0
  40. package/jest/setup.js +14 -0
  41. package/package.json +13 -14
  42. package/src/style/abstracts/variables/_+import.scss +1 -0
  43. package/src/style/abstracts/variables/_box-file.scss +14 -7
  44. package/src/style/abstracts/variables/_cards.scss +1 -1
  45. package/src/style/abstracts/variables/_datepicker.scss +50 -0
  46. package/src/style/abstracts/variables/_forms.scss +6 -3
  47. package/src/style/base/_form-switch.scss +23 -2
  48. package/src/style/base/_input-group.scss +18 -1
  49. package/src/style/base/_nav.scss +0 -1
  50. package/src/style/base/_toast.scss +2 -0
  51. package/src/style/components/_d-box-file.scss +31 -15
  52. package/src/style/components/_d-button-icon.scss +17 -16
  53. package/src/style/components/_d-datepicker.scss +578 -243
  54. package/src/style/components/_d-input-pin.scss +8 -5
  55. package/src/style/components/_d-quick-action-button.scss +1 -1
  56. package/src/style/components/_d-quick-action-check.scss +1 -1
  57. package/src/style/components/_d-select.scss +35 -6
  58. package/src/style/components/_d-stepper-desktop.scss +1 -1
  59. package/src/style/helpers/_text-truncate.scss +2 -2
  60. package/dist/types/components/DDatePickerHeader/DDatePickerHeader.d.ts +0 -24
  61. package/dist/types/components/DDatePickerHeader/index.d.ts +0 -2
  62. package/dist/types/components/DDatePickerInput/index.d.ts +0 -2
  63. package/dist/types/components/DDatePickerTime/index.d.ts +0 -2
package/dist/index.js CHANGED
@@ -5,11 +5,12 @@ var React = require('react');
5
5
  var classNames = require('classnames');
6
6
  var tslib = require('tslib');
7
7
  var reactDom = require('react-dom');
8
- var reactDropzone = require('react-dropzone');
8
+ var fileSelector = require('file-selector');
9
9
  var reactSplide = require('@splidejs/react-splide');
10
10
  var currency = require('currency.js');
11
11
  var DatePicker = require('react-datepicker');
12
12
  var dateFns = require('date-fns');
13
+ var locale = require('date-fns/locale');
13
14
  var Select = require('react-select');
14
15
  var mask = require('@react-input/mask');
15
16
  var ResponsivePagination = require('react-responsive-pagination');
@@ -21,7 +22,7 @@ var reactI18next = require('react-i18next');
21
22
 
22
23
  const PREFIX_BS = 'bs-';
23
24
 
24
- function DIconBase({ icon, theme, style, className, size = '1.5rem', loading = false, loadingDuration = 1.8, hasCircle = false, circleSize = `calc(var(--${PREFIX_BS}icon-component-size) * 1)`, color, backgroundColor, materialStyle = false, familyClass = 'bi', familyPrefix = 'bi-', dataAttributes, }) {
25
+ function DIconBase({ icon, theme, style, className, size, loading = false, loadingDuration = 1.8, hasCircle = false, circleSize = `calc(var(--${PREFIX_BS}icon-size) * 1)`, color, backgroundColor, materialStyle = false, familyClass = 'bi', familyPrefix = 'bi-', dataAttributes, }) {
25
26
  const colorStyle = React.useMemo(() => {
26
27
  if (color) {
27
28
  return { [`--${PREFIX_BS}icon-component-color`]: color };
@@ -49,7 +50,7 @@ function DIconBase({ icon, theme, style, className, size = '1.5rem', loading = f
49
50
  }
50
51
  return { [`--${PREFIX_BS}icon-component-padding`]: '0' };
51
52
  }, [circleSize, hasCircle]);
52
- const generateStyleVariables = React.useMemo(() => (Object.assign(Object.assign(Object.assign(Object.assign({ [`--${PREFIX_BS}icon-component-size`]: size, [`--${PREFIX_BS}icon-component-loading-duration`]: `${loadingDuration}s` }, colorStyle), backgroundStyle), circleSizeStyle), style)), [size, loadingDuration, colorStyle, backgroundStyle, circleSizeStyle, style]);
53
+ const generateStyleVariables = React.useMemo(() => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ [`--${PREFIX_BS}icon-component-loading-duration`]: `${loadingDuration}s` }, size && { [`--${PREFIX_BS}icon-component-size`]: size }), colorStyle), backgroundStyle), circleSizeStyle), style)), [size, loadingDuration, colorStyle, backgroundStyle, circleSizeStyle, style]);
53
54
  const generateClasses = React.useMemo(() => (Object.assign(Object.assign({ 'd-icon': true, [familyClass]: true, 'd-icon-loading': loading }, !materialStyle && {
54
55
  [`${familyPrefix}${icon}`]: true,
55
56
  }), className && { [className]: true })), [
@@ -128,12 +129,22 @@ function useStackState(initialList = []) {
128
129
  return [list, controls];
129
130
  }
130
131
 
132
+ function getKeyboardFocusableElements(container) {
133
+ if (!container) {
134
+ return [];
135
+ }
136
+ return [
137
+ ...container.querySelectorAll('a, button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])'),
138
+ ].filter((element) => !element.hasAttribute('disabled'));
139
+ }
140
+
131
141
  const DPortalContext = React.createContext(undefined);
132
142
  function DPortalContextProvider({ portalName, children, availablePortals, }) {
133
143
  const { created } = usePortal(portalName);
134
144
  const [stack, { push, pop, isEmpty }] = useStackState([]);
135
145
  useDisableBodyScrollEffect(Boolean(stack.length));
136
146
  const openPortal = React.useCallback((name, payload) => {
147
+ var _a;
137
148
  if (!availablePortals) {
138
149
  throw new Error(`there is no component for portal ${name.toString()}`);
139
150
  }
@@ -146,6 +157,7 @@ function DPortalContextProvider({ portalName, children, availablePortals, }) {
146
157
  Component,
147
158
  payload,
148
159
  });
160
+ (_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.blur();
149
161
  }, [availablePortals, push]);
150
162
  const closePortal = React.useCallback(() => {
151
163
  if (isEmpty()) {
@@ -175,10 +187,26 @@ function DPortalContextProvider({ portalName, children, availablePortals, }) {
175
187
  }, [closePortal]);
176
188
  React.useEffect(() => {
177
189
  const keyEvent = (event) => {
190
+ const lastPortal = document.querySelector(`#${portalName} > div > div:last-child`);
178
191
  if (event.key === 'Escape') {
179
- const lastPortal = document.querySelector(`#${portalName} > div > div:last-child`);
180
192
  if (lastPortal) {
181
193
  handleClose(lastPortal);
194
+ return;
195
+ }
196
+ }
197
+ if (event.key === 'Tab') {
198
+ const focusableElements = getKeyboardFocusableElements(lastPortal);
199
+ if (focusableElements.length === 0)
200
+ return;
201
+ const firstElement = focusableElements[0];
202
+ const lastElement = focusableElements[focusableElements.length - 1];
203
+ if (event.shiftKey && document.activeElement === firstElement) {
204
+ event.preventDefault();
205
+ lastElement.focus();
206
+ }
207
+ else if (!event.shiftKey && document.activeElement === lastElement) {
208
+ event.preventDefault();
209
+ firstElement.focus();
182
210
  }
183
211
  }
184
212
  };
@@ -272,7 +300,6 @@ function DContextProvider({ language = DEFAULT_STATE.language, currency = DEFAUL
272
300
  });
273
301
  const setContext = React.useCallback((newValue) => (setInternalContext((prevInternalContext) => (Object.assign(Object.assign({}, prevInternalContext), newValue)))), []);
274
302
  React.useLayoutEffect(() => {
275
- console.log('context');
276
303
  setContext({
277
304
  breakpoints: {
278
305
  xs: getCssVariable(`--${PREFIX_BS}breakpoint-xs`),
@@ -342,18 +369,494 @@ function DBadge({ text, soft = false, theme = 'primary', id, rounded, className,
342
369
  return (jsxRuntime.jsxs("span", Object.assign({ className: classNames(generateClasses, className), style: style }, id && { id }, dataAttributes, { children: [iconStart && (jsxRuntime.jsx(DIcon, { icon: iconStart, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle })), jsxRuntime.jsx("span", { children: text }), iconEnd && (jsxRuntime.jsx(DIcon, { icon: iconEnd, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle }))] })));
343
370
  }
344
371
 
372
+ /* eslint-disable */
373
+ /**
374
+ * This file is originally from `@primer/react`
375
+ * The original source for this lived in the URL below.
376
+ *
377
+ * @see https://github.com/primer/react/blob/216d2a9f57b8acb0701ab4e04a23e057fc325c90/src/hooks/useProvidedRefOrCreate.ts
378
+ */
379
+ /**
380
+ * There are some situations where we only want to create a new ref if one is not provided to a component
381
+ * or hook as a prop. However, due to the `rules-of-hooks`, we cannot conditionally make a call to `React.useRef`
382
+ * only in the situations where the ref is not provided as a prop.
383
+ * This hook aims to encapsulate that logic, so the consumer doesn't need to be concerned with violating `rules-of-hooks`.
384
+ * @param providedRef The ref to use - if undefined, will use the ref from a call to React.useRef
385
+ * @type TRef The type of the RefObject which should be created.
386
+ */
387
+ function useProvidedRefOrCreate(providedRef) {
388
+ const createdRef = React.useRef(null);
389
+ return providedRef !== null && providedRef !== void 0 ? providedRef : createdRef;
390
+ }
391
+
392
+ function DInput(_a, ref) {
393
+ var { id: idProp, style, className, label = '', labelIcon, labelIconFamilyClass, labelIconFamilyPrefix, labelIconMaterialStyle, disabled = false, loading = false, iconFamilyClass, iconFamilyPrefix, iconMaterialStyle, iconStart, iconStartDisabled, iconStartFamilyClass, iconStartFamilyPrefix, iconStartAriaLabel, iconStartTabIndex, iconStartMaterialStyle, iconEnd, iconEndDisabled, iconEndFamilyClass, iconEndFamilyPrefix, iconEndAriaLabel, iconEndTabIndex, iconEndMaterialStyle, hint, size, invalid = false, valid = false, floatingLabel = false, inputStart, inputEnd, value, placeholder = '', dataAttributes, onChange, onIconStartClick, onIconEndClick } = _a, inputProps = tslib.__rest(_a, ["id", "style", "className", "label", "labelIcon", "labelIconFamilyClass", "labelIconFamilyPrefix", "labelIconMaterialStyle", "disabled", "loading", "iconFamilyClass", "iconFamilyPrefix", "iconMaterialStyle", "iconStart", "iconStartDisabled", "iconStartFamilyClass", "iconStartFamilyPrefix", "iconStartAriaLabel", "iconStartTabIndex", "iconStartMaterialStyle", "iconEnd", "iconEndDisabled", "iconEndFamilyClass", "iconEndFamilyPrefix", "iconEndAriaLabel", "iconEndTabIndex", "iconEndMaterialStyle", "hint", "size", "invalid", "valid", "floatingLabel", "inputStart", "inputEnd", "value", "placeholder", "dataAttributes", "onChange", "onIconStartClick", "onIconEndClick"]);
394
+ const inputRef = useProvidedRefOrCreate(ref);
395
+ const innerId = React.useId();
396
+ const id = React.useMemo(() => idProp || innerId, [idProp, innerId]);
397
+ const handleOnChange = React.useCallback((event) => {
398
+ onChange === null || onChange === void 0 ? void 0 : onChange(event.currentTarget.value);
399
+ }, [onChange]);
400
+ const handleOnIconStartClick = React.useCallback(() => {
401
+ onIconStartClick === null || onIconStartClick === void 0 ? void 0 : onIconStartClick(value);
402
+ }, [onIconStartClick, value]);
403
+ const handleOnIconEndClick = React.useCallback(() => {
404
+ onIconEndClick === null || onIconEndClick === void 0 ? void 0 : onIconEndClick(value);
405
+ }, [onIconEndClick, value]);
406
+ const ariaDescribedby = React.useMemo(() => ([
407
+ !!inputStart && `${id}InputStart`,
408
+ !!iconStart && `${id}Start`,
409
+ (invalid || valid) && !iconEnd && !loading && `${id}State`,
410
+ (iconEnd && !loading) && `${id}End`,
411
+ loading && `${id}Loading`,
412
+ !!inputEnd && `${id}InputEnd`,
413
+ !!hint && `${id}Hint`,
414
+ ]
415
+ .filter(Boolean)
416
+ .join(' ')), [
417
+ id,
418
+ inputStart,
419
+ iconStart,
420
+ invalid,
421
+ valid,
422
+ iconEnd,
423
+ loading,
424
+ inputEnd,
425
+ hint,
426
+ ]);
427
+ const inputComponent = React.useMemo(() => (jsxRuntime.jsx("input", Object.assign({ ref: inputRef, id: id, className: classNames('form-control', {
428
+ 'is-invalid': invalid,
429
+ 'is-valid': valid,
430
+ }), disabled: disabled || loading, value: value, onChange: handleOnChange }, (floatingLabel || placeholder) && { placeholder: floatingLabel ? '' : placeholder }, ariaDescribedby && { 'aria-describedby': ariaDescribedby }, inputProps))), [
431
+ ariaDescribedby,
432
+ disabled,
433
+ handleOnChange,
434
+ id,
435
+ inputProps,
436
+ inputRef,
437
+ invalid,
438
+ loading,
439
+ placeholder,
440
+ floatingLabel,
441
+ valid,
442
+ value,
443
+ ]);
444
+ const labelComponent = React.useMemo(() => (jsxRuntime.jsxs("label", { htmlFor: id, children: [label, labelIcon && (jsxRuntime.jsx(DIcon, { icon: labelIcon, size: `var(--${PREFIX_BS}label-font-size)`, familyClass: labelIconFamilyClass, familyPrefix: labelIconFamilyPrefix, materialStyle: labelIconMaterialStyle }))] })), [
445
+ id,
446
+ label,
447
+ labelIcon,
448
+ labelIconFamilyClass,
449
+ labelIconFamilyPrefix,
450
+ labelIconMaterialStyle,
451
+ ]);
452
+ const dynamicComponent = React.useMemo(() => {
453
+ if (floatingLabel) {
454
+ return (jsxRuntime.jsxs("div", { className: "form-floating", children: [inputComponent, labelComponent] }));
455
+ }
456
+ return inputComponent;
457
+ }, [floatingLabel, inputComponent, labelComponent]);
458
+ return (jsxRuntime.jsxs("div", Object.assign({ className: className, style: style }, dataAttributes, { children: [label && !floatingLabel && labelComponent, jsxRuntime.jsxs("div", { className: classNames({
459
+ [`input-group-${size}`]: !!size,
460
+ 'input-group': true,
461
+ 'has-validation': invalid || valid,
462
+ }), children: [!!inputStart && (jsxRuntime.jsx("div", { className: "input-group-text", id: `${id}InputStart`, children: inputStart })), iconStart && (jsxRuntime.jsx("button", { type: "button", className: "input-group-text", id: `${id}Start`, onClick: handleOnIconStartClick, disabled: disabled || loading || iconStartDisabled, "aria-label": iconStartAriaLabel, tabIndex: onIconStartClick ? iconStartTabIndex : -1, children: jsxRuntime.jsx(DIcon, { icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix, materialStyle: iconStartMaterialStyle }) })), dynamicComponent, (iconEnd && !loading) && (jsxRuntime.jsx("button", { type: "button", className: "input-group-text", id: `${id}End`, onClick: handleOnIconEndClick, disabled: disabled || loading || iconEndDisabled, "aria-label": iconEndAriaLabel, tabIndex: onIconEndClick ? iconEndTabIndex : -1, children: jsxRuntime.jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix, materialStyle: iconEndMaterialStyle }) })), loading && (jsxRuntime.jsx("div", { className: "input-group-text", id: `${id}Loading`, children: jsxRuntime.jsx("span", { className: "spinner-border spinner-border-sm", role: "status", "aria-hidden": "true", children: jsxRuntime.jsx("span", { className: "visually-hidden", children: "Loading..." }) }) })), !!inputEnd && (jsxRuntime.jsx("div", { className: "input-group-text", id: `${id}InputEnd`, children: inputEnd }))] }), hint && (jsxRuntime.jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] })));
463
+ }
464
+ const ForwardedDInput = React.forwardRef(DInput);
465
+ ForwardedDInput.displayName = 'DInput';
466
+
467
+ /**
468
+ * Check if the provided file type should be accepted by the input with accept attribute.
469
+ * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#attr-accept
470
+ *
471
+ * Inspired by https://github.com/enyo/dropzone
472
+ *
473
+ * @param file {File} https://developer.mozilla.org/en-US/docs/Web/API/File
474
+ * @param acceptedFiles {string|string[]}
475
+ * @returns {boolean}
476
+ */
477
+ function attrAccept(file, acceptedFiles) {
478
+ if (file && acceptedFiles) {
479
+ const acceptedFilesArray = Array.isArray(acceptedFiles)
480
+ ? acceptedFiles
481
+ : acceptedFiles.split(',');
482
+ if (acceptedFilesArray.length === 0) {
483
+ return true;
484
+ }
485
+ const fileName = file.name || '';
486
+ const mimeType = (file.type || '').toLowerCase();
487
+ const baseMimeType = mimeType.replace(/\/.*$/, '');
488
+ return acceptedFilesArray.some((type) => {
489
+ const validType = type.trim().toLowerCase();
490
+ if (validType.charAt(0) === '.') {
491
+ return fileName.toLowerCase().endsWith(validType);
492
+ }
493
+ if (validType.endsWith('/*')) {
494
+ // This is something like a image/* mime type
495
+ return baseMimeType === validType.replace(/\/.*$/, '');
496
+ }
497
+ return mimeType === validType;
498
+ });
499
+ }
500
+ return true;
501
+ }
502
+
503
+ const isIeOrEdge = (userAgent = window.navigator.userAgent) => ((userAgent.indexOf('MSIE') !== -1 || userAgent.indexOf('Trident/') !== -1)
504
+ || userAgent.indexOf('Edge/') !== -1);
505
+ const ErrorCodes = {
506
+ FileInvalidType: 'file-invalid-type',
507
+ FileTooLarge: 'file-too-large',
508
+ FileTooSmall: 'file-too-small',
509
+ TooManyFiles: 'too-many-files',
510
+ FailedFetch: 'failed-fetch-file',
511
+ };
512
+ // Check if v is a MIME type string.
513
+ function isMIMEType(v) {
514
+ return (v === 'audio/*'
515
+ || v === 'video/*'
516
+ || v === 'image/*'
517
+ || v === 'text/*'
518
+ || v === 'application/*'
519
+ || /\w+\/[-+.\w]+/g.test(v));
520
+ }
521
+ // Check if v is a file extension.
522
+ function isExt(v) {
523
+ return /^.*\.[\w]+$/.test(v);
524
+ }
525
+ function isDefined(value) {
526
+ return value !== undefined && value !== null;
527
+ }
528
+ // Convert the `{accept}` dropzone prop to an array of MIME types/extensions.
529
+ function acceptPropAsAcceptAttr(accept) {
530
+ return (Object.entries(accept)
531
+ .reduce((a, [mimeType, ext]) => [...a, mimeType, ...ext], [])
532
+ .filter((v) => isMIMEType(v) || isExt(v))
533
+ .join(','));
534
+ }
535
+ function fileAccepted(file, accept) {
536
+ const isAcceptable = file.type === 'application/x-moz-file' || attrAccept(file, accept);
537
+ if (!isAcceptable) {
538
+ return [
539
+ false,
540
+ {
541
+ code: ErrorCodes.FileInvalidType,
542
+ message: 'File has an unsupported file type',
543
+ },
544
+ ];
545
+ }
546
+ return [true, null];
547
+ }
548
+ function fileMatchSize(file, minSize, maxSize) {
549
+ if (isDefined(file.size)) {
550
+ if (isDefined(minSize) && file.size < minSize) {
551
+ return [
552
+ false,
553
+ {
554
+ code: ErrorCodes.FileTooSmall,
555
+ message: `File "${file.name}" is too small. Minimum size is ${minSize} bytes.`,
556
+ },
557
+ ];
558
+ }
559
+ if (isDefined(maxSize) && file.size > maxSize) {
560
+ return [
561
+ false, {
562
+ code: ErrorCodes.FileTooLarge,
563
+ message: `File "${file.name}" is too large. Maximum size is ${maxSize} bytes.`,
564
+ },
565
+ ];
566
+ }
567
+ }
568
+ return [true, null];
569
+ }
570
+ async function urlToFile(url) {
571
+ var _a;
572
+ try {
573
+ const res = await fetch(url);
574
+ if (!res.ok) {
575
+ return [
576
+ null,
577
+ {
578
+ code: ErrorCodes.FailedFetch,
579
+ message: `Failed to fetch file from ${url}`,
580
+ },
581
+ ];
582
+ }
583
+ const blob = await res.blob();
584
+ const filename = ((_a = url.split('/').pop()) === null || _a === void 0 ? void 0 : _a.split('?')[0]) || 'file';
585
+ const file = new File([blob], filename, { type: blob.type });
586
+ return [file, null];
587
+ }
588
+ catch (error) {
589
+ return [
590
+ null,
591
+ {
592
+ code: ErrorCodes.FailedFetch,
593
+ message: `Failed to fetch file from ${url}}`,
594
+ },
595
+ ];
596
+ }
597
+ }
598
+ async function urlsToFiles(urls) {
599
+ const results = await Promise.all(urls.map(urlToFile));
600
+ let acceptedFiles = [];
601
+ let errors = [];
602
+ results.forEach(([file, error]) => {
603
+ if (file) {
604
+ acceptedFiles = [...acceptedFiles, file];
605
+ }
606
+ if (error) {
607
+ errors = [...errors, error];
608
+ }
609
+ });
610
+ return [acceptedFiles, errors];
611
+ }
612
+ const DEFAULT_PROPS = {
613
+ disabled: false,
614
+ maxSize: Infinity,
615
+ minSize: 0,
616
+ multiple: false,
617
+ maxFiles: Infinity,
618
+ noClick: false,
619
+ noKeyboard: false,
620
+ noDrag: false,
621
+ autoFocus: false,
622
+ };
623
+
624
+ /* eslint-disable no-param-reassign */
625
+ function useDBoxFile(props) {
626
+ const { accept, autoFocus, disabled, maxSize, minSize, multiple, maxFiles, value: preloadUrls, onDragEnter, onDragLeave, onDrop, onError, noClick, noKeyboard, noDrag, } = Object.assign(Object.assign({}, DEFAULT_PROPS), props);
627
+ const inputRef = React.useRef(null);
628
+ const rootRef = React.useRef(null);
629
+ const dragTargetsRef = React.useRef([]);
630
+ const acceptAttr = React.useMemo(() => acceptPropAsAcceptAttr(accept), [accept]);
631
+ const [files, setFiles] = React.useState([]);
632
+ const [isDragValid, setIsDragValid] = React.useState(false);
633
+ const [isDragInvalid, setIsDragInvalid] = React.useState(false);
634
+ const preventDropOnDocument = React.useCallback((event) => {
635
+ if (rootRef.current && rootRef.current.contains(event.target)) {
636
+ // If we intercepted an event for our instance
637
+ // let it propagate down to the instance's onDrop handler
638
+ return;
639
+ }
640
+ event.preventDefault();
641
+ dragTargetsRef.current = [];
642
+ }, []);
643
+ React.useEffect(() => {
644
+ // Prevent drop over anywhere in the document
645
+ document.addEventListener('dragover', preventDropOnDocument, false);
646
+ document.addEventListener('drop', preventDropOnDocument, false);
647
+ return () => {
648
+ document.removeEventListener('dragover', preventDropOnDocument);
649
+ document.removeEventListener('drop', preventDropOnDocument);
650
+ };
651
+ }, [preventDropOnDocument]);
652
+ // Auto focus the root when autoFocus is true
653
+ React.useEffect(() => {
654
+ if (!disabled && autoFocus && rootRef.current) {
655
+ rootRef.current.focus();
656
+ }
657
+ }, [rootRef, autoFocus, disabled]);
658
+ React.useEffect(() => {
659
+ if (!preloadUrls || !preloadUrls.length)
660
+ return;
661
+ // eslint-disable-next-line no-void
662
+ void (async () => {
663
+ const [accepted, errors] = await urlsToFiles(preloadUrls);
664
+ if (accepted.length) {
665
+ setFiles(accepted);
666
+ }
667
+ if (errors.length) {
668
+ onError === null || onError === void 0 ? void 0 : onError(new Error(errors.map((e) => e.message).join(', ')));
669
+ }
670
+ })();
671
+ }, [preloadUrls, onError]);
672
+ const processFiles = React.useCallback((inputFiles, event) => {
673
+ let acceptedFiles = [];
674
+ let rejectedFiles = [];
675
+ // Handle size and type validation
676
+ inputFiles.forEach((file) => {
677
+ const [isTypeValid, acceptError] = fileAccepted(file, acceptAttr);
678
+ const [isSizeValid, sizeError] = fileMatchSize(file, minSize, maxSize);
679
+ const errors = [acceptError, sizeError].filter((e) => Boolean(e));
680
+ if (isTypeValid && isSizeValid) {
681
+ acceptedFiles = [...acceptedFiles, file];
682
+ }
683
+ else {
684
+ rejectedFiles = [...rejectedFiles, { file, errors }];
685
+ }
686
+ });
687
+ // Handle maxFiles overflow by trimming
688
+ const total = files.length + acceptedFiles.length;
689
+ if (total > maxFiles) {
690
+ const allowed = Math.max(0, maxFiles - files.length);
691
+ const accepted = acceptedFiles.slice(0, allowed);
692
+ const rejected = acceptedFiles.slice(allowed).map((file) => ({
693
+ file,
694
+ errors: [
695
+ {
696
+ code: ErrorCodes.TooManyFiles,
697
+ message: `Exceeds maximum number of files (${maxFiles})`,
698
+ },
699
+ ],
700
+ }));
701
+ acceptedFiles = [...accepted];
702
+ rejectedFiles = [...rejectedFiles, ...rejected];
703
+ }
704
+ if (multiple) {
705
+ setFiles((prev) => [...prev, ...acceptedFiles]);
706
+ }
707
+ else {
708
+ setFiles(acceptedFiles.slice(0, 1));
709
+ }
710
+ if (onDrop) {
711
+ onDrop(acceptedFiles, rejectedFiles, event);
712
+ }
713
+ }, [
714
+ acceptAttr,
715
+ files.length,
716
+ maxFiles,
717
+ maxSize,
718
+ minSize,
719
+ multiple,
720
+ onDrop,
721
+ ]);
722
+ const handleDragEnter = React.useCallback((event) => {
723
+ event.preventDefault();
724
+ event.stopPropagation();
725
+ if (disabled || noDrag)
726
+ return;
727
+ if (event.target instanceof HTMLElement) {
728
+ dragTargetsRef.current = [...dragTargetsRef.current, event.target];
729
+ }
730
+ fileSelector.fromEvent(event).then((eventFiles) => {
731
+ const fileCount = eventFiles.length;
732
+ if (fileCount === 0) {
733
+ setIsDragValid(false);
734
+ setIsDragInvalid(true);
735
+ return;
736
+ }
737
+ const isDragAccepted = eventFiles.every((file) => {
738
+ const [typeValid] = fileAccepted(file, acceptAttr);
739
+ const [sizeValid] = fileMatchSize(file, minSize, maxSize);
740
+ return typeValid && sizeValid;
741
+ });
742
+ setIsDragValid(isDragAccepted);
743
+ setIsDragInvalid(!isDragAccepted);
744
+ onDragEnter === null || onDragEnter === void 0 ? void 0 : onDragEnter(event);
745
+ }).catch((error) => {
746
+ onError === null || onError === void 0 ? void 0 : onError(error);
747
+ });
748
+ }, [
749
+ acceptAttr,
750
+ disabled,
751
+ maxSize,
752
+ minSize,
753
+ noDrag,
754
+ onDragEnter,
755
+ onError,
756
+ ]);
757
+ const handleDrop = React.useCallback((event) => {
758
+ event.preventDefault();
759
+ event.persist();
760
+ event.stopPropagation();
761
+ dragTargetsRef.current = [];
762
+ setIsDragValid(false);
763
+ setIsDragInvalid(false);
764
+ if (disabled || noDrag)
765
+ return;
766
+ const droppedArray = Array.from(event.dataTransfer.files);
767
+ processFiles(droppedArray, event.nativeEvent);
768
+ }, [
769
+ disabled,
770
+ noDrag,
771
+ processFiles,
772
+ ]);
773
+ const handleDragLeave = React.useCallback((event) => {
774
+ event.preventDefault();
775
+ event.stopPropagation();
776
+ if (disabled || noDrag)
777
+ return;
778
+ // Only deactivate once the dropzone and all children have been left
779
+ const targets = dragTargetsRef.current.filter((target) => rootRef.current && rootRef.current.contains(target));
780
+ // Make sure to remove a target present multiple times only once
781
+ // (Firefox may fire dragenter/dragleave multiple times on the same element)
782
+ if (event.target instanceof HTMLElement) {
783
+ const targetIdx = targets.indexOf(event.target);
784
+ if (targetIdx !== -1) {
785
+ targets.splice(targetIdx, 1);
786
+ }
787
+ dragTargetsRef.current = targets;
788
+ }
789
+ if (targets.length === 0) {
790
+ setIsDragValid(false);
791
+ setIsDragInvalid(false);
792
+ onDragLeave === null || onDragLeave === void 0 ? void 0 : onDragLeave(event);
793
+ }
794
+ }, [disabled, noDrag, onDragLeave]);
795
+ const handleFileSelect = React.useCallback((event) => {
796
+ const targetFiles = event.target.files;
797
+ if (!targetFiles)
798
+ return;
799
+ const selectedFiles = Array.from(targetFiles);
800
+ processFiles(selectedFiles, event.nativeEvent);
801
+ event.target.value = '';
802
+ }, [processFiles]);
803
+ const handleRemoveFile = React.useCallback((index) => {
804
+ setFiles((prevFiles) => prevFiles.filter((_, i) => i !== index));
805
+ }, []);
806
+ const openFileDialog = React.useCallback(() => {
807
+ var _a;
808
+ if (disabled)
809
+ return;
810
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.click();
811
+ }, [disabled]);
812
+ const handleClick = React.useCallback(() => {
813
+ if (noClick) {
814
+ return;
815
+ }
816
+ if (isIeOrEdge()) {
817
+ setTimeout(openFileDialog, 0);
818
+ }
819
+ else {
820
+ openFileDialog();
821
+ }
822
+ }, [noClick, openFileDialog]);
823
+ const handleKeyDown = React.useCallback((event) => {
824
+ if (!noKeyboard && (event.key === ' ' || event.key === 'Enter')) {
825
+ event.preventDefault();
826
+ openFileDialog();
827
+ }
828
+ }, [noKeyboard, openFileDialog]);
829
+ return {
830
+ inputRef,
831
+ rootRef,
832
+ files,
833
+ isDragValid,
834
+ isDragInvalid,
835
+ acceptAttr,
836
+ openFileDialog,
837
+ handleFileSelect,
838
+ handleDrop,
839
+ handleDragEnter,
840
+ handleDragLeave,
841
+ handleRemoveFile,
842
+ handleClick,
843
+ handleKeyDown,
844
+ };
845
+ }
846
+
345
847
  function DBoxFile(_a) {
346
- var { icon: iconProp, iconFamilyClass, iconFamilyPrefix, iconMaterialStyle, disabled = false, children, className, style, dataAttributes } = _a, dropzoneOptions = tslib.__rest(_a, ["icon", "iconFamilyClass", "iconFamilyPrefix", "iconMaterialStyle", "disabled", "children", "className", "style", "dataAttributes"]);
347
- const { acceptedFiles, getRootProps, getInputProps, } = reactDropzone.useDropzone(Object.assign({ disabled }, dropzoneOptions));
348
- const { iconMap: { upload, }, } = useDContext();
848
+ var { icon: iconProp, iconFamilyClass, iconFamilyPrefix, iconMaterialStyle, children, className, style, dataAttributes } = _a, props = tslib.__rest(_a, ["icon", "iconFamilyClass", "iconFamilyPrefix", "iconMaterialStyle", "children", "className", "style", "dataAttributes"]);
849
+ const { iconMap: { upload } } = useDContext();
349
850
  const icon = React.useMemo(() => iconProp || upload, [iconProp, upload]);
350
- return (jsxRuntime.jsxs("section", Object.assign({ className: classNames('d-box-file', {
351
- 'd-box-file-selected': !!acceptedFiles.length,
352
- }, className), style: style }, dataAttributes, { children: [jsxRuntime.jsxs("div", Object.assign({}, getRootProps({
353
- className: classNames('d-box-file-dropzone', {
354
- disabled,
355
- }),
356
- }), { children: [jsxRuntime.jsx("input", Object.assign({}, getInputProps())), jsxRuntime.jsx(DIcon, { icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle }), jsxRuntime.jsx("div", { className: "d-box-content", children: children })] })), !!acceptedFiles.length && (jsxRuntime.jsx("aside", { className: "d-box-files", children: acceptedFiles.map((file) => (jsxRuntime.jsx("div", { className: "d-box-files-text", children: `${file.name} - ${file.size} bytes` }, file.name))) }))] })));
851
+ const { inputRef, rootRef, isDragValid, isDragInvalid, acceptAttr, files, handleFileSelect, handleDrop, handleDragEnter, handleDragLeave, handleClick, handleKeyDown, handleRemoveFile, openFileDialog, } = useDBoxFile(props);
852
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("section", Object.assign({ className: classNames('d-box-file', {
853
+ 'd-box-file-selected': files.length > 0,
854
+ 'd-box-file-disabled': props.disabled,
855
+ 'd-box-file-valid': isDragValid,
856
+ 'd-box-file-invalid': isDragInvalid,
857
+ }, className), style: style }, dataAttributes, { children: jsxRuntime.jsxs("div", Object.assign({ className: "d-box-file-dropzone", ref: rootRef, onDragEnter: handleDragEnter, onDragOver: (e) => e.preventDefault(), onDragLeave: handleDragLeave, onDrop: handleDrop, onClick: handleClick, onKeyDown: handleKeyDown }, (!props.disabled && !props.noKeyboard ? { tabIndex: 0 } : {}), { role: "presentation", children: [jsxRuntime.jsx("input", { type: "file", multiple: props.multiple, style: { display: 'none' }, ref: inputRef, disabled: props.disabled, onChange: handleFileSelect, onClick: (e) => e.stopPropagation(), tabIndex: -1, accept: acceptAttr }), jsxRuntime.jsx(DIcon, { icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle }), jsxRuntime.jsx("div", { className: "d-box-content", children: typeof children === 'function'
858
+ ? children(openFileDialog)
859
+ : children })] })) })), !!files.length && (jsxRuntime.jsx("ul", { className: "d-box-files", children: files.map((file, index) => (jsxRuntime.jsx(ForwardedDInput, { value: file.name, iconStart: "paperclip", iconEnd: "trash", readOnly: true, onIconEndClick: () => handleRemoveFile(index) }, file.name))) }))] }));
357
860
  }
358
861
 
359
862
  function DButton({ theme = 'primary', size, variant, state, text = '', ariaLabel, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconStartMaterialStyle, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, iconEndMaterialStyle, value, type = 'button', loading = false, loadingAriaLabel, disabled = false, stopPropagationEnabled = true, className, style, form, dataAttributes, onClick, }) {
@@ -494,102 +997,6 @@ function DCurrencyText({ value, className, style, dataAttributes, }) {
494
997
  return (jsxRuntime.jsx("span", Object.assign({ className: className, style: style }, dataAttributes, { children: valueFormatted })));
495
998
  }
496
999
 
497
- /* eslint-disable */
498
- /**
499
- * This file is originally from `@primer/react`
500
- * The original source for this lived in the URL below.
501
- *
502
- * @see https://github.com/primer/react/blob/216d2a9f57b8acb0701ab4e04a23e057fc325c90/src/hooks/useProvidedRefOrCreate.ts
503
- */
504
- /**
505
- * There are some situations where we only want to create a new ref if one is not provided to a component
506
- * or hook as a prop. However, due to the `rules-of-hooks`, we cannot conditionally make a call to `React.useRef`
507
- * only in the situations where the ref is not provided as a prop.
508
- * This hook aims to encapsulate that logic, so the consumer doesn't need to be concerned with violating `rules-of-hooks`.
509
- * @param providedRef The ref to use - if undefined, will use the ref from a call to React.useRef
510
- * @type TRef The type of the RefObject which should be created.
511
- */
512
- function useProvidedRefOrCreate(providedRef) {
513
- const createdRef = React.useRef(null);
514
- return providedRef !== null && providedRef !== void 0 ? providedRef : createdRef;
515
- }
516
-
517
- function DInput(_a, ref) {
518
- var { id: idProp, style, className, label = '', labelIcon, labelIconFamilyClass, labelIconFamilyPrefix, labelIconMaterialStyle, disabled = false, loading = false, iconFamilyClass, iconFamilyPrefix, iconMaterialStyle, iconStart, iconStartDisabled, iconStartFamilyClass, iconStartFamilyPrefix, iconStartAriaLabel, iconStartTabIndex, iconStartMaterialStyle, iconEnd, iconEndDisabled, iconEndFamilyClass, iconEndFamilyPrefix, iconEndAriaLabel, iconEndTabIndex, iconEndMaterialStyle, hint, size, invalid = false, valid = false, floatingLabel = false, inputStart, inputEnd, value, placeholder = '', dataAttributes, onChange, onIconStartClick, onIconEndClick } = _a, inputProps = tslib.__rest(_a, ["id", "style", "className", "label", "labelIcon", "labelIconFamilyClass", "labelIconFamilyPrefix", "labelIconMaterialStyle", "disabled", "loading", "iconFamilyClass", "iconFamilyPrefix", "iconMaterialStyle", "iconStart", "iconStartDisabled", "iconStartFamilyClass", "iconStartFamilyPrefix", "iconStartAriaLabel", "iconStartTabIndex", "iconStartMaterialStyle", "iconEnd", "iconEndDisabled", "iconEndFamilyClass", "iconEndFamilyPrefix", "iconEndAriaLabel", "iconEndTabIndex", "iconEndMaterialStyle", "hint", "size", "invalid", "valid", "floatingLabel", "inputStart", "inputEnd", "value", "placeholder", "dataAttributes", "onChange", "onIconStartClick", "onIconEndClick"]);
519
- const inputRef = useProvidedRefOrCreate(ref);
520
- const innerId = React.useId();
521
- const id = React.useMemo(() => idProp || innerId, [idProp, innerId]);
522
- const handleOnChange = React.useCallback((event) => {
523
- onChange === null || onChange === void 0 ? void 0 : onChange(event.currentTarget.value);
524
- }, [onChange]);
525
- const handleOnIconStartClick = React.useCallback(() => {
526
- onIconStartClick === null || onIconStartClick === void 0 ? void 0 : onIconStartClick(value);
527
- }, [onIconStartClick, value]);
528
- const handleOnIconEndClick = React.useCallback(() => {
529
- onIconEndClick === null || onIconEndClick === void 0 ? void 0 : onIconEndClick(value);
530
- }, [onIconEndClick, value]);
531
- const ariaDescribedby = React.useMemo(() => ([
532
- !!inputStart && `${id}InputStart`,
533
- !!iconStart && `${id}Start`,
534
- (invalid || valid) && !iconEnd && !loading && `${id}State`,
535
- (iconEnd && !loading) && `${id}End`,
536
- loading && `${id}Loading`,
537
- !!inputEnd && `${id}InputEnd`,
538
- !!hint && `${id}Hint`,
539
- ]
540
- .filter(Boolean)
541
- .join(' ')), [
542
- id,
543
- inputStart,
544
- iconStart,
545
- invalid,
546
- valid,
547
- iconEnd,
548
- loading,
549
- inputEnd,
550
- hint,
551
- ]);
552
- const inputComponent = React.useMemo(() => (jsxRuntime.jsx("input", Object.assign({ ref: inputRef, id: id, className: classNames('form-control', {
553
- [`form-control-${size}`]: !!size,
554
- 'is-invalid': invalid,
555
- 'is-valid': valid,
556
- }), disabled: disabled || loading, value: value, onChange: handleOnChange }, (floatingLabel || placeholder) && { placeholder: floatingLabel ? '' : placeholder }, ariaDescribedby && { 'aria-describedby': ariaDescribedby }, inputProps))), [
557
- ariaDescribedby,
558
- disabled,
559
- handleOnChange,
560
- id,
561
- inputProps,
562
- inputRef,
563
- invalid,
564
- loading,
565
- placeholder,
566
- floatingLabel,
567
- valid,
568
- value,
569
- size,
570
- ]);
571
- const labelComponent = React.useMemo(() => (jsxRuntime.jsxs("label", { htmlFor: id, children: [label, labelIcon && (jsxRuntime.jsx(DIcon, { icon: labelIcon, size: `var(--${PREFIX_BS}label-font-size)`, familyClass: labelIconFamilyClass, familyPrefix: labelIconFamilyPrefix, materialStyle: labelIconMaterialStyle }))] })), [
572
- id,
573
- label,
574
- labelIcon,
575
- labelIconFamilyClass,
576
- labelIconFamilyPrefix,
577
- labelIconMaterialStyle,
578
- ]);
579
- const dynamicComponent = React.useMemo(() => {
580
- if (floatingLabel) {
581
- return (jsxRuntime.jsxs("div", { className: "form-floating", children: [inputComponent, labelComponent] }));
582
- }
583
- return inputComponent;
584
- }, [floatingLabel, inputComponent, labelComponent]);
585
- return (jsxRuntime.jsxs("div", Object.assign({ className: className, style: style }, dataAttributes, { children: [label && !floatingLabel && labelComponent, jsxRuntime.jsxs("div", { className: classNames({
586
- 'input-group': true,
587
- 'has-validation': invalid || valid,
588
- }), children: [!!inputStart && (jsxRuntime.jsx("div", { className: "input-group-text", id: `${id}InputStart`, children: inputStart })), iconStart && (jsxRuntime.jsx("button", { type: "button", className: "input-group-text", id: `${id}Start`, onClick: handleOnIconStartClick, disabled: disabled || loading || iconStartDisabled, "aria-label": iconStartAriaLabel, tabIndex: onIconStartClick ? iconStartTabIndex : -1, children: jsxRuntime.jsx(DIcon, { icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix, materialStyle: iconStartMaterialStyle }) })), dynamicComponent, (iconEnd && !loading) && (jsxRuntime.jsx("button", { type: "button", className: "input-group-text", id: `${id}End`, onClick: handleOnIconEndClick, disabled: disabled || loading || iconEndDisabled, "aria-label": iconEndAriaLabel, tabIndex: onIconEndClick ? iconEndTabIndex : -1, children: jsxRuntime.jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix, materialStyle: iconEndMaterialStyle }) })), loading && (jsxRuntime.jsx("div", { className: "input-group-text", id: `${id}Loading`, children: jsxRuntime.jsx("span", { className: "spinner-border spinner-border-sm", role: "status", "aria-hidden": "true", children: jsxRuntime.jsx("span", { className: "visually-hidden", children: "Loading..." }) }) })), !!inputEnd && (jsxRuntime.jsx("div", { className: "input-group-text", id: `${id}InputEnd`, children: inputEnd }))] }), hint && (jsxRuntime.jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] })));
589
- }
590
- const ForwardedDInput = React.forwardRef(DInput);
591
- ForwardedDInput.displayName = 'DInput';
592
-
593
1000
  function DDatePickerTime(_a) {
594
1001
  var { value, onChange, id, label, className, style } = _a, props = tslib.__rest(_a, ["value", "onChange", "id", "label", "className", "style"]);
595
1002
  return (jsxRuntime.jsxs("div", { className: classNames('d-flex align-items-center gap-2 flex-column d-datepicker-time', className), style: style, children: [label && (jsxRuntime.jsx("label", { htmlFor: id, className: "d-datepicker-time-label", children: label })), jsxRuntime.jsx(ForwardedDInput, Object.assign({ className: "w-100" }, onChange && {
@@ -599,7 +1006,8 @@ function DDatePickerTime(_a) {
599
1006
 
600
1007
  function DDatePickerInput(_a, ref) {
601
1008
  var { value, onClick, id, iconEnd, className, style, inputLabel, readOnly: ignored } = _a, props = tslib.__rest(_a, ["value", "onClick", "id", "iconEnd", "className", "style", "inputLabel", "readOnly"]);
602
- return (jsxRuntime.jsx(ForwardedDInput, Object.assign({ ref: ref, onClick: onClick, readOnly: true, type: "text", id: id, value: value, onIconEndClick: onClick, iconEnd: iconEnd, className: className, style: style, label: inputLabel }, props)));
1009
+ const { iconMap: { calendar } } = useDContext();
1010
+ return (jsxRuntime.jsx(ForwardedDInput, Object.assign({ ref: ref, onClick: onClick, readOnly: true, type: "text", id: id, value: value, onIconEndClick: onClick, iconEnd: iconEnd || calendar, className: className, style: style, label: inputLabel }, props)));
603
1011
  }
604
1012
  const ForwardedDDatePickerInput = React.forwardRef(DDatePickerInput);
605
1013
  ForwardedDDatePickerInput.displayName = 'DDatePickerInput';
@@ -683,8 +1091,8 @@ function DSelectDropdownIndicator(props) {
683
1091
  }
684
1092
 
685
1093
  function DSelectClearIndicator(props) {
686
- const { iconMap: { xLg, }, } = useDContext();
687
- return (jsxRuntime.jsx(Select.components.ClearIndicator, Object.assign({}, props, { children: jsxRuntime.jsx(DIcon, { icon: xLg }) })));
1094
+ const { iconMap: { x, }, } = useDContext();
1095
+ return (jsxRuntime.jsx(Select.components.ClearIndicator, Object.assign({}, props, { children: jsxRuntime.jsx(DIcon, { icon: x }) })));
688
1096
  }
689
1097
 
690
1098
  function DSelectMultiValueRemove(props) {
@@ -768,43 +1176,65 @@ var DSelect$1 = Object.assign(DSelect, {
768
1176
  Placeholder: DSelectPlaceholder,
769
1177
  });
770
1178
 
771
- function DDatePickerHeader({ date, changeYear, changeMonth, decreaseMonth, increaseMonth, prevMonthButtonDisabled, nextMonthButtonDisabled, iconPrevMonth, iconNextMonth, iconFamilyClass, iconFamilyPrefix, iconMaterialStyle, prevMonthAriaLabel = 'decrease month', nextMonthAriaLabel = 'increase month', iconSize, buttonVariant, buttonTheme, locale, style, className, minYearSelect, maxYearSelect, }) {
1179
+ var PickerType;
1180
+ (function (PickerType) {
1181
+ PickerType["Default"] = "default";
1182
+ PickerType["Quarter"] = "quarter";
1183
+ PickerType["Month"] = "month";
1184
+ PickerType["Year"] = "year";
1185
+ })(PickerType || (PickerType = {}));
1186
+ function DDatePickerHeaderSelector({ date, changeYear, changeMonth, decreaseMonth, increaseMonth, decreaseYear, increaseYear, monthDate, pickerType, prevMonthButtonDisabled, nextMonthButtonDisabled, monthsShown = 1, iconPrev, iconNext, prevYearButtonDisabled, nextYearButtonDisabled, iconFamilyClass, iconFamilyPrefix, iconMaterialStyle = false, prevMonthAriaLabel = 'decrease month', nextMonthAriaLabel = 'increase month', prevYearAriaLabel = 'decrease year', nextYearAriaLabel = 'increase year', iconSize = 'sm', buttonVariant = 'link', buttonTheme = 'dark', style, className, minYearSelect = 1900, maxYearSelect = 2100, showHeaderSelectors = false, customHeaderCount, }) {
1187
+ const { iconMap: { chevronLeft, chevronRight, }, } = useDContext();
772
1188
  const arrayYears = React.useMemo(() => Array.from({ length: maxYearSelect - minYearSelect + 1 }, (_, index) => minYearSelect + index), [maxYearSelect, minYearSelect]);
773
1189
  const years = React.useMemo(() => arrayYears.map((year) => ({
774
1190
  label: year.toString(),
775
1191
  value: year,
776
1192
  })), [arrayYears]);
777
- const defaultYear = React.useMemo(() => years.find((year) => year.value === dateFns.getYear(date)), [date, years]);
778
- const arrayMonths = React.useMemo(() => Array.from({ length: 12 }, (_, i) => dateFns.format(new Date(2000, i), 'LLLL', { locale })), [locale]);
1193
+ const defaultYear = React.useMemo(() => years.find((year) => year.value === dateFns.getYear(monthDate)), [monthDate, years]);
1194
+ const arrayMonths = React.useMemo(() => Array.from({ length: 12 }, (_, i) => dateFns.format(new Date(2000, i), 'LLLL', { locale: locale.enUS })), []);
779
1195
  const months = React.useMemo(() => arrayMonths.map((month, i) => ({
780
1196
  label: month,
781
1197
  value: i,
782
1198
  })), [arrayMonths]);
783
1199
  const defaultMonth = React.useMemo(() => ({
784
- label: arrayMonths[dateFns.getMonth(date)],
785
- value: dateFns.getMonth(date),
786
- }), [arrayMonths, date]);
787
- return (jsxRuntime.jsxs("div", { className: classNames('d-flex align-items-center d-datepicker-header', className), style: style, children: [jsxRuntime.jsx(DButton, { iconStart: iconPrevMonth, iconStartFamilyClass: iconFamilyClass, iconStartFamilyPrefix: iconFamilyPrefix, iconStartMaterialStyle: iconMaterialStyle, size: iconSize, variant: buttonVariant, theme: buttonTheme, onClick: decreaseMonth, disabled: prevMonthButtonDisabled, ariaLabel: prevMonthAriaLabel, className: "header-button" }), jsxRuntime.jsxs("div", { className: "d-flex justify-content-center flex-grow-1", children: [jsxRuntime.jsx(DSelect$1, { options: months, value: defaultMonth, defaultValue: defaultMonth, onChange: (month) => changeMonth((month === null || month === void 0 ? void 0 : month.value) || 0), searchable: false }), jsxRuntime.jsx(DSelect$1, { options: years, value: defaultYear, defaultValue: defaultYear, onChange: (year) => changeYear(Number(year === null || year === void 0 ? void 0 : year.value)), searchable: false })] }), jsxRuntime.jsx(DButton, { iconStart: iconNextMonth, iconStartFamilyClass: iconFamilyClass, iconStartFamilyPrefix: iconFamilyPrefix, iconStartMaterialStyle: iconMaterialStyle, size: iconSize, variant: buttonVariant, theme: buttonTheme, onClick: increaseMonth, disabled: nextMonthButtonDisabled, ariaLabel: nextMonthAriaLabel, className: "header-button" })] }));
1200
+ label: arrayMonths[dateFns.getMonth(monthDate)],
1201
+ value: dateFns.getMonth(monthDate),
1202
+ }), [arrayMonths, monthDate]);
1203
+ const getYearRange = React.useCallback(() => {
1204
+ const blockIndex = Math.floor((date.getFullYear() - 1) / 12);
1205
+ const startYear = blockIndex * 12 + 1;
1206
+ const endYear = startYear + 11;
1207
+ return [startYear, endYear];
1208
+ }, [date]);
1209
+ const [startYear, endYear] = getYearRange();
1210
+ if (pickerType === PickerType.Year) {
1211
+ return (jsxRuntime.jsxs("div", { className: classNames('react-datepicker__header-selector react-datepicker__header-year-selector', className), style: style, children: [jsxRuntime.jsx(DButton, { iconStart: iconPrev || chevronLeft, iconStartFamilyClass: iconFamilyClass, iconStartFamilyPrefix: iconFamilyPrefix, iconStartMaterialStyle: iconMaterialStyle, size: iconSize, variant: buttonVariant, theme: buttonTheme, onClick: decreaseYear, disabled: prevYearButtonDisabled, ariaLabel: prevYearAriaLabel, className: "header-button" }), jsxRuntime.jsx("p", { children: `${startYear} - ${endYear}` }), jsxRuntime.jsx(DButton, { iconStart: iconNext || chevronRight, iconStartFamilyClass: iconFamilyClass, iconStartFamilyPrefix: iconFamilyPrefix, iconStartMaterialStyle: iconMaterialStyle, size: iconSize, variant: buttonVariant, theme: buttonTheme, onClick: increaseYear, disabled: nextYearButtonDisabled, ariaLabel: nextYearAriaLabel, className: "header-button" })] }));
1212
+ }
1213
+ if (pickerType === PickerType.Quarter || pickerType === PickerType.Month) {
1214
+ return (jsxRuntime.jsxs("div", { className: classNames(`react-datepicker__header-selector react-datepicker__header-${pickerType}-selector`, className), style: style, children: [jsxRuntime.jsx(DButton, { iconStart: iconPrev || chevronLeft, iconStartFamilyClass: iconFamilyClass, iconStartFamilyPrefix: iconFamilyPrefix, iconStartMaterialStyle: iconMaterialStyle, size: iconSize, variant: buttonVariant, theme: buttonTheme, onClick: decreaseYear, disabled: prevMonthButtonDisabled, ariaLabel: prevMonthAriaLabel, className: "header-button", style: { visibility: customHeaderCount === 0 ? 'visible' : 'hidden' } }), jsxRuntime.jsx("div", { className: "d-flex justify-content-center flex-grow-1", children: showHeaderSelectors ? (jsxRuntime.jsx(DSelect$1, { options: years, value: defaultYear, defaultValue: defaultYear, onChange: (year) => changeYear(Number(year === null || year === void 0 ? void 0 : year.value)), searchable: false })) : (jsxRuntime.jsx("p", { children: defaultYear === null || defaultYear === void 0 ? void 0 : defaultYear.label })) }), jsxRuntime.jsx(DButton, { iconStart: iconNext || chevronRight, iconStartFamilyClass: iconFamilyClass, iconStartFamilyPrefix: iconFamilyPrefix, iconStartMaterialStyle: iconMaterialStyle, size: iconSize, variant: buttonVariant, theme: buttonTheme, onClick: increaseYear, disabled: nextMonthButtonDisabled, ariaLabel: nextMonthAriaLabel, className: "header-button", style: { visibility: customHeaderCount === monthsShown - 1 ? 'visible' : 'hidden' } })] }));
1215
+ }
1216
+ return (jsxRuntime.jsxs("div", { className: classNames('react-datepicker__header-selector react-datepicker__header-day-selector', className), style: style, children: [jsxRuntime.jsx(DButton, { iconStart: iconPrev || chevronLeft, iconStartFamilyClass: iconFamilyClass, iconStartFamilyPrefix: iconFamilyPrefix, iconStartMaterialStyle: iconMaterialStyle, size: iconSize, variant: buttonVariant, theme: buttonTheme, onClick: decreaseMonth, disabled: prevMonthButtonDisabled, ariaLabel: prevMonthAriaLabel, className: "header-button", style: { visibility: customHeaderCount === 0 ? 'visible' : 'hidden' } }), showHeaderSelectors ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(DSelect$1, { options: months, value: defaultMonth, defaultValue: defaultMonth, onChange: (month) => changeMonth((month === null || month === void 0 ? void 0 : month.value) || 0), searchable: false, className: "custom-month-selector" }), jsxRuntime.jsx(DSelect$1, { options: years, value: defaultYear, defaultValue: defaultYear, onChange: (year) => changeYear(Number(year === null || year === void 0 ? void 0 : year.value)), searchable: false, className: "custom-year-selector" })] })) : (jsxRuntime.jsx("p", { children: `${defaultMonth.label} ${defaultYear === null || defaultYear === void 0 ? void 0 : defaultYear.label}` })), jsxRuntime.jsx(DButton, { iconStart: iconNext || chevronRight, iconStartFamilyClass: iconFamilyClass, iconStartFamilyPrefix: iconFamilyPrefix, iconStartMaterialStyle: iconMaterialStyle, size: iconSize, variant: buttonVariant, theme: buttonTheme, onClick: increaseMonth, disabled: nextMonthButtonDisabled, ariaLabel: nextMonthAriaLabel, className: "header-button", style: { visibility: customHeaderCount === monthsShown - 1 ? 'visible' : 'hidden' } })] }));
788
1217
  }
789
1218
 
790
- /**
791
- * @deprecated
792
- */
793
1219
  function DDatePicker(_a) {
794
- var { date, selectsRange = false, inputLabel, inputHint, inputAriaLabel, inputActionAriaLabel = 'open calendar', inputId = 'input-calendar', timeId = 'input-time', timeLabel, iconInput: iconInputProp, iconHeaderPrevMonth: iconHeaderPrevMonthProp, iconHeaderNextMonth: iconHeaderNextMonthProp, iconMaterialStyle: iconMaterialStyleProp, iconFamilyClass, iconFamilyPrefix, minYearSelect = 1900, maxYearSelect = 2100, iconHeaderSize = 'sm', headerPrevMonthAriaLabel = 'decrease month', headerNextMonthAriaLabel = 'increase month', headerButtonVariant = 'link', headerButtonTheme = 'dark', invalid = false, valid = false, renderCustomHeader: renderCustomHeaderProp, locale, className, formatWeekDay: formatWeekDayProp, style, dataAttributes, placeholder } = _a, props = tslib.__rest(_a, ["date", "selectsRange", "inputLabel", "inputHint", "inputAriaLabel", "inputActionAriaLabel", "inputId", "timeId", "timeLabel", "iconInput", "iconHeaderPrevMonth", "iconHeaderNextMonth", "iconMaterialStyle", "iconFamilyClass", "iconFamilyPrefix", "minYearSelect", "maxYearSelect", "iconHeaderSize", "headerPrevMonthAriaLabel", "headerNextMonthAriaLabel", "headerButtonVariant", "headerButtonTheme", "invalid", "valid", "renderCustomHeader", "locale", "className", "formatWeekDay", "style", "dataAttributes", "placeholder"]);
795
- const { iconMap: { calendar, chevronLeft, chevronRight, }, } = useDContext();
796
- const selected = React.useMemo(() => (date ? dateFns.parseISO(date) : null), [date]);
797
- const iconInput = React.useMemo(() => iconInputProp || calendar, [calendar, iconInputProp]);
798
- const handleFormatWeekDay = React.useMemo(() => (formatWeekDayProp
799
- ? (day) => formatWeekDayProp(day)
800
- : (day) => day.substring(0, 1)), [formatWeekDayProp]);
801
- const iconPrevMonth = React.useMemo(() => iconHeaderPrevMonthProp || chevronLeft, [chevronLeft, iconHeaderPrevMonthProp]);
802
- const iconNextMonth = React.useMemo(() => iconHeaderNextMonthProp || chevronRight, [chevronRight, iconHeaderNextMonthProp]);
803
- const DatePickerHeader = React.useCallback((headerProps) => (jsxRuntime.jsx(DDatePickerHeader, Object.assign({}, headerProps, locale && { locale }, { iconPrevMonth: iconPrevMonth, iconNextMonth: iconNextMonth, iconMaterialStyle: iconMaterialStyleProp, prevMonthAriaLabel: headerPrevMonthAriaLabel, nextMonthAriaLabel: headerNextMonthAriaLabel, iconSize: iconHeaderSize, buttonVariant: headerButtonVariant, buttonTheme: headerButtonTheme, minYearSelect: minYearSelect, maxYearSelect: maxYearSelect }))), [
804
- locale,
805
- iconPrevMonth,
806
- iconNextMonth,
807
- iconMaterialStyleProp,
1220
+ var { inputLabel, inputHint, inputAriaLabel, inputActionAriaLabel = 'open calendar', inputId = 'input-calendar', timeId = 'input-time', timeLabel, iconInput, iconHeaderPrev, iconHeaderNext, iconMaterialStyle, iconFamilyClass, iconFamilyPrefix, minYearSelect, maxYearSelect, iconHeaderSize, headerPrevMonthAriaLabel, headerNextMonthAriaLabel, headerButtonVariant, headerButtonTheme, invalid = false, valid = false, renderCustomHeader: renderCustomHeaderProp, className, dateFormatCalendar: dateFormatCalendarProp, style, dataAttributes, placeholder, showHeaderSelectors } = _a, props = tslib.__rest(_a, ["inputLabel", "inputHint", "inputAriaLabel", "inputActionAriaLabel", "inputId", "timeId", "timeLabel", "iconInput", "iconHeaderPrev", "iconHeaderNext", "iconMaterialStyle", "iconFamilyClass", "iconFamilyPrefix", "minYearSelect", "maxYearSelect", "iconHeaderSize", "headerPrevMonthAriaLabel", "headerNextMonthAriaLabel", "headerButtonVariant", "headerButtonTheme", "invalid", "valid", "renderCustomHeader", "className", "dateFormatCalendar", "style", "dataAttributes", "placeholder", "showHeaderSelectors"]);
1221
+ const pickerType = React.useMemo(() => {
1222
+ if (props.showQuarterYearPicker)
1223
+ return PickerType.Quarter;
1224
+ if (props.showMonthYearPicker)
1225
+ return PickerType.Month;
1226
+ if (props.showYearPicker)
1227
+ return PickerType.Year;
1228
+ return PickerType.Default;
1229
+ }, [
1230
+ props.showQuarterYearPicker,
1231
+ props.showMonthYearPicker,
1232
+ props.showYearPicker,
1233
+ ]);
1234
+ const DatePickerHeader = React.useCallback((headerProps) => (jsxRuntime.jsx(DDatePickerHeaderSelector, Object.assign({}, headerProps, { monthsShown: props.monthsShown, iconPrev: iconHeaderPrev, iconNext: iconHeaderNext, iconMaterialStyle: iconMaterialStyle, prevMonthAriaLabel: headerPrevMonthAriaLabel, nextMonthAriaLabel: headerNextMonthAriaLabel, iconSize: iconHeaderSize, buttonVariant: headerButtonVariant, buttonTheme: headerButtonTheme, minYearSelect: minYearSelect, maxYearSelect: maxYearSelect, pickerType: pickerType, showHeaderSelectors: showHeaderSelectors }))), [
1235
+ iconHeaderNext,
1236
+ iconHeaderPrev,
1237
+ iconMaterialStyle,
808
1238
  headerPrevMonthAriaLabel,
809
1239
  headerNextMonthAriaLabel,
810
1240
  iconHeaderSize,
@@ -812,10 +1242,13 @@ function DDatePicker(_a) {
812
1242
  headerButtonTheme,
813
1243
  minYearSelect,
814
1244
  maxYearSelect,
1245
+ pickerType,
1246
+ showHeaderSelectors,
1247
+ props.monthsShown,
815
1248
  ]);
816
1249
  const defaultRenderCustomHeader = React.useCallback((headerProps) => (jsxRuntime.jsx(DatePickerHeader, Object.assign({}, headerProps))), [DatePickerHeader]);
817
1250
  const renderCustomHeader = React.useMemo(() => (renderCustomHeaderProp || defaultRenderCustomHeader), [defaultRenderCustomHeader, renderCustomHeaderProp]);
818
- return (jsxRuntime.jsx(DatePicker, Object.assign({ selected: selected, calendarClassName: "d-date-picker", renderCustomHeader: renderCustomHeader, selectsRange: selectsRange, formatWeekDay: handleFormatWeekDay, customInput: (jsxRuntime.jsx(ForwardedDDatePickerInput, { id: inputId, "aria-label": inputAriaLabel, iconEndAriaLabel: inputActionAriaLabel, iconMaterialStyle: iconMaterialStyleProp, iconEnd: iconInput, inputLabel: inputLabel, className: className, style: style, invalid: invalid, valid: valid, hint: inputHint })), customTimeInput: (jsxRuntime.jsx(DDatePickerTime, { id: timeId, label: timeLabel })), placeholderText: placeholder }, locale && { locale }, dataAttributes, props)));
1251
+ return (jsxRuntime.jsx(DatePicker, Object.assign({ calendarClassName: "d-date-picker", renderCustomHeader: renderCustomHeader, customInput: (jsxRuntime.jsx(ForwardedDDatePickerInput, { id: inputId, "aria-label": inputAriaLabel, iconEndAriaLabel: inputActionAriaLabel, iconMaterialStyle: iconMaterialStyle, iconEnd: iconInput, inputLabel: inputLabel, className: className, style: style, invalid: invalid, valid: valid, hint: inputHint })), customTimeInput: (jsxRuntime.jsx(DDatePickerTime, { id: timeId, label: timeLabel })), placeholderText: placeholder }, dataAttributes, props)));
819
1252
  }
820
1253
 
821
1254
  function DInputMask(props, ref) {
@@ -1324,7 +1757,7 @@ function DListGroupItem({ as = 'li', action: actionProp, active, disabled, href,
1324
1757
  }
1325
1758
  return Object.assign(Object.assign({}, active && { 'aria-current': true }), disabled && { 'aria-disabled': true });
1326
1759
  }, [Tag, active, disabled]);
1327
- return (jsxRuntime.jsx(Tag, Object.assign({ className: classNames(generateClasses, className), style: style }, Tag === 'a' && href && { href }, onClick && { onClick }, ariaAttributes, dataAttributes, { children: children })));
1760
+ return (jsxRuntime.jsx(Tag, Object.assign({ className: classNames(generateClasses, className), style: style }, Tag === 'a' && href && { href }, onClick && { onClick }, ariaAttributes, dataAttributes, Tag === 'button' && { type: 'button' }, { children: children })));
1328
1761
  }
1329
1762
 
1330
1763
  function DListGroup({ as = 'ul', numbered, flush, horizontal, children, className, style, dataAttributes, }) {
@@ -1434,9 +1867,6 @@ function DPaginator(_a) {
1434
1867
  return (jsxRuntime.jsx(ResponsivePagination, Object.assign({ navClassName: classNames('page-item-arrow', navClassName) }, backwardCompatibilityProps)));
1435
1868
  }
1436
1869
 
1437
- /**
1438
- * @deprecated
1439
- */
1440
1870
  function DPopover({ children, renderComponent, open, setOpen, adjustContentToRender = false, className, style, dataAttributes, }) {
1441
1871
  const [isOpen, setIsOpen] = React.useState(false);
1442
1872
  React.useEffect(() => {