@dnb/eufemia 9.47.0 → 9.47.2

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 (92) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/cjs/components/accordion/AccordionProvider.js +1 -3
  3. package/cjs/components/autocomplete/Autocomplete.js +4 -1
  4. package/cjs/components/button/Button.d.ts +6 -1
  5. package/cjs/components/button/Button.js +3 -3
  6. package/cjs/components/dropdown/Dropdown.d.ts +2 -2
  7. package/cjs/components/help-button/HelpButtonInstance.js +1 -3
  8. package/cjs/components/icon/Icon.js +1 -3
  9. package/cjs/components/icon-primary/IconPrimary.js +1 -3
  10. package/cjs/components/input-masked/InputMasked.js +13 -1
  11. package/cjs/components/input-masked/InputMaskedHooks.js +1 -1
  12. package/cjs/components/input-masked/InputMaskedUtils.js +3 -3
  13. package/cjs/components/logo/Logo.js +1 -3
  14. package/cjs/components/modal/Modal.js +1 -3
  15. package/cjs/components/pagination/Pagination.js +1 -3
  16. package/cjs/components/progress-indicator/ProgressIndicator.js +1 -3
  17. package/cjs/components/step-indicator/StepIndicatorContext.js +1 -3
  18. package/cjs/components/upload/Upload.js +0 -1
  19. package/cjs/components/upload/UploadFileInput.js +2 -10
  20. package/cjs/components/upload/UploadFileList.js +0 -1
  21. package/cjs/components/upload/UploadFileListCell.js +22 -23
  22. package/cjs/components/upload/UploadInfo.js +1 -9
  23. package/cjs/components/upload/UploadVerify.d.ts +3 -0
  24. package/cjs/components/upload/UploadVerify.js +27 -3
  25. package/cjs/elements/Element.js +1 -3
  26. package/cjs/fragments/drawer-list/DrawerList.js +1 -3
  27. package/cjs/shared/Eufemia.js +1 -1
  28. package/components/accordion/AccordionProvider.js +1 -2
  29. package/components/autocomplete/Autocomplete.js +4 -1
  30. package/components/button/Button.d.ts +6 -1
  31. package/components/button/Button.js +3 -2
  32. package/components/dropdown/Dropdown.d.ts +2 -2
  33. package/components/help-button/HelpButtonInstance.js +1 -2
  34. package/components/icon/Icon.js +1 -2
  35. package/components/icon-primary/IconPrimary.js +1 -2
  36. package/components/input-masked/InputMasked.js +13 -1
  37. package/components/input-masked/InputMaskedHooks.js +1 -1
  38. package/components/input-masked/InputMaskedUtils.js +3 -3
  39. package/components/logo/Logo.js +1 -2
  40. package/components/modal/Modal.js +1 -2
  41. package/components/pagination/Pagination.js +1 -2
  42. package/components/progress-indicator/ProgressIndicator.js +1 -2
  43. package/components/step-indicator/StepIndicatorContext.js +1 -2
  44. package/components/upload/Upload.js +0 -1
  45. package/components/upload/UploadFileInput.js +3 -10
  46. package/components/upload/UploadFileList.js +0 -1
  47. package/components/upload/UploadFileListCell.js +17 -19
  48. package/components/upload/UploadInfo.js +1 -9
  49. package/components/upload/UploadVerify.d.ts +3 -0
  50. package/components/upload/UploadVerify.js +18 -1
  51. package/elements/Element.js +1 -2
  52. package/es/components/accordion/AccordionProvider.js +1 -2
  53. package/es/components/autocomplete/Autocomplete.js +4 -1
  54. package/es/components/button/Button.d.ts +6 -1
  55. package/es/components/button/Button.js +3 -2
  56. package/es/components/dropdown/Dropdown.d.ts +2 -2
  57. package/es/components/help-button/HelpButtonInstance.js +1 -2
  58. package/es/components/icon/Icon.js +1 -2
  59. package/es/components/icon-primary/IconPrimary.js +1 -2
  60. package/es/components/input-masked/InputMasked.js +12 -1
  61. package/es/components/input-masked/InputMaskedHooks.js +1 -1
  62. package/es/components/input-masked/InputMaskedUtils.js +3 -3
  63. package/es/components/logo/Logo.js +1 -2
  64. package/es/components/modal/Modal.js +1 -2
  65. package/es/components/pagination/Pagination.js +1 -2
  66. package/es/components/progress-indicator/ProgressIndicator.js +1 -2
  67. package/es/components/step-indicator/StepIndicatorContext.js +1 -2
  68. package/es/components/upload/Upload.js +0 -1
  69. package/es/components/upload/UploadFileInput.js +3 -7
  70. package/es/components/upload/UploadFileList.js +0 -1
  71. package/es/components/upload/UploadFileListCell.js +14 -18
  72. package/es/components/upload/UploadInfo.js +1 -9
  73. package/es/components/upload/UploadVerify.d.ts +3 -0
  74. package/es/components/upload/UploadVerify.js +11 -1
  75. package/es/elements/Element.js +1 -2
  76. package/es/fragments/drawer-list/DrawerList.js +1 -2
  77. package/es/shared/Eufemia.js +1 -1
  78. package/esm/dnb-ui-basis.min.mjs +1 -1
  79. package/esm/dnb-ui-components.min.mjs +1 -1
  80. package/esm/dnb-ui-elements.min.mjs +2 -2
  81. package/esm/dnb-ui-extensions.min.mjs +1 -1
  82. package/esm/dnb-ui-lib.min.mjs +2 -2
  83. package/esm/dnb-ui-web-components.min.mjs +2 -2
  84. package/fragments/drawer-list/DrawerList.js +1 -2
  85. package/package.json +1 -1
  86. package/shared/Eufemia.js +1 -1
  87. package/umd/dnb-ui-basis.min.js +1 -1
  88. package/umd/dnb-ui-components.min.js +1 -1
  89. package/umd/dnb-ui-elements.min.js +2 -2
  90. package/umd/dnb-ui-extensions.min.js +1 -1
  91. package/umd/dnb-ui-lib.min.js +2 -2
  92. package/umd/dnb-ui-web-components.min.js +2 -2
