@dnb/eufemia 9.43.0 → 9.45.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 (149) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/cjs/components/avatar/Avatar.d.ts +1 -1
  3. package/cjs/components/lib.d.ts +7 -7
  4. package/cjs/components/section/style/themes/dnb-section-theme-ui.css +2 -7
  5. package/cjs/components/section/style/themes/dnb-section-theme-ui.min.css +1 -1
  6. package/cjs/components/space/SpacingHelper.d.ts +1 -2
  7. package/cjs/components/space/SpacingHelper.js +0 -6
  8. package/cjs/components/space/SpacingUtils.d.ts +30 -19
  9. package/cjs/components/space/SpacingUtils.js +151 -132
  10. package/cjs/components/space/types.d.ts +13 -6
  11. package/cjs/components/table/TableAccordion.d.ts +4 -1
  12. package/cjs/components/table/TableAccordion.js +8 -2
  13. package/cjs/components/table/TableAccordionContent.js +22 -2
  14. package/cjs/components/table/TableTr.d.ts +18 -0
  15. package/cjs/components/table/TableTr.js +8 -2
  16. package/cjs/components/table/style/_table-header-buttons.scss +4 -0
  17. package/cjs/components/table/style/_table-sticky.scss +3 -7
  18. package/cjs/components/table/style/_table-tr.scss +2 -1
  19. package/cjs/components/table/style/dnb-table.css +7 -8
  20. package/cjs/components/table/style/dnb-table.min.css +3 -3
  21. package/cjs/components/tag/Tag.d.ts +1 -1
  22. package/cjs/elements/Anchor.d.ts +1 -1
  23. package/cjs/elements/Dd.d.ts +1 -1
  24. package/cjs/elements/Dt.d.ts +1 -1
  25. package/cjs/elements/Element.d.ts +1 -1
  26. package/cjs/elements/Link.d.ts +1 -1
  27. package/cjs/elements/lib.d.ts +5 -5
  28. package/cjs/fragments/lib.d.ts +1 -1
  29. package/cjs/fragments/scroll-view/ScrollView.d.ts +1 -1
  30. package/cjs/shared/Eufemia.js +1 -1
  31. package/cjs/shared/index.d.ts +1 -1
  32. package/cjs/shared/index.js +1 -1
  33. package/cjs/style/dnb-ui-components.css +7 -8
  34. package/cjs/style/dnb-ui-components.min.css +3 -3
  35. package/cjs/style/dnb-ui-elements.css +12 -39
  36. package/cjs/style/dnb-ui-elements.min.css +1 -1
  37. package/cjs/style/dnb-ui-tags.css +21 -59
  38. package/cjs/style/dnb-ui-tags.min.css +1 -1
  39. package/cjs/style/elements/_anchor-mixins.scss +9 -14
  40. package/cjs/style/elements/anchor.scss +1 -1
  41. package/cjs/style/themes/theme-eiendom/dnb-theme-eiendom.css +14 -46
  42. package/cjs/style/themes/theme-eiendom/dnb-theme-eiendom.min.css +2 -2
  43. package/cjs/style/themes/theme-ui/dnb-theme-ui.css +14 -46
  44. package/cjs/style/themes/theme-ui/dnb-theme-ui.min.css +2 -2
  45. package/components/avatar/Avatar.d.ts +1 -1
  46. package/components/lib.d.ts +7 -7
  47. package/components/section/style/themes/dnb-section-theme-ui.css +2 -7
  48. package/components/section/style/themes/dnb-section-theme-ui.min.css +1 -1
  49. package/components/space/SpacingHelper.d.ts +1 -2
  50. package/components/space/SpacingHelper.js +2 -2
  51. package/components/space/SpacingUtils.d.ts +30 -19
  52. package/components/space/SpacingUtils.js +121 -109
  53. package/components/space/types.d.ts +13 -6
  54. package/components/table/TableAccordion.d.ts +4 -1
  55. package/components/table/TableAccordion.js +8 -2
  56. package/components/table/TableAccordionContent.js +21 -2
  57. package/components/table/TableTr.d.ts +18 -0
  58. package/components/table/TableTr.js +8 -2
  59. package/components/table/style/_table-header-buttons.scss +4 -0
  60. package/components/table/style/_table-sticky.scss +3 -7
  61. package/components/table/style/_table-tr.scss +2 -1
  62. package/components/table/style/dnb-table.css +7 -8
  63. package/components/table/style/dnb-table.min.css +3 -3
  64. package/components/tag/Tag.d.ts +1 -1
  65. package/elements/Anchor.d.ts +1 -1
  66. package/elements/Dd.d.ts +1 -1
  67. package/elements/Dt.d.ts +1 -1
  68. package/elements/Element.d.ts +1 -1
  69. package/elements/Link.d.ts +1 -1
  70. package/elements/lib.d.ts +5 -5
  71. package/es/components/avatar/Avatar.d.ts +1 -1
  72. package/es/components/lib.d.ts +7 -7
  73. package/es/components/section/style/themes/dnb-section-theme-ui.css +2 -7
  74. package/es/components/section/style/themes/dnb-section-theme-ui.min.css +1 -1
  75. package/es/components/space/SpacingHelper.d.ts +1 -2
  76. package/es/components/space/SpacingHelper.js +2 -2
  77. package/es/components/space/SpacingUtils.d.ts +30 -19
  78. package/es/components/space/SpacingUtils.js +81 -76
  79. package/es/components/space/types.d.ts +13 -6
  80. package/es/components/table/TableAccordion.d.ts +4 -1
  81. package/es/components/table/TableAccordion.js +8 -2
  82. package/es/components/table/TableAccordionContent.js +23 -2
  83. package/es/components/table/TableTr.d.ts +18 -0
  84. package/es/components/table/TableTr.js +8 -2
  85. package/es/components/table/style/_table-header-buttons.scss +4 -0
  86. package/es/components/table/style/_table-sticky.scss +3 -7
  87. package/es/components/table/style/_table-tr.scss +2 -1
  88. package/es/components/table/style/dnb-table.css +7 -8
  89. package/es/components/table/style/dnb-table.min.css +3 -3
  90. package/es/components/tag/Tag.d.ts +1 -1
  91. package/es/elements/Anchor.d.ts +1 -1
  92. package/es/elements/Dd.d.ts +1 -1
  93. package/es/elements/Dt.d.ts +1 -1
  94. package/es/elements/Element.d.ts +1 -1
  95. package/es/elements/Link.d.ts +1 -1
  96. package/es/elements/lib.d.ts +5 -5
  97. package/es/fragments/lib.d.ts +1 -1
  98. package/es/fragments/scroll-view/ScrollView.d.ts +1 -1
  99. package/es/shared/Eufemia.js +1 -1
  100. package/es/shared/index.d.ts +1 -1
  101. package/es/shared/index.js +2 -2
  102. package/es/style/dnb-ui-components.css +7 -8
  103. package/es/style/dnb-ui-components.min.css +3 -3
  104. package/es/style/dnb-ui-elements.css +12 -39
  105. package/es/style/dnb-ui-elements.min.css +1 -1
  106. package/es/style/dnb-ui-tags.css +21 -59
  107. package/es/style/dnb-ui-tags.min.css +1 -1
  108. package/es/style/elements/_anchor-mixins.scss +9 -14
  109. package/es/style/elements/anchor.scss +1 -1
  110. package/es/style/themes/theme-eiendom/dnb-theme-eiendom.css +14 -46
  111. package/es/style/themes/theme-eiendom/dnb-theme-eiendom.min.css +2 -2
  112. package/es/style/themes/theme-ui/dnb-theme-ui.css +14 -46
  113. package/es/style/themes/theme-ui/dnb-theme-ui.min.css +2 -2
  114. package/esm/dnb-ui-basis.min.mjs +1 -1
  115. package/esm/dnb-ui-components.min.mjs +1 -1
  116. package/esm/dnb-ui-elements.min.mjs +2 -2
  117. package/esm/dnb-ui-extensions.min.mjs +1 -1
  118. package/esm/dnb-ui-lib.min.mjs +2 -2
  119. package/esm/dnb-ui-web-components.min.mjs +2 -2
  120. package/fragments/lib.d.ts +1 -1
  121. package/fragments/scroll-view/ScrollView.d.ts +1 -1
  122. package/package.json +1 -1
  123. package/shared/Eufemia.js +1 -1
  124. package/shared/index.d.ts +1 -1
  125. package/shared/index.js +2 -2
  126. package/style/dnb-ui-components.css +7 -8
  127. package/style/dnb-ui-components.min.css +3 -3
  128. package/style/dnb-ui-elements.css +12 -39
  129. package/style/dnb-ui-elements.min.css +1 -1
  130. package/style/dnb-ui-tags.css +21 -59
  131. package/style/dnb-ui-tags.min.css +1 -1
  132. package/style/elements/_anchor-mixins.scss +9 -14
  133. package/style/elements/anchor.scss +1 -1
  134. package/style/themes/theme-eiendom/dnb-theme-eiendom.css +14 -46
  135. package/style/themes/theme-eiendom/dnb-theme-eiendom.min.css +2 -2
  136. package/style/themes/theme-ui/dnb-theme-ui.css +14 -46
  137. package/style/themes/theme-ui/dnb-theme-ui.min.css +2 -2
  138. package/umd/dnb-ui-basis.min.js +1 -1
  139. package/umd/dnb-ui-components.min.js +1 -1
  140. package/umd/dnb-ui-elements.min.js +2 -2
  141. package/umd/dnb-ui-extensions.min.js +4 -4
  142. package/umd/dnb-ui-lib.min.js +2 -2
  143. package/umd/dnb-ui-web-components.min.js +2 -2
  144. package/cjs/shared/SpacingHelper.d.ts +0 -6
  145. package/cjs/shared/SpacingHelper.js +0 -11
  146. package/es/shared/SpacingHelper.d.ts +0 -6
  147. package/es/shared/SpacingHelper.js +0 -2
  148. package/shared/SpacingHelper.d.ts +0 -6
  149. package/shared/SpacingHelper.js +0 -2
@@ -2,14 +2,8 @@
2
2
  * Space helper
3
3
  *
4
4
  */
5
- import type { SpacingProps } from './types';
6
- declare type Props = SpacingProps | Record<string, unknown>;
7
- declare type StyleObjectProps = {
8
- maxWidth?: string;
9
- maxHeight?: string;
10
- width?: string;
11
- height?: string;
12
- };
5
+ import type { StyleObjectProps, SpaceType, SpacingUnknownProps, SpacingProps } from './types';
6
+ declare type SpaceNumber = number;
13
7
  export declare const spacingDefaultProps: {
14
8
  space: any;
15
9
  top: any;
@@ -27,17 +21,34 @@ export declare const spacePatterns: {
27
21
  'xx-large': number;
28
22
  'xx-large-x2': number;
29
23
  };
30
- export declare const translateSpace: (type: any) => any;
31
- export declare const splitTypes: (types: any) => any;
32
- export declare const sumTypes: (types: any) => any;
33
- export declare const createTypeModifiers: (types: any) => any;
34
- export declare const findType: (num: any, { returnObject }?: {
35
- returnObject?: boolean;
36
- }) => string | [string, number];
37
- export declare const findNearestTypes: (num: any) => any[];
24
+ /**
25
+ * Helper function to generate a calc(var(--spacing-large) + var(--spacing-small))
26
+ *
27
+ * @param types 'small', '16px', '1rem'
28
+ * @returns e.g. calc(var(--spacing-large) + var(--spacing-small))
29
+ */
30
+ export declare const calc: (...types: Array<SpaceType>) => string;
31
+ /**
32
+ * Creates a valid space CSS class out from given space types
33
+ *
34
+ * @param props
35
+ * @param Element to check if it should be handled as inline
36
+ * @returns "dnb-space__large dnb-space__small"
37
+ */
38
+ export declare const createSpacingClasses: (props: SpacingProps
39
+ /**
40
+ * To support typical not defined props form components
41
+ */
42
+ | SpacingUnknownProps, Element?: any) => any[];
43
+ export declare const translateSpace: (type: SpaceType) => any;
44
+ export declare const splitTypes: (types: SpaceType | Array<SpaceType>) => SpaceType[];
45
+ export declare const sumTypes: (types: SpaceType | Array<SpaceType>) => any;
46
+ export declare const createTypeModifiers: (types: SpaceType) => Array<SpaceType>;
47
+ export declare const findType: (num: SpaceNumber) => SpaceType;
48
+ export declare const findTypeAll: (num: SpaceNumber) => Array<SpaceType>;
49
+ export declare const findNearestTypes: (num: SpaceNumber, multiply?: boolean) => any[];
38
50
  export declare const isValidSpaceProp: (propName: string) => boolean;
39
- export declare const removeSpaceProps: (props: Props) => Props;
40
- export declare const createSpacingClasses: (props: Props, Element?: any) => any[];
41
- export declare const createStyleObject: (props: Props & StyleObjectProps) => {};
51
+ export declare const removeSpaceProps: (props: StyleObjectProps) => StyleObjectProps;
52
+ export declare const createStyleObject: (props: StyleObjectProps) => {};
42
53
  export declare const isInline: (elementName: string) => boolean;
43
54
  export {};
@@ -2,32 +2,33 @@ import "core-js/modules/es.object.keys.js";
2
2
  import "core-js/modules/es.symbol.js";
3
3
  import "core-js/modules/es.object.get-own-property-descriptor.js";
4
4
  import "core-js/modules/es.object.get-own-property-descriptors.js";
5
- import _typeof from "@babel/runtime/helpers/esm/typeof";
6
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
5
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
8
6
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
7
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
8
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
9
 
10
10
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
11
11
 
12
12
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
13
13
 
14
+ import "core-js/modules/es.object.to-string.js";
15
+ import "core-js/modules/web.dom-collections.for-each.js";
16
+ import "core-js/modules/es.array.join.js";
17
+ import "core-js/modules/es.object.is-frozen.js";
18
+ import "core-js/modules/es.array.reduce.js";
19
+ import "core-js/modules/es.object.entries.js";
20
+ import "core-js/modules/es.array.concat.js";
21
+ import "core-js/modules/es.array.map.js";
14
22
  import "core-js/modules/es.regexp.exec.js";
15
23
  import "core-js/modules/es.string.replace.js";
16
24
  import "core-js/modules/es.string.split.js";
17
25
  import "core-js/modules/es.array.filter.js";
18
- import "core-js/modules/es.object.to-string.js";
19
- import "core-js/modules/es.array.reduce.js";
20
- import "core-js/modules/es.array.map.js";
21
26
  import "core-js/modules/es.parse-float.js";
22
- import "core-js/modules/web.dom-collections.for-each.js";
23
27
  import "core-js/modules/es.array.find.js";
24
- import "core-js/modules/es.object.entries.js";
25
28
  import "core-js/modules/es.array.reverse.js";
26
- import "core-js/modules/es.array.index-of.js";
27
- import "core-js/modules/es.array.concat.js";
28
29
  import "core-js/modules/es.array.includes.js";
29
- import "core-js/modules/es.object.is-frozen.js";
30
- import "core-js/modules/es.array.join.js";
30
+ import "core-js/modules/es.string.includes.js";
31
+ import "core-js/modules/es.array.index-of.js";
31
32
  import { warn } from '../../shared/component-helper';
32
33
  export var spacingDefaultProps = {
33
34
  space: null,
@@ -46,25 +47,95 @@ export var spacePatterns = {
46
47
  'xx-large': 3.5,
47
48
  'xx-large-x2': 7
48
49
  };
50
+ export var calc = function calc() {
51
+ var result = [];
52
+
53
+ for (var _len = arguments.length, types = new Array(_len), _key = 0; _key < _len; _key++) {
54
+ types[_key] = arguments[_key];
55
+ }
56
+
57
+ types.forEach(function (rawTypes) {
58
+ createTypeModifiers(rawTypes).forEach(function (type) {
59
+ result.push("var(--spacing-".concat(type, ")"));
60
+ });
61
+ });
62
+ return result.length ? "calc(".concat(result.join(' + '), ")") : null;
63
+ };
64
+ export var createSpacingClasses = function createSpacingClasses(props) {
65
+ var Element = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
66
+ var p = Object.isFrozen(props) ? _objectSpread({}, props) : props;
67
+
68
+ if (typeof p.space !== 'undefined') {
69
+ if (typeof p.space === 'string' || typeof p.space === 'number' || typeof p.space === 'boolean' && p.space) {
70
+ p.top = p.right = p.bottom = p.left = p.space;
71
+ }
72
+
73
+ if (_typeof(p.space) === 'object') {
74
+ for (var i in p.space) {
75
+ if (!p[i] && isValidSpaceProp(i)) {
76
+ p[i] = p.space[i];
77
+ }
78
+ }
79
+ }
80
+
81
+ delete p.space;
82
+ }
83
+
84
+ return Object.entries(p).reduce(function (acc, _ref) {
85
+ var _ref2 = _slicedToArray(_ref, 2),
86
+ direction = _ref2[0],
87
+ cur = _ref2[1];
88
+
89
+ if (isValidSpaceProp(direction)) {
90
+ if (String(cur) === '0' || String(cur) === 'false') {
91
+ acc.push("dnb-space__".concat(direction, "--zero"));
92
+ } else if (cur) {
93
+ var typeModifiers = createTypeModifiers(cur);
94
+ var sum = sumTypes(typeModifiers);
95
+
96
+ if (sum > 10) {
97
+ warn("Spacing of more than 10rem is not supported! You used ".concat(sum, " / (").concat(typeModifiers.join(','), ")"));
98
+ } else {
99
+ var nearestTypes = findNearestTypes(sum, true);
100
+ acc = [].concat(_toConsumableArray(acc), _toConsumableArray(nearestTypes.map(function (type) {
101
+ return "dnb-space__".concat(direction, "--").concat(type);
102
+ })));
103
+ }
104
+ }
105
+ } else if (direction === 'no_collapse') {
106
+ acc.push('dnb-space--no-collapse');
107
+
108
+ if (Element && isInline(Element)) {
109
+ acc.push('dnb-space--inline');
110
+ }
111
+ }
112
+
113
+ return acc;
114
+ }, []);
115
+ };
49
116
  export var translateSpace = function translateSpace(type) {
50
- if (/-x2$/.test(type)) {
51
- return spacePatterns[type.replace(/-x2$/, '')] * 2;
117
+ if (/-x2$/.test(String(type))) {
118
+ return spacePatterns[String(type).replace(/-x2$/, '')] * 2;
52
119
  }
53
120
 
54
- return spacePatterns[type] || 0;
121
+ return spacePatterns[String(type)] || 0;
55
122
  };
56
123
  export var splitTypes = function splitTypes(types) {
57
124
  if (typeof types === 'string') {
58
- types = types.split(/ /g);
125
+ return clean(types.split(/ /g));
59
126
  } else if (typeof types === 'boolean') {
60
127
  return ['small'];
61
128
  } else if (typeof types === 'number') {
62
129
  return [types];
63
130
  }
64
131
 
65
- return types ? types.filter(function (r) {
66
- return r && r.length > 0;
67
- }) : null;
132
+ return clean(types) || null;
133
+
134
+ function clean(t) {
135
+ return t === null || t === void 0 ? void 0 : t.filter(function (r) {
136
+ return r && String(r).length > 0;
137
+ });
138
+ }
68
139
  };
69
140
  export var sumTypes = function sumTypes(types) {
70
141
  return splitTypes(types).map(function (type) {
@@ -80,18 +151,14 @@ export var sumTypes = function sumTypes(types) {
80
151
  }, 0);
81
152
  };
82
153
  export var createTypeModifiers = function createTypeModifiers(types) {
83
- if (typeof types === 'number') {
84
- types = String(types);
85
- }
86
-
87
154
  return (splitTypes(types) || []).reduce(function (acc, type) {
88
155
  if (type) {
89
- var firstLetter = type[0];
156
+ var firstLetter = String(type)[0];
90
157
 
91
158
  if (parseFloat(firstLetter) > -1) {
92
- var num = parseFloat(type);
159
+ var num = parseFloat(String(type));
93
160
 
94
- if (num >= 8 && /[0-9]px/.test(type)) {
161
+ if (num >= 8 && /[0-9]px/.test(String(type))) {
95
162
  num = num / 16;
96
163
  }
97
164
 
@@ -108,7 +175,7 @@ export var createTypeModifiers = function createTypeModifiers(types) {
108
175
  }
109
176
  }
110
177
 
111
- if (!(parseFloat(type) > 0)) {
178
+ if (!(parseFloat(String(type)) > 0)) {
112
179
  acc.push(type);
113
180
  }
114
181
  }
@@ -117,52 +184,49 @@ export var createTypeModifiers = function createTypeModifiers(types) {
117
184
  }, []);
118
185
  };
119
186
  export var findType = function findType(num) {
120
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
121
- _ref$returnObject = _ref.returnObject,
122
- returnObject = _ref$returnObject === void 0 ? false : _ref$returnObject;
123
-
124
- var found = Object.entries(spacePatterns).find(function (_ref2) {
125
- var _ref3 = _slicedToArray(_ref2, 2),
126
- k = _ref3[0],
127
- v = _ref3[1];
128
-
129
- return k && v === num;
130
- }) || null;
131
-
132
- if (returnObject) {
133
- return found;
134
- }
187
+ var found = findTypeAll(num);
135
188
 
136
189
  if (found) {
137
190
  return found[0];
138
191
  }
139
192
 
193
+ return null;
194
+ };
195
+ export var findTypeAll = function findTypeAll(num) {
196
+ var found = Object.entries(spacePatterns).find(function (_ref3) {
197
+ var _ref4 = _slicedToArray(_ref3, 2),
198
+ k = _ref4[0],
199
+ v = _ref4[1];
200
+
201
+ return k && v === num;
202
+ }) || null;
140
203
  return found;
141
204
  };
142
205
  export var findNearestTypes = function findNearestTypes(num) {
206
+ var multiply = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
143
207
  var res = [];
144
- var near = Object.entries(spacePatterns).reverse().find(function (_ref4) {
145
- var _ref5 = _slicedToArray(_ref4, 2),
146
- k = _ref5[0],
147
- v = _ref5[1];
208
+ var near = Object.entries(spacePatterns).reverse().filter(function (k) {
209
+ return multiply ? true : !k[0].includes('-x');
210
+ }).find(function (_ref5) {
211
+ var _ref6 = _slicedToArray(_ref5, 2),
212
+ k = _ref6[0],
213
+ v = _ref6[1];
148
214
 
149
215
  return k && num >= v;
150
216
  });
151
217
  var nearNum = near && near[1] || num;
152
- var typeObject = findType(nearNum, {
153
- returnObject: true
154
- });
218
+ var types = findTypeAll(nearNum);
155
219
 
156
- if (typeObject) {
157
- var nearType = typeObject[0];
220
+ if (types) {
221
+ var nearType = types[0];
158
222
  res.push(nearType);
159
- var leftOver = num - parseFloat(String(typeObject[1]));
160
- var foundMoreTypes = findNearestTypes(leftOver);
223
+ var leftOver = num - parseFloat(String(types[1]));
224
+ var foundMoreTypes = findNearestTypes(leftOver, multiply);
161
225
  foundMoreTypes.forEach(function (type) {
162
226
  var index = res.indexOf(type);
163
227
 
164
228
  if (index !== -1) {
165
- res[index] = "".concat(type, "-x2");
229
+ res[index] = multiply ? "".concat(type, "-x2") : type;
166
230
  }
167
231
  });
168
232
  res = [].concat(_toConsumableArray(res), _toConsumableArray(foundMoreTypes));
@@ -184,58 +248,6 @@ export var removeSpaceProps = function removeSpaceProps(props) {
184
248
 
185
249
  return p;
186
250
  };
187
- export var createSpacingClasses = function createSpacingClasses(props) {
188
- var Element = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
189
- var p = Object.isFrozen(props) ? _objectSpread({}, props) : props;
190
-
191
- if (typeof p.space !== 'undefined') {
192
- if (typeof p.space === 'string' || typeof p.space === 'number' || typeof p.space === 'boolean' && p.space) {
193
- p.top = p.right = p.bottom = p.left = p.space;
194
- }
195
-
196
- if (_typeof(p.space) === 'object') {
197
- for (var i in p.space) {
198
- if (!p[i] && isValidSpaceProp(i)) {
199
- p[i] = p.space[i];
200
- }
201
- }
202
- }
203
-
204
- delete p.space;
205
- }
206
-
207
- return Object.entries(p).reduce(function (acc, _ref6) {
208
- var _ref7 = _slicedToArray(_ref6, 2),
209
- direction = _ref7[0],
210
- cur = _ref7[1];
211
-
212
- if (isValidSpaceProp(direction)) {
213
- if (String(cur) === '0' || String(cur) === 'false') {
214
- acc.push("dnb-space__".concat(direction, "--zero"));
215
- } else if (cur) {
216
- var typeModifiers = createTypeModifiers(cur);
217
- var sum = sumTypes(typeModifiers);
218
-
219
- if (sum > 10) {
220
- warn("Spacing of more than 10rem is not supported! You used ".concat(sum, " / (").concat(typeModifiers.join(','), ")"));
221
- } else {
222
- var nearestTypes = findNearestTypes(sum);
223
- acc = [].concat(_toConsumableArray(acc), _toConsumableArray(nearestTypes.map(function (type) {
224
- return "dnb-space__".concat(direction, "--").concat(type);
225
- })));
226
- }
227
- }
228
- } else if (direction === 'no_collapse') {
229
- acc.push('dnb-space--no-collapse');
230
-
231
- if (Element && isInline(Element)) {
232
- acc.push('dnb-space--inline');
233
- }
234
- }
235
-
236
- return acc;
237
- }, []);
238
- };
239
251
  export var createStyleObject = function createStyleObject(props) {
240
252
  var p = Object.isFrozen(props) ? _objectSpread({}, props) : props;
241
253
 
@@ -262,10 +274,10 @@ export var createStyleObject = function createStyleObject(props) {
262
274
  maxHeight: p.maxHeight && "".concat(p.maxHeight, "rem"),
263
275
  width: p.width && "".concat(p.width, "rem"),
264
276
  height: p.height && "".concat(p.height, "rem")
265
- }).reduce(function (acc, _ref8) {
266
- var _ref9 = _slicedToArray(_ref8, 2),
267
- key = _ref9[0],
268
- val = _ref9[1];
277
+ }).reduce(function (acc, _ref7) {
278
+ var _ref8 = _slicedToArray(_ref7, 2),
279
+ key = _ref8[0],
280
+ val = _ref8[1];
269
281
 
270
282
  if (typeof val !== 'undefined') {
271
283
  acc[key] = val;
@@ -3,26 +3,33 @@ export declare type SpacingElementProps = {
3
3
  * Use spacing values like: `small`, `1rem`, `1` or , `16px`. Will use `margin-top`.
4
4
  *
5
5
  */
6
- top?: SpaceTypes;
6
+ top?: SpaceType;
7
7
  /**
8
8
  * Use spacing values like: `small`, `1rem`, `1` or , `16px`. will use `margin-right`.
9
9
  *
10
10
  */
11
- right?: SpaceTypes;
11
+ right?: SpaceType;
12
12
  /**
13
13
  * Use spacing values like: `small`, `1rem`, `1` or , `16px`. will use `margin-bottom`.
14
14
  *
15
15
  */
16
- bottom?: SpaceTypes;
16
+ bottom?: SpaceType;
17
17
  /**
18
18
  * Use spacing values like: `small`, `1rem`, `1` or , `16px`. will use `margin-left`.
19
19
  *
20
20
  */
21
- left?: SpaceTypes;
21
+ left?: SpaceType;
22
22
  };
23
- export declare type SpaceTypes = string | boolean | number;
23
+ export declare type SpaceType = string | boolean | number;
24
24
  export declare type SpacingProps = SpacingElementProps & {
25
- space?: SpaceTypes | SpacingElementProps;
25
+ space?: SpaceType | SpacingElementProps;
26
+ };
27
+ export declare type SpacingUnknownProps = Record<string, unknown>;
28
+ export declare type StyleObjectProps = SpacingProps & {
29
+ maxWidth?: string;
30
+ maxHeight?: string;
31
+ width?: string;
32
+ height?: string;
26
33
  };
27
34
  /**
28
35
  * @deprecated Use SpacingElementProps instead
@@ -1,10 +1,13 @@
1
1
  /// <reference types="react" />
2
- export declare function useTableAccordion({ children, className, props, expanded, disabled, noAnimation, }: {
2
+ export declare function useTableAccordion({ children, className, props, expanded, disabled, noAnimation, onClick, onOpened, onClosed, }: {
3
3
  children: any;
4
4
  className: any;
5
5
  props: any;
6
6
  expanded: any;
7
7
  disabled: any;
8
8
  noAnimation: any;
9
+ onClick: any;
10
+ onOpened: any;
11
+ onClosed: any;
9
12
  }): JSX.Element;
10
13
  export declare function TableAccordionToggleButton(): JSX.Element;
@@ -25,7 +25,10 @@ export function useTableAccordion(_ref) {
25
25
  props = _ref.props,
26
26
  expanded = _ref.expanded,
27
27
  disabled = _ref.disabled,
28
- noAnimation = _ref.noAnimation;
28
+ noAnimation = _ref.noAnimation,
29
+ onClick = _ref.onClick,
30
+ onOpened = _ref.onOpened,
31
+ onClosed = _ref.onClosed;
29
32
  var tableContext = React.useContext(TableContext);
30
33
 
31
34
  var _React$useState = React.useState(function () {
@@ -114,7 +117,9 @@ export function useTableAccordion(_ref) {
114
117
  trIsOpen: trIsOpen,
115
118
  noAnimation: noAnimation,
116
119
  countTds: countTds,
117
- hasAccordionContent: hasAccordionContent
120
+ hasAccordionContent: hasAccordionContent,
121
+ onOpened: onOpened,
122
+ onClosed: onClosed
118
123
  }
119
124
  }, React.createElement("tr", _extends({
120
125
  tabIndex: accordionContent && !disabled ? 0 : undefined,
@@ -152,6 +157,7 @@ export function useTableAccordion(_ref) {
152
157
  if (document.activeElement !== target && target.tagName !== 'INPUT' && !hasSelectedText()) {
153
158
  setOpen(!trIsOpen);
154
159
  setHadClick(true);
160
+ onClick === null || onClick === void 0 ? void 0 : onClick(event);
155
161
  }
156
162
  }
157
163
  }
@@ -23,6 +23,7 @@ export default function TableAccordionContent(componentProps) {
23
23
  var allProps = (_React$useContext = React.useContext(TableContext)) === null || _React$useContext === void 0 ? void 0 : _React$useContext.allProps;
24
24
  var trContext = React.useContext(TrContext);
25
25
  var innerRef = React.useRef(null);
26
+ var trRef = React.useRef(null);
26
27
 
27
28
  var _React$useState = React.useState(null),
28
29
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -33,7 +34,24 @@ export default function TableAccordionContent(componentProps) {
33
34
  open: Boolean(expanded || (trContext === null || trContext === void 0 ? void 0 : trContext.trIsOpen)),
34
35
  animate: Boolean(!noAnimation && !(trContext !== null && trContext !== void 0 && trContext.noAnimation)),
35
36
  onOpen: function onOpen(state) {
36
- return setAriaLive(state ? true : null);
37
+ setAriaLive(state ? true : null);
38
+ },
39
+ onAnimationEnd: function onAnimationEnd(state) {
40
+ var _trContext$onOpened, _trContext$onClosed;
41
+
42
+ var event = {
43
+ target: trRef.current
44
+ };
45
+
46
+ switch (state) {
47
+ case 'opened':
48
+ (_trContext$onOpened = trContext.onOpened) === null || _trContext$onOpened === void 0 ? void 0 : _trContext$onOpened.call(trContext, event);
49
+ break;
50
+
51
+ case 'closed':
52
+ (_trContext$onClosed = trContext.onClosed) === null || _trContext$onClosed === void 0 ? void 0 : _trContext$onClosed.call(trContext, event);
53
+ break;
54
+ }
37
55
  }
38
56
  }),
39
57
  isInDOM = _useHeightAnimation.isInDOM,
@@ -45,7 +63,8 @@ export default function TableAccordionContent(componentProps) {
45
63
  "aria-hidden": !isInDOM,
46
64
  hidden: isInDOM ? undefined : true,
47
65
  role: isInDOM ? 'row' : undefined,
48
- className: classnames('dnb-table__tr__accordion_content', className, isInDOM && "dnb-table__tr dnb-table__tr__accordion_content--expanded", isAnimating && 'dnb-table__tr__accordion_content--animating', isVisibleParallax && 'dnb-table__tr__accordion_content--parallax')
66
+ className: classnames('dnb-table__tr__accordion_content', className, isInDOM && "dnb-table__tr dnb-table__tr__accordion_content--expanded", isAnimating && 'dnb-table__tr__accordion_content--animating', isVisibleParallax && 'dnb-table__tr__accordion_content--parallax'),
67
+ ref: trRef
49
68
  }, props), React.createElement("td", {
50
69
  role: isInDOM ? 'cell' : undefined,
51
70
  colSpan: countTds,
@@ -12,19 +12,37 @@ export declare type TableTrProps = {
12
12
  noWrap?: boolean;
13
13
  /**
14
14
  * Set true to render the tr initially as expanded
15
+ * Is part of the accordion feature and needs to be enabled with `accordion` prop in main Table
15
16
  * Default: false
16
17
  */
17
18
  expanded?: boolean;
18
19
  /**
19
20
  * Set true to disable the tr to be accessible as an interactive element
21
+ * Is part of the accordion feature and needs to be enabled with `accordion` prop in main Table
20
22
  * Default: false
21
23
  */
22
24
  disabled?: boolean;
23
25
  /**
24
26
  * Set to true to skip animation
27
+ * Is part of the accordion feature and needs to be enabled with `accordion` prop in main Table
25
28
  * Default: false
26
29
  */
27
30
  noAnimation?: boolean;
31
+ /**
32
+ * Will emit when user clicks/expands the table row
33
+ * Is part of the accordion feature and needs to be enabled with `accordion` prop in main Table
34
+ */
35
+ onClick?: (event?: React.SyntheticEvent) => void;
36
+ /**
37
+ * Will emit when table row is expanded
38
+ * Is part of the accordion feature and needs to be enabled with `accordion` prop in main Table
39
+ */
40
+ onOpened?: (event?: React.SyntheticEvent) => void;
41
+ /**
42
+ * Will emit when table row is closed (after it was open)
43
+ * Is part of the accordion feature and needs to be enabled with `accordion` prop in main Table
44
+ */
45
+ onClosed?: (event?: React.SyntheticEvent) => void;
28
46
  /**
29
47
  * The content of the component.
30
48
  */
@@ -1,7 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- var _excluded = ["variant", "noWrap", "expanded", "disabled", "noAnimation", "children", "className"];
4
+ var _excluded = ["variant", "noWrap", "expanded", "disabled", "noAnimation", "onClick", "onOpened", "onClosed", "children", "className"];
5
5
  import React from 'react';
6
6
  import classnames from 'classnames';
7
7
  import { useTableAccordion } from './TableAccordion';
@@ -12,6 +12,9 @@ export default function Tr(componentProps) {
12
12
  expanded = componentProps.expanded,
13
13
  disabled = componentProps.disabled,
14
14
  noAnimation = componentProps.noAnimation,
15
+ onClick = componentProps.onClick,
16
+ onOpened = componentProps.onOpened,
17
+ onClosed = componentProps.onClosed,
15
18
  children = componentProps.children,
16
19
  _className = componentProps.className,
17
20
  props = _objectWithoutProperties(componentProps, _excluded);
@@ -28,7 +31,10 @@ export default function Tr(componentProps) {
28
31
  props: props,
29
32
  expanded: expanded,
30
33
  disabled: disabled,
31
- noAnimation: noAnimation
34
+ noAnimation: noAnimation,
35
+ onClick: onClick,
36
+ onOpened: onOpened,
37
+ onClosed: onClosed
32
38
  });
33
39
 
34
40
  if (accordionTr) {
@@ -198,4 +198,8 @@
198
198
  margin-left: 0.5rem;
199
199
  }
200
200
  }
201
+
202
+ & > thead > &--no-wrap &__sort-button {
203
+ white-space: nowrap;
204
+ }
201
205
  }
@@ -12,18 +12,14 @@
12
12
  height: 0;
13
13
  }
14
14
 
15
- // Target th because of Safari transparent issue
16
- tr.sticky:not(.css-position) th {
17
- position: relative;
18
- z-index: 3; // over borders and TDs
15
+ tr.sticky {
16
+ position: sticky;
17
+ z-index: 4; // over borders and TDs
19
18
 
20
- will-change: transform;
21
19
  transform: translate3d(0, var(--table-offset, 0), 0);
22
20
  }
23
21
 
24
22
  tr.sticky.css-position {
25
- position: sticky;
26
- z-index: 3; // over borders and TDs
27
23
  top: var(--table-top, 0); // is set by "stickyOffset" prop
28
24
  }
29
25
 
@@ -25,7 +25,8 @@
25
25
  tbody
26
26
  &__tr#{&}__tr--has-accordion-content:not(#{&}__tr--expanded):nth-last-child(2) {
27
27
  // use clip-path, because border-radius does not clip on tr's
28
- clip-path: inset(0 round 0.5rem 0.5rem 0 0);
28
+ // use "-1rem" to add room for sticky shadow
29
+ clip-path: inset(0 0 -1rem 0 round 0.5rem 0.5rem 0 0);
29
30
  }
30
31
  &--outline tbody &__tr:last-of-type,
31
32
  &--outline