@@ -13,7 +13,6 @@ import classnames from 'classnames';
13
13
  import { isTrue, makeUniqueId, extendPropsWithContextInClassComponent, registerElement, validateDOMAttributes, dispatchCustomElementEvent } from '../../shared/component-helper';
14
14
  import { createSpacingClasses } from '../space/SpacingHelper';
15
15
  import { accordionPropTypes, accordionDefaultProps } from './AccordionPropTypes';
16
- import { includeValidProps } from '../form-row/FormRowHelpers';
17
16
  import Context from '../../shared/Context';
18
17
  import AccordionGroupContext from './AccordionProviderContext';
19
18
  export default class AccordionGroup extends React.PureComponent {
@@ -39,7 +38,7 @@ export default class AccordionGroup extends React.PureComponent {
39
38
  }
40
39
 
41
40
  render() {
42
- const props = extendPropsWithContextInClassComponent(this.props, AccordionGroup.defaultProps, includeValidProps(this.context.FormRow), this.context.Accordion, this.context.getTranslation(this.props).Accordion);
41
+ const props = extendPropsWithContextInClassComponent(this.props, AccordionGroup.defaultProps, this.context.Accordion, this.context.getTranslation(this.props).Accordion);
43
42
 
44
43
  const {
45
44
  expanded,
@@ -1524,7 +1524,10 @@ class AutocompleteInstance extends React.PureComponent {
1524
1524
  icon_size: icon_size || (size === 'large' ? 'medium' : 'default'),
1525
1525
  variant: "secondary",
1526
1526
  size: size === 'default' ? 'medium' : size,
1527
- type: "button"
1527
+ type: "button",
1528
+ status: status,
1529
+ status_state: status_state,
1530
+ status_props: status_props
1528
1531
  }, triggerParams));
1529
1532
  }
1530
1533
 
@@ -150,10 +150,15 @@ export type ButtonProps = {
150
150
  href?: string;
151
151
 
152
152
  /**
153
- * When button behaves as a link. Used to specifiy where to open the linked document, specified by `href`. Possible values are `_self`, `_blank`, `_parent` and `_top`.
153
+ * When button behaves as a link. Used to specify where to open the linked document, specified by `href`. Possible values are `_self`, `_blank`, `_parent` and `_top`.
154
154
  */
155
155
  target?: string;
156
156
 
157
+ /**
158
+ * When button behaves as a link. Used to specify the relationship between a linked resource and the current document. Examples(non-exhaustive list) of values are `nofollow`, `search`, and `tag`.
159
+ */
160
+ rel?: string;
161
+
157
162
  /**
158
163
  * Use this prop only if you are using a router Link component as the `element` that uses the `to` property to declare the navigation url.
159
164
  */
@@ -17,7 +17,6 @@ import Context from '../../shared/Context';
17
17
  import { warn, makeUniqueId, isTrue, extendPropsWithContextInClassComponent, registerElement, validateDOMAttributes, processChildren, getStatusState, dispatchCustomElementEvent } from '../../shared/component-helper';
18
18
  import { spacingPropTypes, createSpacingClasses } from '../space/SpacingHelper';
19
19
  import { skeletonDOMAttributes, createSkeletonClass } from '../skeleton/SkeletonHelper';
20
- import { includeValidProps } from '../form-row/FormRowHelpers';
21
20
  import IconPrimary from '../icon-primary/IconPrimary';
22
21
  import { launch, launch_medium } from '../../icons';
23
22
  import FormStatus from '../form-status/FormStatus';
@@ -72,7 +71,7 @@ export default class Button extends React.PureComponent {
72
71
 
73
72
  const props = extendPropsWithContextInClassComponent(this.props, Button.defaultProps, {
74
73
  skeleton: (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.skeleton
75
- }, includeValidProps(this.context.FormRow), this.context.Button);
74
+ }, this.context.Button);
76
75
 
77
76
  const {
78
77
  class: class_name,
@@ -226,6 +225,7 @@ process.env.NODE_ENV !== "production" ? Button.propTypes = _objectSpread(_object
226
225
  class: PropTypes.string,
227
226
  href: PropTypes.string,
228
227
  target: PropTypes.string,
228
+ rel: PropTypes.string,
229
229
  to: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func]),
230
230
  custom_content: PropTypes.node,
231
231
  wrap: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
@@ -254,6 +254,7 @@ Button.defaultProps = {
254
254
  icon_size: null,
255
255
  href: null,
256
256
  target: null,
257
+ rel: null,
257
258
  to: null,
258
259
  id: null,
259
260
  class: null,
@@ -433,12 +433,12 @@ export interface DropdownProps extends React.HTMLProps<HTMLElement> {
433
433
  on_hide?: (...args: any[]) => any;
434
434
 
435
435
  /**
436
- * Will be called on state changes made by the user. Returns an object with the new selected `data` item `{ data, event, attributes, selected_key, value }`.
436
+ * Will be called on state changes made by the user. Returns an object with the new selected `data` item `{ data, event, attributes, value }`.
437
437
  */
438
438
  on_change?: (...args: any[]) => any;
439
439
 
440
440
  /**
441
- * Will be called once the user selects an item by a click or keyboard navigation. Returns an object with the new selected `data` item `{ data, event, attributes, selected_key, value, active_item }`. The "active_item" property is the currently selected item by keyboard navigation
441
+ * Will be called once the user selects an item by a click or keyboard navigation. Returns an object with the new selected `data` item `{ data, event, attributes, value, active_item }`. The "active_item" property is the currently selected item by keyboard navigation
442
442
  */
443
443
  on_select?: (...args: any[]) => any;
444
444
  on_state_update?: (...args: any[]) => any;
@@ -11,7 +11,6 @@ import React from 'react';
11
11
  import classnames from 'classnames';
12
12
  import { convertJsxToString, extendPropsWithContext } from '../../shared/component-helper';
13
13
  import Context from '../../shared/Context';
14
- import { includeValidProps } from '../form-row/FormRowHelpers';
15
14
  import { createSpacingClasses } from '../space/SpacingHelper';
16
15
  import Button from '../button/Button';
17
16
  const defaultProps = {
@@ -20,7 +19,7 @@ const defaultProps = {
20
19
  };
21
20
  export default function HelpButtonInstance(localProps) {
22
21
  const context = React.useContext(Context);
23
- const props = extendPropsWithContext(localProps, defaultProps, includeValidProps(context.FormRow), context.HelpButton);
22
+ const props = extendPropsWithContext(localProps, defaultProps, context.HelpButton);
24
23
 
25
24
  const {
26
25
  size,
@@ -16,7 +16,6 @@ import { spacingPropTypes, createSpacingClasses } from '../space/SpacingHelper';
16
16
  import { createSkeletonClass } from '../skeleton/SkeletonHelper';
17
17
  import Context from '../../shared/Context';
18
18
  import { iconCase } from './IconHelpers';
19
- import { includeValidProps } from '../form-row/FormRowHelpers';
20
19
  export const DefaultIconSize = 16;
21
20
  export const DefaultIconSizes = {
22
21
  default: 16,
@@ -59,7 +58,7 @@ export default class Icon extends React.PureComponent {
59
58
 
60
59
  const props = extendPropsWithContextInClassComponent(this.props, Icon.defaultProps, {
61
60
  skeleton: (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.skeleton
62
- }, includeValidProps(this.context.FormRow), this.context.Icon);
61
+ }, this.context.Icon);
63
62
  const {
64
63
  icon,
65
64
  size,
@@ -7,7 +7,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
7
7
  import React from 'react';
8
8
  import Context from '../../shared/Context';
9
9
  import { extendPropsWithContextInClassComponent } from '../../shared/component-helper';
10
- import { includeValidProps } from '../form-row/FormRowHelpers';
11
10
  import DefaultIcon, { iconPropTypes, DefaultIconSize, prerenderIcon, prepareIcon } from '../icon/Icon';
12
11
  import * as primary_icons from '../../icons/primary_icons.js';
13
12
  import * as primary_icons_medium from '../../icons/primary_icons_medium.js';
@@ -29,7 +28,7 @@ export default class IconPrimary extends React.PureComponent {
29
28
 
30
29
  const props = extendPropsWithContextInClassComponent(this.props, IconPrimary.defaultProps, {
31
30
  skeleton: (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.skeleton
32
- }, includeValidProps(this.context.FormRow), this.context.Icon, this.context.IconPrimary);
31
+ }, this.context.Icon, this.context.IconPrimary);
33
32
  const {
34
33
  icon,
35
34
  size,
@@ -15,6 +15,17 @@ import Input, { inputPropTypes } from '../input/Input';
15
15
  import Context from '../../shared/Context';
16
16
  const InputMasked = React.forwardRef((props, ref) => {
17
17
  const context = React.useContext(Context);
18
+
19
+ if (props !== null && props !== void 0 && props.mask) {
20
+ const alias = context === null || context === void 0 ? void 0 : context.InputMasked;
21
+
22
+ for (const key in alias) {
23
+ if (/^as[_A-Z]|number_mask|currency_mask/.test(key)) {
24
+ delete alias[key];
25
+ }
26
+ }
27
+ }
28
+
18
29
  const contextAndProps = React.useCallback(extendPropsWithContext(props, InputMasked.defaultProps, context === null || context === void 0 ? void 0 : context.InputMasked), [props, InputMasked.defaultProps, context === null || context === void 0 ? void 0 : context.InputMasked]);
19
30
  return React.createElement(InputMaskedContext.Provider, {
20
31
  value: {
@@ -55,7 +66,7 @@ process.env.NODE_ENV !== "production" ? InputMasked.propTypes = _objectSpread({
55
66
  on_submit_blur: PropTypes.func
56
67
  }, inputPropTypes) : void 0;
57
68
  InputMasked.defaultProps = _objectSpread(_objectSpread({}, Input.defaultProps), {}, {
58
- mask: [],
69
+ mask: null,
59
70
  number_mask: null,
60
71
  currency_mask: null,
61
72
  mask_options: null,
@@ -182,7 +182,7 @@ export const useInputElement = () => {
182
182
  inputRef: ref,
183
183
  inputElement: inputElementRef.current,
184
184
  pipe: pipe,
185
- mask: mask,
185
+ mask: mask || [],
186
186
  showMask: showMask,
187
187
  guide: showGuide,
188
188
  keepCharPositions: keepCharPositions,
@@ -63,8 +63,8 @@ export const correctNumberValue = ({
63
63
  value = value.replace('.', decimalSymbol);
64
64
 
65
65
  if (localValue !== null) {
66
- const localNumberValue = localValue.replace(/[^\d,.]/g, '');
67
- const numberValue = value.replace(/[^\d,.]/g, '');
66
+ const localNumberValue = localValue.replace(/[^\d,.-]/g, '');
67
+ const numberValue = value.replace(/[^\d,.-]/g, '');
68
68
  const endsWithDecimal = localNumberValue.endsWith(decimalSymbol);
69
69
  const endsWithZeroAndDecimal = localNumberValue.endsWith(`${decimalSymbol}0`);
70
70
 
@@ -78,7 +78,7 @@ export const correctNumberValue = ({
78
78
  value = localValue;
79
79
  }
80
80
 
81
- if (/^-|-0$/.test(localValue)) {
81
+ if (/^(-|-0)$/.test(localValue.replace(/[^\d-0]/g, ''))) {
82
82
  value = localValue;
83
83
  } else if (localNumberValue === '' && numberValue === '0') {
84
84
  value = '';
@@ -14,7 +14,6 @@ import PropTypes from 'prop-types';
14
14
  import classnames from 'classnames';
15
15
  import Context from '../../shared/Context';
16
16
  import { validateDOMAttributes, registerElement, extendPropsWithContextInClassComponent } from '../../shared/component-helper';
17
- import { includeValidProps } from '../form-row/FormRowHelpers';
18
17
  import { spacingPropTypes, createSpacingClasses } from '../space/SpacingHelper';
19
18
  export default class Logo extends React.PureComponent {
20
19
  static enableWebComponent() {
@@ -22,7 +21,7 @@ export default class Logo extends React.PureComponent {
22
21
  }
23
22
 
24
23
  render() {
25
- const props = extendPropsWithContextInClassComponent(this.props, Logo.defaultProps, this.context.getTranslation(this.props).Logo, includeValidProps(this.context.FormRow), this.context.Logo);
24
+ const props = extendPropsWithContextInClassComponent(this.props, Logo.defaultProps, this.context.getTranslation(this.props).Logo, this.context.Logo);
26
25
 
27
26
  let {
28
27
  ratio,
@@ -21,7 +21,6 @@ import ModalHeaderBar from './parts/ModalHeaderBar';
21
21
  import CloseButton from './parts/CloseButton';
22
22
  import ModalRoot from './ModalRoot';
23
23
  import { classWithCamelCaseProps } from '../../shared/helpers/withCamelCaseProps';
24
- import { includeValidProps } from '../form-row/FormRowHelpers';
25
24
  export const ANIMATION_DURATION = 300;
26
25
 
27
26
  class Modal extends React.PureComponent {
@@ -317,7 +316,7 @@ class Modal extends React.PureComponent {
317
316
  }
318
317
 
319
318
  render() {
320
- const props = extendPropsWithContextInClassComponent(this.props, Modal.defaultProps, this.context.getTranslation(this.props).Modal, includeValidProps(this.context.FormRow), this.context.Modal);
319
+ const props = extendPropsWithContextInClassComponent(this.props, Modal.defaultProps, this.context.getTranslation(this.props).Modal, this.context.Modal);
321
320
 
322
321
  const {
323
322
  root_id = 'root',
@@ -18,7 +18,6 @@ import classnames from 'classnames';
18
18
  import PaginationContext from './PaginationContext';
19
19
  import PaginationProvider from './PaginationProvider';
20
20
  import { registerElement, validateDOMAttributes, extendPropsWithContextInClassComponent } from '../../shared/component-helper';
21
- import { includeValidProps } from '../form-row/FormRowHelpers';
22
21
  import { spacingPropTypes, createSpacingClasses } from '../space/SpacingHelper';
23
22
  import { PaginationIndicator } from './PaginationHelpers';
24
23
  import InfinityScroller from './PaginationInfinity';
@@ -123,7 +122,7 @@ class PaginationInstance extends React.PureComponent {
123
122
  }
124
123
 
125
124
  render() {
126
- const props = extendPropsWithContextInClassComponent(this.props, paginationDefaultProps, this.context.getTranslation(this.props).Pagination, includeValidProps(this.context.FormRow), this.context.Pagination);
125
+ const props = extendPropsWithContextInClassComponent(this.props, paginationDefaultProps, this.context.getTranslation(this.props).Pagination, this.context.Pagination);
127
126
 
128
127
  const {
129
128
  align,
@@ -12,7 +12,6 @@ import PropTypes from 'prop-types';
12
12
  import classnames from 'classnames';
13
13
  import Context from '../../shared/Context';
14
14
  import { isTrue, registerElement, validateDOMAttributes, dispatchCustomElementEvent, extendPropsWithContextInClassComponent } from '../../shared/component-helper';
15
- import { includeValidProps } from '../form-row/FormRowHelpers';
16
15
  import { spacingPropTypes, createSpacingClasses } from '../space/SpacingHelper';
17
16
  import ProgressIndicatorCircular from './ProgressIndicatorCircular';
18
17
  import ProgressIndicatorLinear from './ProgressIndicatorLinear';
@@ -65,7 +64,7 @@ export default class ProgressIndicator extends React.PureComponent {
65
64
  }
66
65
 
67
66
  render() {
68
- const props = extendPropsWithContextInClassComponent(this.props, ProgressIndicator.defaultProps, this.context.getTranslation(this.props).ProgressIndicator, includeValidProps(this.context.FormRow), this.context.ProgressIndicator);
67
+ const props = extendPropsWithContextInClassComponent(this.props, ProgressIndicator.defaultProps, this.context.getTranslation(this.props).ProgressIndicator, this.context.ProgressIndicator);
69
68
 
70
69
  const {
71
70
  type,
@@ -10,7 +10,6 @@ import Context from '../../shared/Context';
10
10
  import { stepIndicatorDefaultProps } from './StepIndicatorProps';
11
11
  import { processChildren, extendPropsWithContextInClassComponent } from '../../shared/component-helper';
12
12
  import { onMediaQueryChange } from '../../shared/MediaQueryUtils';
13
- import { includeValidProps } from '../form-row/FormRowHelpers';
14
13
  const filterAttributes = Object.keys(stepIndicatorDefaultProps).filter(item => {
15
14
  return !['class', 'className'].includes(item);
16
15
  }).concat(['internalId', 'isSidebar', 'hasSidebar', 'hideSidebar', 'sidebarIsVisible', 'mainTitle', 'stepsLabel', 'stepsLabelExtended', 'listOfReachedSteps', 'setActiveStep', 'activeStep', 'countSteps', 'openState', 'onChangeState', 'openHandler', 'closeHandler', 'innerRef', 'hasSkeletonData', 'filterAttributes', 'listAttributes', 'onChangeState', 'isV1', 'activeUrl']);
@@ -139,7 +138,7 @@ export class StepIndicatorProvider extends React.PureComponent {
139
138
  getGlobalContext(context = this.context) {
140
139
  const data = extendPropsWithContextInClassComponent(this.props, stepIndicatorDefaultProps, {
141
140
  skeleton: context === null || context === void 0 ? void 0 : context.skeleton
142
- }, context.getTranslation(context).StepIndicator, includeValidProps(context.FormRow), context.StepIndicator);
141
+ }, context.getTranslation(context).StepIndicator, context.StepIndicator);
143
142
  return data;
144
143
  }
145
144
 
@@ -75,7 +75,6 @@ const Upload = localProps => {
75
75
  }, React.createElement(Provider, {
76
76
  skeleton: skeleton
77
77
  }, React.createElement(UploadDropzone, _extends({
78
- "data-testid": "upload",
79
78
  className: classnames('dnb-upload', spacingClasses, className)
80
79
  }, props), _UploadInfo || (_UploadInfo = React.createElement(UploadInfo, null)), _UploadFileInput || (_UploadFileInput = React.createElement(UploadFileInput, null)), _UploadFileList || (_UploadFileList = React.createElement(UploadFileList, null)))));
81
80
 
@@ -6,7 +6,7 @@ import { folder as FolderIcon } from '../../icons';
6
6
  import { makeUniqueId } from '../../shared/component-helper';
7
7
  import { UploadContext } from './UploadContext';
8
8
  import UploadStatus from './UploadStatus';
9
- import { extendWithAbbreviation } from './UploadVerify';
9
+ import { getAcceptedFileTypes } from './UploadVerify';
10
10
 
11
11
  const UploadFileInput = () => {
12
12
  const fileInput = useRef(null);
@@ -26,13 +26,10 @@ const UploadFileInput = () => {
26
26
  };
27
27
 
28
28
  const sharedId = id || makeUniqueId();
29
- const accept = extendWithAbbreviation(acceptedFileTypes).map(type => `.${type}`).join(',');
30
- return React.createElement("div", {
31
- "data-testid": "upload-file-input"
32
- }, React.createElement(Button, {
29
+ const accept = getAcceptedFileTypes(acceptedFileTypes);
30
+ return React.createElement("div", null, React.createElement(Button, {
33
31
  top: "medium",
34
32
  id: `${sharedId}-input`,
35
- "data-testid": "upload-file-input-button",
36
33
  className: "dnb-upload__file-input-button",
37
34
  icon: FolderIcon,
38
35
  icon_position: "left",
@@ -41,7 +38,6 @@ const UploadFileInput = () => {
41
38
  onClick: openFileDialog
42
39
  }, buttonText), _UploadStatus || (_UploadStatus = React.createElement(UploadStatus, null)), React.createElement("input", {
43
40
  "aria-labelledby": `${sharedId}-input`,
44
- "data-testid": "upload-file-input-input",
45
41
  ref: fileInput,
46
42
  accept: accept,
47
43
  className: "dnb-upload__file-input",
@@ -24,7 +24,6 @@ function UploadFileList() {
24
24
  }
25
25
 
26
26
  return React.createElement("ul", {
27
- "data-testid": "upload-file-list",
28
27
  className: "dnb-upload__file-list",
29
28
  "aria-label": fileListAriaLabel
30
29
  }, files.map((uploadFile, index) => {
@@ -10,6 +10,7 @@ import P from '../../elements/P';
10
10
  import { trash as TrashIcon, exclamation_medium as ExclamationIcon, file_pdf_medium as pdf, file_xls_medium as xls, file_ppt_medium as ppt, file_csv_medium as csv, file_txt_medium as txt, file_xml_medium as xml, file_medium as file } from '../../icons';
11
11
  import { getPreviousSibling, warn } from '../../shared/component-helper';
12
12
  import useUpload from './useUpload';
13
+ import { getFileTypeFromExtension } from './UploadVerify';
13
14
  const images = {
14
15
  pdf,
15
16
  xls,
@@ -27,19 +28,16 @@ const UploadFileListCell = ({
27
28
  loadingText,
28
29
  deleteButtonText
29
30
  }) => {
30
- var _div, _a, _FormStatus;
31
+ var _div, _P, _FormStatus;
31
32
 
32
33
  const {
33
34
  file,
34
35
  errorMessage,
35
36
  isLoading
36
37
  } = uploadFile;
37
- const {
38
- name,
39
- type
40
- } = file;
41
- const fileType = type.split('/')[1] || '';
42
38
  const hasWarning = errorMessage != null;
39
+ const fileType = getFileTypeFromExtension(file);
40
+ const humanFileType = fileType.toUpperCase();
43
41
  const imageUrl = URL.createObjectURL(file);
44
42
  const cellRef = useRef();
45
43
  const exists = useExistsHighlight(id, file);
@@ -60,7 +58,6 @@ const UploadFileListCell = ({
60
58
  };
61
59
 
62
60
  return React.createElement("li", {
63
- "data-testid": "upload-file-list-cell",
64
61
  className: classnames('dnb-upload__file-cell', hasWarning && 'dnb-upload__file-cell--warning', exists && 'dnb-upload__file-cell--highlight'),
65
62
  ref: cellRef
66
63
  }, React.createElement("div", {
@@ -68,7 +65,6 @@ const UploadFileListCell = ({
68
65
  }, React.createElement("div", {
69
66
  className: "dnb-upload__file-cell__content__left"
70
67
  }, getIcon(), getTitle()), React.createElement("div", null, React.createElement(Button, {
71
- "data-testid": "upload-delete-button",
72
68
  icon: TrashIcon,
73
69
  variant: "tertiary",
74
70
  onClick: onDeleteHandler,
@@ -77,9 +73,7 @@ const UploadFileListCell = ({
77
73
 
78
74
  function getIcon() {
79
75
  if (isLoading) {
80
- return _ProgressIndicator || (_ProgressIndicator = React.createElement(ProgressIndicator, {
81
- "data-testid": "upload-progress-indicator"
82
- }));
76
+ return _ProgressIndicator || (_ProgressIndicator = React.createElement(ProgressIndicator, null));
83
77
  }
84
78
 
85
79
  if (hasWarning) return _Icon || (_Icon = React.createElement(Icon, {
@@ -87,7 +81,12 @@ const UploadFileListCell = ({
87
81
  }));
88
82
  let iconFileType = fileType;
89
83
 
90
- if (!Object.prototype.hasOwnProperty.call(images, fileType)) {
84
+ if (!iconFileType) {
85
+ const mimeParts = file.type.split('/');
86
+ iconFileType = images[mimeParts[0]] || images[mimeParts[1]];
87
+ }
88
+
89
+ if (!Object.prototype.hasOwnProperty.call(images, iconFileType)) {
91
90
  iconFileType = 'file';
92
91
  }
93
92
 
@@ -101,23 +100,20 @@ const UploadFileListCell = ({
101
100
  className: "dnb-upload__file-cell__text-container dnb-upload__file-cell__text-container--loading"
102
101
  }, loadingText)) : React.createElement("div", {
103
102
  className: "dnb-upload__file-cell__text-container"
104
- }, _a || (_a = React.createElement("a", {
105
- "data-testid": "upload-file-anchor",
103
+ }, React.createElement("a", {
106
104
  target: "_blank",
107
105
  href: imageUrl,
108
106
  className: "dnb-anchor dnb-upload__file-cell__title",
109
107
  rel: "noopener noreferrer"
110
- }, name)), React.createElement(P, {
111
- "data-testid": "upload-subtitle",
108
+ }, file.name), _P || (_P = React.createElement(P, {
112
109
  className: "dnb-upload__file-cell__subtitle",
113
110
  size: "x-small",
114
111
  top: "xx-small"
115
- }, fileType.toUpperCase()));
112
+ }, humanFileType)));
116
113
  }
117
114
 
118
115
  function getWarning() {
119
116
  return hasWarning ? _FormStatus || (_FormStatus = React.createElement(FormStatus, {
120
- "data-testid": "upload-warning",
121
117
  top: "small",
122
118
  text: errorMessage,
123
119
  stretch: true
@@ -22,10 +22,8 @@ const UploadInfo = () => {
22
22
  } = context;
23
23
  const prettyfiedAcceptedFileFormats = acceptedFileTypes.join(', ').toUpperCase();
24
24
  return React.createElement(React.Fragment, null, React.createElement(Lead, {
25
- "data-testid": "upload-title",
26
25
  space: "0"
27
26
  }, title), React.createElement(P, {
28
- "data-testid": "upload-text",
29
27
  top: "xx-small",
30
28
  className: "dnb-upload__text"
31
29
  }, text), React.createElement(Dl, {
@@ -33,13 +31,7 @@ const UploadInfo = () => {
33
31
  bottom: 0,
34
32
  direction: "horizontal",
35
33
  className: "dnb-upload__condition-list"
36
- }, React.createElement(Dl.Item, null, React.createElement(Dt, {
37
- "data-testid": "upload-accepted-formats"
38
- }, fileTypeDescription), React.createElement(Dd, null, prettyfiedAcceptedFileFormats)), React.createElement(Dl.Item, null, React.createElement(Dt, {
39
- "data-testid": "upload-file-size"
40
- }, fileSizeDescription), React.createElement(Dd, null, String(fileSizeContent).replace('%size', format(fileMaxSize).toString()))), filesAmountLimit < defaultProps.filesAmountLimit && React.createElement(Dl.Item, null, React.createElement(Dt, {
41
- "data-testid": "upload-file-amount-limit"
42
- }, fileAmountDescription), React.createElement(Dd, null, filesAmountLimit))));
34
+ }, prettyfiedAcceptedFileFormats && React.createElement(Dl.Item, null, React.createElement(Dt, null, fileTypeDescription), React.createElement(Dd, null, prettyfiedAcceptedFileFormats)), React.createElement(Dl.Item, null, React.createElement(Dt, null, fileSizeDescription), React.createElement(Dd, null, String(fileSizeContent).replace('%size', format(fileMaxSize).toString()))), filesAmountLimit < defaultProps.filesAmountLimit && React.createElement(Dl.Item, null, React.createElement(Dt, null, fileAmountDescription), React.createElement(Dd, null, filesAmountLimit))));
43
35
  };
44
36
 
45
37
  export default UploadInfo;
@@ -1,5 +1,8 @@
1
1
  import { UploadFile, UploadContextProps, UploadAcceptedFileTypes } from './types';
2
2
  export declare function verifyFiles(files: UploadFile[], context: Pick<UploadContextProps, 'errorUnsupportedFile' | 'errorLargeFile' | 'acceptedFileTypes' | 'fileMaxSize'>): UploadFile[];
3
+ export declare function getFileTypeFromExtension(file: File): string;
4
+ export declare function getAcceptedFileTypes(acceptedFileTypes: UploadAcceptedFileTypes): string;
5
+ export declare function hasPreferredMimeType(acceptedFileTypes: UploadAcceptedFileTypes, file: File): boolean;
3
6
  export declare function extendWithAbbreviation(acceptedFileTypes: UploadAcceptedFileTypes, abbreviations?: {
4
7
  jpg: string;
5
8
  }): string[];
@@ -17,8 +17,9 @@ export function verifyFiles(files, context) {
17
17
  return false;
18
18
  }
19
19
 
20
+ const fileType = hasPreferredMimeType(acceptedFileTypes, file) ? file.type : getFileTypeFromExtension(file) || file.type;
20
21
  const foundType = extendWithAbbreviation(acceptedFileTypes).some(type => {
21
- return file.type.includes(type);
22
+ return fileType.includes(type);
22
23
  });
23
24
  return !foundType ? errorUnsupportedFile : null;
24
25
  };
@@ -37,6 +38,15 @@ export function verifyFiles(files, context) {
37
38
  });
38
39
  return cleanedFiles;
39
40
  }
41
+ export function getFileTypeFromExtension(file) {
42
+ return file.name.includes('.') && file.name.replace(/.*\.([^.]+)$/, '$1') || null;
43
+ }
44
+ export function getAcceptedFileTypes(acceptedFileTypes) {
45
+ return extendWithAbbreviation(acceptedFileTypes).map(type => type.includes('/') ? type : `.${type}`).join(',');
46
+ }
47
+ export function hasPreferredMimeType(acceptedFileTypes, file) {
48
+ return file.type.split('/')[1] && (!(acceptedFileTypes !== null && acceptedFileTypes !== void 0 && acceptedFileTypes.length) || (acceptedFileTypes === null || acceptedFileTypes === void 0 ? void 0 : acceptedFileTypes.some(type => type.toLowerCase() === file.type.toLowerCase())));
49
+ }
40
50
  export function extendWithAbbreviation(acceptedFileTypes, abbreviations = {
41
51
  jpg: 'jpeg'
42
52
  }) {
@@ -7,7 +7,6 @@ import Context from '../shared/Context';
7
7
  import { validateDOMAttributes, extendPropsWithContext } from '../shared/component-helper';
8
8
  import { createSpacingClasses } from '../components/space/SpacingHelper';
9
9
  import { createSkeletonClass, skeletonDOMAttributes } from '../components/skeleton/SkeletonHelper';
10
- import { includeValidProps } from '../components/form-row/FormRowHelpers';
11
10
  export const defaultProps = {
12
11
  skeletonMethod: 'font'
13
12
  };
@@ -21,7 +20,7 @@ function ElementInstance(localProps) {
21
20
  const context = React.useContext(Context);
22
21
  const props = extendPropsWithContext(localProps, defaultProps, {
23
22
  skeleton: context === null || context === void 0 ? void 0 : context.skeleton
24
- }, includeValidProps(context === null || context === void 0 ? void 0 : context.FormRow));
23
+ });
25
24
 
26
25
  if (typeof props.inner_ref !== 'undefined') {
27
26
  props.innerRef = props.inner_ref;
@@ -16,7 +16,6 @@ import classnames from 'classnames';
16
16
  import keycode from 'keycode';
17
17
  import { isTrue, makeUniqueId, extendPropsWithContextInClassComponent, registerElement, validateDOMAttributes, dispatchCustomElementEvent } from '../../shared/component-helper';
18
18
  import { createSpacingClasses } from '../../components/space/SpacingHelper';
19
- import { includeValidProps } from '../../components/form-row/FormRowHelpers';
20
19
  import DrawerListContext from './DrawerListContext';
21
20
  import DrawerListProvider from './DrawerListProvider';
22
21
  import DrawerListPortal from './DrawerListPortal';
@@ -121,7 +120,7 @@ class DrawerListInstance extends React.PureComponent {
121
120
  }
122
121
 
123
122
  render() {
124
- const props = extendPropsWithContextInClassComponent(this.props, DrawerList.defaultProps, this.context.getTranslation(this.props).DrawerList, includeValidProps(this.context.FormRow), this.context.DrawerList);
123
+ const props = extendPropsWithContextInClassComponent(this.props, DrawerList.defaultProps, this.context.getTranslation(this.props).DrawerList);
125
124
 
126
125
  const {
127
126
  role,
@@ -2,7 +2,7 @@ export function init() {
2
2
  if (typeof window !== 'undefined') {
3
3
  class Eufemia {
4
4
  get version() {
5
- return '9.47.0';
5
+ return '9.47.2';
6
6
  }
7
7
 
8
8
  }