@dnb/eufemia 9.23.0-beta.4 → 9.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -18
- package/cjs/components/avatar/Avatar.d.ts +6 -5
- package/cjs/components/avatar/Avatar.js +4 -8
- package/cjs/components/breadcrumb/Breadcrumb.d.ts +0 -6
- package/cjs/components/breadcrumb/Breadcrumb.js +1 -7
- package/cjs/components/dialog/Dialog.d.ts +2 -1
- package/cjs/components/dialog/Dialog.js +79 -51
- package/cjs/components/dialog/DialogContent.d.ts +1 -1
- package/cjs/components/dialog/DialogContent.js +50 -12
- package/cjs/components/dialog/parts/DialogAction.d.ts +34 -0
- package/cjs/components/dialog/parts/DialogAction.js +136 -0
- package/cjs/components/dialog/style/_dialog.scss +152 -72
- package/cjs/components/dialog/style/dnb-dialog.css +366 -200
- package/cjs/components/dialog/style/dnb-dialog.min.css +1 -1
- package/cjs/components/dialog/types.d.ts +20 -2
- package/cjs/components/drawer/Drawer.js +2 -1
- package/cjs/components/drawer/style/dnb-drawer.css +191 -101
- package/cjs/components/drawer/style/dnb-drawer.min.css +1 -1
- package/cjs/components/form-status/FormStatus.d.ts +19 -2
- package/cjs/components/form-status/FormStatus.js +27 -3
- package/cjs/components/form-status/style/themes/dnb-form-status-theme-ui.css +16 -0
- package/cjs/components/form-status/style/themes/dnb-form-status-theme-ui.min.css +1 -1
- package/cjs/components/form-status/style/themes/dnb-form-status-theme-ui.scss +7 -0
- package/cjs/components/info-card/InfoCard.d.ts +0 -9
- package/cjs/components/info-card/InfoCard.js +2 -11
- package/cjs/components/info-card/style/_info-card.scss +3 -0
- package/cjs/components/info-card/style/dnb-info-card.css +4 -1
- package/cjs/components/info-card/style/dnb-info-card.min.css +1 -1
- package/cjs/components/modal/Modal.d.ts +1 -0
- package/cjs/components/modal/Modal.js +1 -1
- package/cjs/components/modal/ModalContent.js +13 -5
- package/cjs/components/modal/parts/CloseButton.d.ts +1 -0
- package/cjs/components/modal/style/_modal.scss +7 -0
- package/cjs/components/modal/style/dnb-modal.css +191 -101
- package/cjs/components/modal/style/dnb-modal.min.css +1 -1
- package/cjs/components/modal/types.d.ts +9 -1
- package/cjs/components/number-format/NumberFormat.d.ts +7 -1
- package/cjs/components/number-format/NumberFormat.js +5 -1
- package/cjs/components/number-format/NumberUtils.d.ts +12 -3
- package/cjs/components/number-format/NumberUtils.js +106 -7
- package/cjs/components/tabs/Tabs.js +104 -69
- package/cjs/components/tabs/style/_tabs.scss +10 -35
- package/cjs/components/tabs/style/dnb-tabs.css +13 -25
- package/cjs/components/tabs/style/dnb-tabs.min.css +1 -1
- package/cjs/components/tag/Tag.d.ts +5 -6
- package/cjs/components/tag/Tag.js +3 -8
- package/cjs/components/tag/style/_tag.scss +10 -6
- package/cjs/components/tag/style/dnb-tag.css +13 -5
- package/cjs/components/tag/style/dnb-tag.min.css +1 -1
- package/cjs/fragments/drawer-list/DrawerList.js +1 -1
- package/cjs/fragments/drawer-list/DrawerListHelpers.js +3 -1
- package/cjs/shared/Context.d.ts +2 -0
- package/cjs/shared/Context.js +1 -0
- package/cjs/shared/Eufemia.js +1 -1
- package/cjs/shared/hooks/usePropsWithContext.js +1 -1
- package/cjs/shared/locales/en-GB.d.ts +4 -0
- package/cjs/shared/locales/en-GB.js +4 -0
- package/cjs/shared/locales/en-US.d.ts +4 -0
- package/cjs/shared/locales/index.d.ts +8 -0
- package/cjs/shared/locales/nb-NO.d.ts +4 -0
- package/cjs/shared/locales/nb-NO.js +4 -0
- package/cjs/shared/useTranslation.d.ts +1 -0
- package/cjs/style/dnb-ui-components.css +221 -132
- package/cjs/style/dnb-ui-components.min.css +3 -3
- package/cjs/style/themes/theme-open-banking/dnb-theme-open-banking.css +16 -0
- package/cjs/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
- package/cjs/style/themes/theme-ui/dnb-theme-ui.css +16 -0
- package/cjs/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
- package/components/avatar/Avatar.d.ts +6 -5
- package/components/avatar/Avatar.js +4 -8
- package/components/breadcrumb/Breadcrumb.d.ts +0 -6
- package/components/breadcrumb/Breadcrumb.js +1 -7
- package/components/dialog/Dialog.d.ts +2 -1
- package/components/dialog/Dialog.js +78 -52
- package/components/dialog/DialogContent.d.ts +1 -1
- package/components/dialog/DialogContent.js +46 -9
- package/components/dialog/parts/DialogAction.d.ts +34 -0
- package/components/dialog/parts/DialogAction.js +96 -0
- package/components/dialog/style/_dialog.scss +152 -72
- package/components/dialog/style/dnb-dialog.css +366 -200
- package/components/dialog/style/dnb-dialog.min.css +1 -1
- package/components/dialog/types.d.ts +20 -2
- package/components/drawer/Drawer.js +2 -1
- package/components/drawer/style/dnb-drawer.css +191 -101
- package/components/drawer/style/dnb-drawer.min.css +1 -1
- package/components/form-status/FormStatus.d.ts +19 -2
- package/components/form-status/FormStatus.js +23 -2
- package/components/form-status/style/themes/dnb-form-status-theme-ui.css +16 -0
- package/components/form-status/style/themes/dnb-form-status-theme-ui.min.css +1 -1
- package/components/form-status/style/themes/dnb-form-status-theme-ui.scss +7 -0
- package/components/info-card/InfoCard.d.ts +0 -9
- package/components/info-card/InfoCard.js +2 -11
- package/components/info-card/style/_info-card.scss +3 -0
- package/components/info-card/style/dnb-info-card.css +4 -1
- package/components/info-card/style/dnb-info-card.min.css +1 -1
- package/components/modal/Modal.d.ts +1 -0
- package/components/modal/Modal.js +1 -1
- package/components/modal/ModalContent.js +13 -5
- package/components/modal/parts/CloseButton.d.ts +1 -0
- package/components/modal/style/_modal.scss +7 -0
- package/components/modal/style/dnb-modal.css +191 -101
- package/components/modal/style/dnb-modal.min.css +1 -1
- package/components/modal/types.d.ts +9 -1
- package/components/number-format/NumberFormat.d.ts +7 -1
- package/components/number-format/NumberFormat.js +5 -1
- package/components/number-format/NumberUtils.d.ts +12 -3
- package/components/number-format/NumberUtils.js +105 -7
- package/components/tabs/Tabs.js +104 -69
- package/components/tabs/style/_tabs.scss +10 -35
- package/components/tabs/style/dnb-tabs.css +13 -25
- package/components/tabs/style/dnb-tabs.min.css +1 -1
- package/components/tag/Tag.d.ts +5 -6
- package/components/tag/Tag.js +3 -8
- package/components/tag/style/_tag.scss +10 -6
- package/components/tag/style/dnb-tag.css +13 -5
- package/components/tag/style/dnb-tag.min.css +1 -1
- package/es/components/avatar/Avatar.d.ts +6 -5
- package/es/components/avatar/Avatar.js +5 -9
- package/es/components/breadcrumb/Breadcrumb.d.ts +0 -6
- package/es/components/breadcrumb/Breadcrumb.js +1 -7
- package/es/components/dialog/Dialog.d.ts +2 -1
- package/es/components/dialog/Dialog.js +50 -22
- package/es/components/dialog/DialogContent.d.ts +1 -1
- package/es/components/dialog/DialogContent.js +40 -8
- package/es/components/dialog/parts/DialogAction.d.ts +34 -0
- package/es/components/dialog/parts/DialogAction.js +82 -0
- package/es/components/dialog/style/_dialog.scss +152 -72
- package/es/components/dialog/style/dnb-dialog.css +366 -200
- package/es/components/dialog/style/dnb-dialog.min.css +1 -1
- package/es/components/dialog/types.d.ts +20 -2
- package/es/components/drawer/Drawer.js +2 -1
- package/es/components/drawer/style/dnb-drawer.css +191 -101
- package/es/components/drawer/style/dnb-drawer.min.css +1 -1
- package/es/components/form-status/FormStatus.d.ts +19 -2
- package/es/components/form-status/FormStatus.js +21 -2
- package/es/components/form-status/style/themes/dnb-form-status-theme-ui.css +16 -0
- package/es/components/form-status/style/themes/dnb-form-status-theme-ui.min.css +1 -1
- package/es/components/form-status/style/themes/dnb-form-status-theme-ui.scss +7 -0
- package/es/components/info-card/InfoCard.d.ts +0 -9
- package/es/components/info-card/InfoCard.js +2 -11
- package/es/components/info-card/style/_info-card.scss +3 -0
- package/es/components/info-card/style/dnb-info-card.css +4 -1
- package/es/components/info-card/style/dnb-info-card.min.css +1 -1
- package/es/components/modal/Modal.d.ts +1 -0
- package/es/components/modal/Modal.js +1 -1
- package/es/components/modal/ModalContent.js +13 -6
- package/es/components/modal/parts/CloseButton.d.ts +1 -0
- package/es/components/modal/style/_modal.scss +7 -0
- package/es/components/modal/style/dnb-modal.css +191 -101
- package/es/components/modal/style/dnb-modal.min.css +1 -1
- package/es/components/modal/types.d.ts +9 -1
- package/es/components/number-format/NumberFormat.d.ts +7 -1
- package/es/components/number-format/NumberFormat.js +5 -1
- package/es/components/number-format/NumberUtils.d.ts +12 -3
- package/es/components/number-format/NumberUtils.js +101 -7
- package/es/components/tabs/Tabs.js +53 -23
- package/es/components/tabs/style/_tabs.scss +10 -35
- package/es/components/tabs/style/dnb-tabs.css +13 -25
- package/es/components/tabs/style/dnb-tabs.min.css +1 -1
- package/es/components/tag/Tag.d.ts +5 -6
- package/es/components/tag/Tag.js +3 -8
- package/es/components/tag/style/_tag.scss +10 -6
- package/es/components/tag/style/dnb-tag.css +13 -5
- package/es/components/tag/style/dnb-tag.min.css +1 -1
- package/es/fragments/drawer-list/DrawerList.js +1 -1
- package/es/fragments/drawer-list/DrawerListHelpers.js +3 -1
- package/es/shared/Context.d.ts +2 -0
- package/es/shared/Context.js +1 -0
- package/es/shared/Eufemia.js +1 -1
- package/es/shared/hooks/usePropsWithContext.js +1 -1
- package/es/shared/locales/en-GB.d.ts +4 -0
- package/es/shared/locales/en-GB.js +4 -0
- package/es/shared/locales/en-US.d.ts +4 -0
- package/es/shared/locales/index.d.ts +8 -0
- package/es/shared/locales/nb-NO.d.ts +4 -0
- package/es/shared/locales/nb-NO.js +4 -0
- package/es/shared/useTranslation.d.ts +1 -0
- package/es/style/dnb-ui-components.css +221 -132
- package/es/style/dnb-ui-components.min.css +3 -3
- package/es/style/themes/theme-open-banking/dnb-theme-open-banking.css +16 -0
- package/es/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
- package/es/style/themes/theme-ui/dnb-theme-ui.css +16 -0
- package/es/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
- package/esm/dnb-ui-basis.min.mjs +1 -1
- package/esm/dnb-ui-components.min.mjs +1 -1
- package/esm/dnb-ui-elements.min.mjs +1 -1
- package/esm/dnb-ui-extensions.min.mjs +3 -3
- package/esm/dnb-ui-lib.min.mjs +3 -3
- package/esm/dnb-ui-web-components.min.mjs +2 -2
- package/fragments/drawer-list/DrawerList.js +1 -1
- package/fragments/drawer-list/DrawerListHelpers.js +3 -1
- package/package.json +1 -1
- package/shared/Context.d.ts +2 -0
- package/shared/Context.js +1 -0
- package/shared/Eufemia.js +1 -1
- package/shared/hooks/usePropsWithContext.js +1 -1
- package/shared/locales/en-GB.d.ts +4 -0
- package/shared/locales/en-GB.js +4 -0
- package/shared/locales/en-US.d.ts +4 -0
- package/shared/locales/index.d.ts +8 -0
- package/shared/locales/nb-NO.d.ts +4 -0
- package/shared/locales/nb-NO.js +4 -0
- package/shared/useTranslation.d.ts +1 -0
- package/style/dnb-ui-components.css +221 -132
- package/style/dnb-ui-components.min.css +3 -3
- package/style/themes/theme-open-banking/dnb-theme-open-banking.css +16 -0
- package/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
- package/style/themes/theme-ui/dnb-theme-ui.css +16 -0
- package/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
- package/umd/dnb-ui-basis.min.js +1 -1
- package/umd/dnb-ui-components.min.js +3 -3
- package/umd/dnb-ui-elements.min.js +1 -1
- package/umd/dnb-ui-extensions.min.js +2 -2
- package/umd/dnb-ui-lib.min.js +4 -4
- package/umd/dnb-ui-web-components.min.js +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
-
const _excluded = ["id", "value", "prefix", "suffix", "children", "currency", "currency_display", "currency_position", "ban", "nin", "phone", "org", "percent", "link", "tooltip", "skeleton", "options", "locale", "decimals", "omit_rounding", "clean", "selectall", "copy_selection", "clean_copy_value", "element", "class", "className"];
|
|
4
|
+
const _excluded = ["id", "value", "prefix", "suffix", "children", "currency", "currency_display", "currency_position", "compact", "ban", "nin", "phone", "org", "percent", "link", "tooltip", "skeleton", "options", "locale", "decimals", "omit_rounding", "clean", "selectall", "copy_selection", "clean_copy_value", "element", "class", "className"];
|
|
5
5
|
|
|
6
6
|
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; }
|
|
7
7
|
|
|
@@ -129,6 +129,7 @@ export default class NumberFormat extends React.PureComponent {
|
|
|
129
129
|
currency,
|
|
130
130
|
currency_display,
|
|
131
131
|
currency_position,
|
|
132
|
+
compact,
|
|
132
133
|
ban,
|
|
133
134
|
nin,
|
|
134
135
|
phone,
|
|
@@ -165,6 +166,7 @@ export default class NumberFormat extends React.PureComponent {
|
|
|
165
166
|
currency_display,
|
|
166
167
|
currency_position,
|
|
167
168
|
omit_currency_sign: this.state.omitCurrencySign,
|
|
169
|
+
compact,
|
|
168
170
|
ban,
|
|
169
171
|
nin,
|
|
170
172
|
phone,
|
|
@@ -280,6 +282,7 @@ _defineProperty(NumberFormat, "defaultProps", {
|
|
|
280
282
|
currency: null,
|
|
281
283
|
currency_display: null,
|
|
282
284
|
currency_position: null,
|
|
285
|
+
compact: null,
|
|
283
286
|
ban: null,
|
|
284
287
|
nin: null,
|
|
285
288
|
phone: null,
|
|
@@ -311,6 +314,7 @@ process.env.NODE_ENV !== "production" ? NumberFormat.propTypes = _objectSpread(_
|
|
|
311
314
|
currency: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
312
315
|
currency_display: PropTypes.string,
|
|
313
316
|
currency_position: PropTypes.oneOf(['auto', 'before', 'after']),
|
|
317
|
+
compact: PropTypes.oneOfType([PropTypes.oneOf(['short', 'long']), PropTypes.bool]),
|
|
314
318
|
ban: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
315
319
|
nin: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
316
320
|
phone: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
@@ -34,6 +34,9 @@ export interface formatOptionParams {
|
|
|
34
34
|
/** Should the number be cleaned */
|
|
35
35
|
clean?: boolean;
|
|
36
36
|
|
|
37
|
+
/** shortens any number or currency including an abbreviation. You can combine `compact` with `currency`. It gives you zero decimal by default `decimals={0}`. Use either a boolean, or a string with "short" or "long" */
|
|
38
|
+
compact?: boolean | 'short' | 'long';
|
|
39
|
+
|
|
37
40
|
/** How many decimals */
|
|
38
41
|
decimals?: number;
|
|
39
42
|
|
|
@@ -53,13 +56,19 @@ export interface formatOptionParams {
|
|
|
53
56
|
/** Currency code (ISO 4217) or `true` to use the default, `NOK`. */
|
|
54
57
|
currency?: string | boolean;
|
|
55
58
|
|
|
56
|
-
/** Intl.NumberFormat currency option – you can use false or empty string to hide the sign/name */
|
|
57
|
-
currency_display?:
|
|
59
|
+
/** Intl.NumberFormat currency option – you can use false or empty string to hide the sign/name. Defaults to narrowSymbol when the locale is no else we default to code. */
|
|
60
|
+
currency_display?:
|
|
61
|
+
| boolean
|
|
62
|
+
| ''
|
|
63
|
+
| 'code'
|
|
64
|
+
| 'name'
|
|
65
|
+
| 'symbol'
|
|
66
|
+
| 'narrowSymbol';
|
|
58
67
|
/** currency option */
|
|
59
68
|
currency_position?: formatCurrencyPosition;
|
|
60
69
|
/** hides the currency sign */
|
|
61
70
|
omit_currency_sign?: boolean;
|
|
62
|
-
/** will remove all extra signs,like a currency sign or percent sign for the cleanedValue return when returnAria is true */
|
|
71
|
+
/** will remove all extra signs, like a currency sign or percent sign for the cleanedValue return when returnAria is true */
|
|
63
72
|
clean_copy_value?: boolean;
|
|
64
73
|
|
|
65
74
|
/** Intl.NumberFormat options (NumberFormatOptions) */
|
|
@@ -13,6 +13,7 @@ const NUMBER_CHARS = '\\-0-9,.';
|
|
|
13
13
|
export const format = (value, {
|
|
14
14
|
locale = null,
|
|
15
15
|
clean = false,
|
|
16
|
+
compact = null,
|
|
16
17
|
phone = null,
|
|
17
18
|
org = null,
|
|
18
19
|
ban = null,
|
|
@@ -50,7 +51,7 @@ export const format = (value, {
|
|
|
50
51
|
|
|
51
52
|
if (parseFloat(decimals) >= 0) {
|
|
52
53
|
value = formatDecimals(value, decimals, omit_rounding, opts);
|
|
53
|
-
} else {
|
|
54
|
+
} else if (typeof opts.maximumFractionDigits === 'undefined') {
|
|
54
55
|
opts.maximumFractionDigits = 20;
|
|
55
56
|
}
|
|
56
57
|
|
|
@@ -105,6 +106,13 @@ export const format = (value, {
|
|
|
105
106
|
} else if (isTrue(currency) || typeof currency === 'string') {
|
|
106
107
|
type = 'currency';
|
|
107
108
|
opts.currency = opts.currency || (isTrue(currency) ? CURRENCY : currency);
|
|
109
|
+
handleCompactBeforeDisplay({
|
|
110
|
+
value,
|
|
111
|
+
locale,
|
|
112
|
+
compact,
|
|
113
|
+
decimals,
|
|
114
|
+
opts
|
|
115
|
+
});
|
|
108
116
|
|
|
109
117
|
if (decimals === null) {
|
|
110
118
|
decimals = 2;
|
|
@@ -118,7 +126,7 @@ export const format = (value, {
|
|
|
118
126
|
}
|
|
119
127
|
|
|
120
128
|
opts.style = 'currency';
|
|
121
|
-
opts.currencyDisplay = getFallbackCurrencyDisplay(locale, opts.
|
|
129
|
+
opts.currencyDisplay = getFallbackCurrencyDisplay(locale, opts.currencyDisplay || currency_display);
|
|
122
130
|
|
|
123
131
|
if (typeof opts.minimumFractionDigits === 'undefined' && String(value).indexOf('.') === -1 && cleanedNumber % 1 === 0) {
|
|
124
132
|
opts.minimumFractionDigits = 0;
|
|
@@ -166,6 +174,11 @@ export const format = (value, {
|
|
|
166
174
|
}
|
|
167
175
|
}
|
|
168
176
|
|
|
177
|
+
handleCompactBeforeAria({
|
|
178
|
+
value,
|
|
179
|
+
compact,
|
|
180
|
+
opts
|
|
181
|
+
});
|
|
169
182
|
aria = formatNumber(cleanedNumber, locale, _objectSpread(_objectSpread({
|
|
170
183
|
minimumFractionDigits: 0,
|
|
171
184
|
maximumFractionDigits: 2
|
|
@@ -181,12 +194,21 @@ export const format = (value, {
|
|
|
181
194
|
aria = prepareMinus(aria, locale);
|
|
182
195
|
}
|
|
183
196
|
} else {
|
|
197
|
+
handleCompactBeforeDisplay({
|
|
198
|
+
value,
|
|
199
|
+
locale,
|
|
200
|
+
compact,
|
|
201
|
+
decimals,
|
|
202
|
+
opts
|
|
203
|
+
});
|
|
184
204
|
display = formatNumber(value, locale, opts);
|
|
185
205
|
display = prepareMinus(display, locale);
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
206
|
+
handleCompactBeforeAria({
|
|
207
|
+
value,
|
|
208
|
+
compact,
|
|
209
|
+
opts
|
|
210
|
+
});
|
|
211
|
+
aria = formatNumber(value, locale, opts);
|
|
190
212
|
aria = enhanceSR(value, aria, locale);
|
|
191
213
|
}
|
|
192
214
|
|
|
@@ -213,7 +235,7 @@ export const format = (value, {
|
|
|
213
235
|
});
|
|
214
236
|
} else {
|
|
215
237
|
const thousandsSeparator = getThousandsSeparator(locale);
|
|
216
|
-
cleanedValue = display.replace(new RegExp(`${thousandsSeparator}(?=\\d{3})`, 'g'), '');
|
|
238
|
+
cleanedValue = String(display).replace(new RegExp(`${thousandsSeparator}(?=\\d{3})`, 'g'), '');
|
|
217
239
|
}
|
|
218
240
|
|
|
219
241
|
return {
|
|
@@ -732,4 +754,76 @@ function formatToParts({
|
|
|
732
754
|
return [{
|
|
733
755
|
value: number
|
|
734
756
|
}];
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
function handleCompactBeforeDisplay({
|
|
760
|
+
value,
|
|
761
|
+
locale,
|
|
762
|
+
compact,
|
|
763
|
+
decimals = 0,
|
|
764
|
+
opts
|
|
765
|
+
} = {}) {
|
|
766
|
+
if (!canHandleCompact({
|
|
767
|
+
value,
|
|
768
|
+
compact
|
|
769
|
+
})) {
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
value = parseInt(Math.abs(value));
|
|
774
|
+
opts.notation = 'compact';
|
|
775
|
+
|
|
776
|
+
if (isTrue(compact) && locale && /(no|nb|nn)$/i.test(locale)) {
|
|
777
|
+
opts.compactDisplay = Math.abs(value) < 1000000 ? 'long' : 'short';
|
|
778
|
+
} else {
|
|
779
|
+
opts.compactDisplay = !isTrue(compact) ? compact : 'short';
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
if (typeof opts.maximumSignificantDigits === 'undefined') {
|
|
783
|
+
if (isNaN(parseFloat(decimals))) {
|
|
784
|
+
decimals = 0;
|
|
785
|
+
} else {
|
|
786
|
+
decimals = parseFloat(decimals);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
const ref = String(value).length % 3;
|
|
790
|
+
|
|
791
|
+
if (ref === 2) {
|
|
792
|
+
decimals += 1;
|
|
793
|
+
} else if (ref === 0) {
|
|
794
|
+
decimals += 2;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
opts.maximumSignificantDigits = decimals + 1;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
function handleCompactBeforeAria({
|
|
802
|
+
value,
|
|
803
|
+
compact,
|
|
804
|
+
opts
|
|
805
|
+
}) {
|
|
806
|
+
if (!canHandleCompact({
|
|
807
|
+
value,
|
|
808
|
+
compact
|
|
809
|
+
})) {
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
opts.compactDisplay = 'long';
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
function canHandleCompact({
|
|
817
|
+
value,
|
|
818
|
+
compact
|
|
819
|
+
}) {
|
|
820
|
+
if (IS_IE11) {
|
|
821
|
+
return false;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
if (compact && Math.abs(value) >= 1000) {
|
|
825
|
+
return true;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
return false;
|
|
735
829
|
}
|
|
@@ -134,36 +134,46 @@ export default class Tabs extends React.PureComponent {
|
|
|
134
134
|
_defineProperty(this, "init", () => {
|
|
135
135
|
if (this._isMounted) {
|
|
136
136
|
this.addScrollBehaviour();
|
|
137
|
-
this.
|
|
138
|
-
this.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
});
|
|
142
|
-
this.scrollToTab({
|
|
143
|
-
type: 'selected',
|
|
144
|
-
behavior: 'auto'
|
|
137
|
+
const hasScrollbar = this.hasScrollbar();
|
|
138
|
+
const hasLastPosition = this.hasLastPosition();
|
|
139
|
+
this.setScrollbarState({
|
|
140
|
+
hasScrollbar
|
|
145
141
|
});
|
|
146
142
|
|
|
143
|
+
if (hasLastPosition) {
|
|
144
|
+
this.setLeftPosition(this.state.lastPosition);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (hasScrollbar) {
|
|
148
|
+
this.scrollToTab({
|
|
149
|
+
type: 'selected',
|
|
150
|
+
behavior: hasLastPosition ? 'smooth' : 'auto'
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
147
154
|
if (this.hasLastUsedTab() !== null) {
|
|
148
155
|
this.setState(null, this.setFocusOnTabButton);
|
|
149
156
|
}
|
|
150
157
|
}
|
|
151
158
|
});
|
|
152
159
|
|
|
153
|
-
_defineProperty(this, "setScrollbarState", (
|
|
154
|
-
|
|
155
|
-
|
|
160
|
+
_defineProperty(this, "setScrollbarState", ({
|
|
161
|
+
hasScrollbar = this.hasScrollbar()
|
|
162
|
+
} = {}) => {
|
|
156
163
|
if (hasScrollbar !== this.state.hasScrollbar) {
|
|
157
164
|
this.setState({
|
|
158
165
|
hasScrollbar
|
|
159
166
|
});
|
|
160
167
|
}
|
|
161
|
-
|
|
162
|
-
return hasScrollbar;
|
|
163
168
|
});
|
|
164
169
|
|
|
165
170
|
_defineProperty(this, "onResizeHandler", () => {
|
|
166
|
-
|
|
171
|
+
const hasScrollbar = this.hasScrollbar();
|
|
172
|
+
this.setScrollbarState({
|
|
173
|
+
hasScrollbar
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
if (hasScrollbar) {
|
|
167
177
|
this.scrollToTab({
|
|
168
178
|
type: 'selected'
|
|
169
179
|
});
|
|
@@ -482,11 +492,11 @@ export default class Tabs extends React.PureComponent {
|
|
|
482
492
|
}, rest), React.createElement(ScrollNavButton, {
|
|
483
493
|
onMouseDown: this.openPrevTab,
|
|
484
494
|
icon: "chevron_left",
|
|
485
|
-
className: classnames(hasScrollbar && typeof this.state.isFirst !== 'undefined' && 'dnb-tabs__scroll-nav-button--visible', this.state.isFirst && 'dnb-tabs__scroll-nav-button--hide')
|
|
495
|
+
className: classnames(hasScrollbar && (typeof this.state.isFirst !== 'undefined' || this.hasLastPosition()) && 'dnb-tabs__scroll-nav-button--visible', this.state.isFirst && 'dnb-tabs__scroll-nav-button--hide')
|
|
486
496
|
}), children, React.createElement(ScrollNavButton, {
|
|
487
497
|
onMouseDown: this.openNextTab,
|
|
488
498
|
icon: "chevron_right",
|
|
489
|
-
className: classnames(hasScrollbar && typeof this.state.isLast !== 'undefined' && 'dnb-tabs__scroll-nav-button--visible', this.state.isLast && 'dnb-tabs__scroll-nav-button--hide')
|
|
499
|
+
className: classnames(hasScrollbar && (typeof this.state.isLast !== 'undefined' || this.hasLastPosition()) && 'dnb-tabs__scroll-nav-button--visible', this.state.isLast && 'dnb-tabs__scroll-nav-button--hide')
|
|
490
500
|
}));
|
|
491
501
|
});
|
|
492
502
|
|
|
@@ -607,6 +617,7 @@ Tip: Check out other solutions like <Tabs.Content id="unique">Your content, outs
|
|
|
607
617
|
selected_key: _selected_key,
|
|
608
618
|
focus_key: _selected_key,
|
|
609
619
|
atEdge: false,
|
|
620
|
+
lastPosition,
|
|
610
621
|
hasScrollbar: lastPosition > -1,
|
|
611
622
|
_selected_key: _selected_key,
|
|
612
623
|
_data: _props.data || _props.children,
|
|
@@ -664,12 +675,16 @@ Tip: Check out other solutions like <Tabs.Content id="unique">Your content, outs
|
|
|
664
675
|
}
|
|
665
676
|
}
|
|
666
677
|
|
|
678
|
+
hasLastPosition() {
|
|
679
|
+
return this.state.lastPosition > -1;
|
|
680
|
+
}
|
|
681
|
+
|
|
667
682
|
getLastPosition() {
|
|
668
683
|
if (typeof window !== 'undefined') {
|
|
669
684
|
try {
|
|
670
|
-
const pos = parseFloat(window.localStorage.getItem(`tabs-pos-${this._id}`))
|
|
685
|
+
const pos = parseFloat(window.localStorage.getItem(`tabs-pos-${this._id}`));
|
|
671
686
|
window.localStorage.removeItem(`tabs-pos-${this._id}`);
|
|
672
|
-
return pos;
|
|
687
|
+
return isNaN(pos) ? -1 : pos;
|
|
673
688
|
} catch (e) {
|
|
674
689
|
warn(e);
|
|
675
690
|
}
|
|
@@ -702,10 +717,10 @@ Tip: Check out other solutions like <Tabs.Content id="unique">Your content, outs
|
|
|
702
717
|
}
|
|
703
718
|
}
|
|
704
719
|
|
|
705
|
-
saveLastPosition(
|
|
720
|
+
saveLastPosition(position = this._tablistRef.current.scrollLeft) {
|
|
706
721
|
if (typeof window !== 'undefined') {
|
|
707
722
|
try {
|
|
708
|
-
window.localStorage.setItem(`tabs-pos-${this._id}`,
|
|
723
|
+
window.localStorage.setItem(`tabs-pos-${this._id}`, position);
|
|
709
724
|
} catch (e) {
|
|
710
725
|
warn(e);
|
|
711
726
|
}
|
|
@@ -722,6 +737,14 @@ Tip: Check out other solutions like <Tabs.Content id="unique">Your content, outs
|
|
|
722
737
|
}
|
|
723
738
|
}
|
|
724
739
|
|
|
740
|
+
setLeftPosition(scrollLeft) {
|
|
741
|
+
try {
|
|
742
|
+
this._tablistRef.current.style.scrollBehavior = 'auto';
|
|
743
|
+
this._tablistRef.current.scrollLeft = scrollLeft;
|
|
744
|
+
this._tablistRef.current.style.scrollBehavior = 'smooth';
|
|
745
|
+
} catch (e) {}
|
|
746
|
+
}
|
|
747
|
+
|
|
725
748
|
scrollToTab({
|
|
726
749
|
type,
|
|
727
750
|
behavior = 'smooth'
|
|
@@ -750,7 +773,15 @@ Tip: Check out other solutions like <Tabs.Content id="unique">Your content, outs
|
|
|
750
773
|
const style = window.getComputedStyle(this._tabsRef.current);
|
|
751
774
|
const margin = parseFloat(style.marginLeft);
|
|
752
775
|
let padding = margin < 0 ? parseFloat(style.paddingLeft) : 0;
|
|
753
|
-
|
|
776
|
+
|
|
777
|
+
if (!isFirst && !isLast && parseFloat(style.paddingLeft) < 16) {
|
|
778
|
+
const navButton = this._tabsRef.current.querySelector('.dnb-tabs__scroll-nav-button:first-of-type');
|
|
779
|
+
|
|
780
|
+
const additionalSpace = parseFloat(window.getComputedStyle(navButton).width) * 1.5;
|
|
781
|
+
padding += additionalSpace;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
let leftPadding = (margin < 0 ? Math.abs(margin) : 0) + padding + parseFloat(window.getComputedStyle(first).paddingLeft);
|
|
754
785
|
const offsetLeft = elem.offsetLeft;
|
|
755
786
|
const left = elem && !isFirst ? offsetLeft - leftPadding : 0;
|
|
756
787
|
|
|
@@ -1022,8 +1053,7 @@ const ScrollNavButton = props => {
|
|
|
1022
1053
|
variant: "primary",
|
|
1023
1054
|
tabIndex: "-1",
|
|
1024
1055
|
bounding: true,
|
|
1025
|
-
"aria-hidden": true
|
|
1026
|
-
icon_size: "medium"
|
|
1056
|
+
"aria-hidden": true
|
|
1027
1057
|
}, props, {
|
|
1028
1058
|
className: classnames('dnb-tabs__scroll-nav-button', props.className)
|
|
1029
1059
|
}));
|
|
@@ -58,11 +58,13 @@
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
&__scroll-nav-button {
|
|
61
|
-
position:
|
|
61
|
+
position: absolute;
|
|
62
62
|
z-index: 2;
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
right: -2px;
|
|
65
|
+
&:first-of-type {
|
|
66
|
+
left: -2px;
|
|
67
|
+
right: auto;
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
display: none; // use "none" to remove it from markup by default
|
|
@@ -155,39 +157,19 @@
|
|
|
155
157
|
padding-right: 0.5rem;
|
|
156
158
|
}
|
|
157
159
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
&:first-of-type.selected.focus,
|
|
161
|
-
&:last-of-type.focus,
|
|
162
|
-
&:last-of-type.selected {
|
|
163
|
-
transition: padding 1s #{$defaultEasing} 10ms;
|
|
164
|
-
}
|
|
160
|
+
will-change: padding;
|
|
161
|
+
transition: padding 1s #{$defaultEasing};
|
|
165
162
|
}
|
|
166
163
|
|
|
167
|
-
|
|
168
|
-
&:first-of-type {
|
|
169
|
-
margin-left: -3rem;
|
|
170
|
-
padding-left: 3rem;
|
|
171
|
-
}
|
|
172
|
-
&:last-of-type {
|
|
173
|
-
margin-right: -3rem;
|
|
174
|
-
padding-right: 3rem;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
&:first-of-type.focus,
|
|
178
|
-
&:first-of-type.selected.focus {
|
|
179
|
-
padding-left: 0;
|
|
180
|
-
|
|
164
|
+
html[data-whatinput='keyboard'] &__button__snap {
|
|
165
|
+
&:first-of-type.focus {
|
|
181
166
|
// add space so the focus ring is visible within our overflow
|
|
182
167
|
.dnb-tabs__button:focus {
|
|
183
168
|
margin-left: 0.5rem;
|
|
184
169
|
}
|
|
185
170
|
}
|
|
186
171
|
|
|
187
|
-
&:last-of-type.focus
|
|
188
|
-
&:last-of-type.selected.focus {
|
|
189
|
-
padding-right: 0;
|
|
190
|
-
|
|
172
|
+
&:last-of-type.focus {
|
|
191
173
|
// add space so the focus ring is visible within our overflow
|
|
192
174
|
/* stylelint-disable */
|
|
193
175
|
.dnb-tabs__button:focus {
|
|
@@ -197,13 +179,6 @@
|
|
|
197
179
|
}
|
|
198
180
|
}
|
|
199
181
|
|
|
200
|
-
// Do this in order to have the selected tab to be nice aligned during scrollTo
|
|
201
|
-
&--has-scrollbar &__tabs__tablist {
|
|
202
|
-
margin: 0 -2rem; // The width of the nav-button
|
|
203
|
-
padding-left: 3rem;
|
|
204
|
-
padding-right: 3rem;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
182
|
/* stylelint-disable */
|
|
208
183
|
html[data-visual-test] & &__button,
|
|
209
184
|
html[data-visual-test] & &__button__snap,
|
|
@@ -152,16 +152,17 @@
|
|
|
152
152
|
.dnb-tabs__tabs--no-border::before {
|
|
153
153
|
content: none; }
|
|
154
154
|
.dnb-tabs__scroll-nav-button {
|
|
155
|
-
position:
|
|
155
|
+
position: absolute;
|
|
156
156
|
z-index: 2;
|
|
157
|
+
right: -2px;
|
|
157
158
|
display: none;
|
|
158
159
|
opacity: 0;
|
|
159
160
|
pointer-events: none;
|
|
160
161
|
-webkit-transition: opacity 600ms ease-out;
|
|
161
162
|
transition: opacity 600ms ease-out; }
|
|
162
|
-
.dnb-tabs__scroll-nav-button
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
.dnb-tabs__scroll-nav-button:first-of-type {
|
|
164
|
+
left: -2px;
|
|
165
|
+
right: auto; }
|
|
165
166
|
.dnb-tabs__scroll-nav-button--visible {
|
|
166
167
|
display: -webkit-box;
|
|
167
168
|
display: -ms-flexbox;
|
|
@@ -230,7 +231,10 @@
|
|
|
230
231
|
display: -webkit-box;
|
|
231
232
|
display: -ms-flexbox;
|
|
232
233
|
display: flex;
|
|
233
|
-
padding: 0 1rem 0 1.5rem;
|
|
234
|
+
padding: 0 1rem 0 1.5rem;
|
|
235
|
+
will-change: padding;
|
|
236
|
+
-webkit-transition: padding 1s cubic-bezier(0.42, 0, 0, 1);
|
|
237
|
+
transition: padding 1s cubic-bezier(0.42, 0, 0, 1); }
|
|
234
238
|
@media screen and (max-width: 40em) {
|
|
235
239
|
.dnb-tabs__button__snap {
|
|
236
240
|
padding: 0 1rem; } }
|
|
@@ -238,29 +242,13 @@
|
|
|
238
242
|
padding-left: 0; }
|
|
239
243
|
.dnb-tabs__button__snap:last-of-type {
|
|
240
244
|
padding-right: 0.5rem; }
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
.dnb-tabs--has-scrollbar .dnb-tabs__button__snap:first-of-type {
|
|
245
|
-
margin-left: -3rem;
|
|
246
|
-
padding-left: 3rem; }
|
|
247
|
-
.dnb-tabs--has-scrollbar .dnb-tabs__button__snap:last-of-type {
|
|
248
|
-
margin-right: -3rem;
|
|
249
|
-
padding-right: 3rem; }
|
|
250
|
-
.dnb-tabs--has-scrollbar .dnb-tabs__button__snap:first-of-type.focus, .dnb-tabs--has-scrollbar .dnb-tabs__button__snap:first-of-type.selected.focus {
|
|
251
|
-
padding-left: 0; }
|
|
252
|
-
.dnb-tabs--has-scrollbar .dnb-tabs__button__snap:first-of-type.focus .dnb-tabs__button:focus, .dnb-tabs--has-scrollbar .dnb-tabs__button__snap:first-of-type.selected.focus .dnb-tabs__button:focus {
|
|
253
|
-
margin-left: 0.5rem; }
|
|
254
|
-
.dnb-tabs--has-scrollbar .dnb-tabs__button__snap:last-of-type.focus, .dnb-tabs--has-scrollbar .dnb-tabs__button__snap:last-of-type.selected.focus {
|
|
255
|
-
padding-right: 0;
|
|
245
|
+
html[data-whatinput='keyboard'] .dnb-tabs__button__snap:first-of-type.focus .dnb-tabs__button:focus {
|
|
246
|
+
margin-left: 0.5rem; }
|
|
247
|
+
html[data-whatinput='keyboard'] .dnb-tabs__button__snap:last-of-type.focus {
|
|
256
248
|
/* stylelint-disable */
|
|
257
249
|
/* stylelint-enable */ }
|
|
258
|
-
|
|
250
|
+
html[data-whatinput='keyboard'] .dnb-tabs__button__snap:last-of-type.focus .dnb-tabs__button:focus {
|
|
259
251
|
margin-right: 0.5rem; }
|
|
260
|
-
.dnb-tabs--has-scrollbar .dnb-tabs__tabs__tablist {
|
|
261
|
-
margin: 0 -2rem;
|
|
262
|
-
padding-left: 3rem;
|
|
263
|
-
padding-right: 3rem; }
|
|
264
252
|
html[data-visual-test] .dnb-tabs .dnb-tabs__button,
|
|
265
253
|
html[data-visual-test] .dnb-tabs .dnb-tabs__button__snap,
|
|
266
254
|
html[data-visual-test] .dnb-tabs .dnb-tabs__scroll-nav-button {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.dnb-tabs{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:rgba(0,0,0,0);-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;color:#333;color:var(--color-black-80,#333);font-family:DNB,sans-serif;font-family:var(--font-family-default);font-size:1rem;font-size:var(--font-size-small);font-style:normal;font-weight:400;font-weight:var(--font-weight-basis);line-height:1.5rem;line-height:var(--line-height-basis);margin:0;padding:0;-moz-tab-size:4;-o-tab-size:4;tab-size:4;word-break:break-word}.dnb-tabs *,.dnb-tabs :after,.dnb-tabs :before{background-repeat:no-repeat;-webkit-box-sizing:border-box;box-sizing:border-box}.dnb-tabs :after,.dnb-tabs :before{text-decoration:inherit;vertical-align:inherit}.dnb-tabs__tabs{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;position:relative;z-index:1}.dnb-tabs__tabs,.dnb-tabs__tabs.dnb-section--spacing{padding-bottom:0}.dnb-tabs__tabs__tablist{-webkit-box-flex:0;-ms-scroll-chaining:none;-webkit-overflow-scrolling:touch;-ms-overflow-style:auto;-ms-overflow-style:none;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex:0 1 auto;flex:0 1 auto;overflow-x:auto;overscroll-behavior:contain;scrollbar-color:#14555a transparent;scrollbar-color:var(--color-emerald-green) transparent;scrollbar-width:thin;scrollbar-width:none}.dnb-tabs__tabs__tablist:focus{outline:none}html[data-whatinput=keyboard] .dnb-tabs__tabs__tablist:focus{--border-color:var(--color-emerald-green);border-color:transparent;-webkit-box-shadow:0 0 0 .125rem var(--border-color);box-shadow:0 0 0 .125rem var(--border-color)}@media screen and (-ms-high-contrast:none){html[data-whatinput=keyboard] .dnb-tabs__tabs__tablist:focus{-webkit-box-shadow:0 0 0 .125rem #14555a;box-shadow:0 0 0 .125rem #14555a;-webkit-box-shadow:0 0 0 .125rem var(--color-emerald-green);box-shadow:0 0 0 .125rem var(--color-emerald-green)}}html:not([data-visual-test]) .dnb-tabs__tabs__tablist{scroll-behavior:smooth}html[data-visual-test] .dnb-tabs__tabs__tablist{scroll-behavior:auto!important}.dnb-tabs__tabs__tablist::-webkit-scrollbar{display:none}.dnb-tabs__tabs--left .dnb-tabs__tabs__tablist{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start}.dnb-tabs__tabs--right .dnb-tabs__tabs__tablist{-webkit-box-flex:1;-webkit-box-pack:end;-ms-flex-pack:end;-ms-flex:1;flex:1;justify-content:flex-end}.dnb-tabs__tabs--center .dnb-tabs__tabs__tablist{-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.dnb-tabs__tabs:before{bottom:0;content:"";height:1px;left:-100vw;position:absolute;width:100vw;z-index:-1}.dnb-tabs__tabs--no-border:before{content:none}.dnb-tabs__scroll-nav-button{display:none;opacity:0;pointer-events:none;position:
|
|
1
|
+
.dnb-tabs{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:rgba(0,0,0,0);-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;color:#333;color:var(--color-black-80,#333);font-family:DNB,sans-serif;font-family:var(--font-family-default);font-size:1rem;font-size:var(--font-size-small);font-style:normal;font-weight:400;font-weight:var(--font-weight-basis);line-height:1.5rem;line-height:var(--line-height-basis);margin:0;padding:0;-moz-tab-size:4;-o-tab-size:4;tab-size:4;word-break:break-word}.dnb-tabs *,.dnb-tabs :after,.dnb-tabs :before{background-repeat:no-repeat;-webkit-box-sizing:border-box;box-sizing:border-box}.dnb-tabs :after,.dnb-tabs :before{text-decoration:inherit;vertical-align:inherit}.dnb-tabs__tabs{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;position:relative;z-index:1}.dnb-tabs__tabs,.dnb-tabs__tabs.dnb-section--spacing{padding-bottom:0}.dnb-tabs__tabs__tablist{-webkit-box-flex:0;-ms-scroll-chaining:none;-webkit-overflow-scrolling:touch;-ms-overflow-style:auto;-ms-overflow-style:none;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex:0 1 auto;flex:0 1 auto;overflow-x:auto;overscroll-behavior:contain;scrollbar-color:#14555a transparent;scrollbar-color:var(--color-emerald-green) transparent;scrollbar-width:thin;scrollbar-width:none}.dnb-tabs__tabs__tablist:focus{outline:none}html[data-whatinput=keyboard] .dnb-tabs__tabs__tablist:focus{--border-color:var(--color-emerald-green);border-color:transparent;-webkit-box-shadow:0 0 0 .125rem var(--border-color);box-shadow:0 0 0 .125rem var(--border-color)}@media screen and (-ms-high-contrast:none){html[data-whatinput=keyboard] .dnb-tabs__tabs__tablist:focus{-webkit-box-shadow:0 0 0 .125rem #14555a;box-shadow:0 0 0 .125rem #14555a;-webkit-box-shadow:0 0 0 .125rem var(--color-emerald-green);box-shadow:0 0 0 .125rem var(--color-emerald-green)}}html:not([data-visual-test]) .dnb-tabs__tabs__tablist{scroll-behavior:smooth}html[data-visual-test] .dnb-tabs__tabs__tablist{scroll-behavior:auto!important}.dnb-tabs__tabs__tablist::-webkit-scrollbar{display:none}.dnb-tabs__tabs--left .dnb-tabs__tabs__tablist{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start}.dnb-tabs__tabs--right .dnb-tabs__tabs__tablist{-webkit-box-flex:1;-webkit-box-pack:end;-ms-flex-pack:end;-ms-flex:1;flex:1;justify-content:flex-end}.dnb-tabs__tabs--center .dnb-tabs__tabs__tablist{-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.dnb-tabs__tabs:before{bottom:0;content:"";height:1px;left:-100vw;position:absolute;width:100vw;z-index:-1}.dnb-tabs__tabs--no-border:before{content:none}.dnb-tabs__scroll-nav-button{display:none;opacity:0;pointer-events:none;position:absolute;right:-2px;-webkit-transition:opacity .6s ease-out;transition:opacity .6s ease-out;z-index:2}.dnb-tabs__scroll-nav-button:first-of-type{left:-2px;right:auto}.dnb-tabs__scroll-nav-button--visible{display:-webkit-box;display:-ms-flexbox;display:flex;opacity:1;pointer-events:auto}.dnb-tabs__scroll-nav-button--hide{opacity:0!important;pointer-events:none}.dnb-core-style .dnb-tabs .dnb-tabs__button,.dnb-tabs__button{background-color:transparent;border:none;cursor:pointer;font-size:1.125rem;font-size:var(--font-size-basis);line-height:1.5rem;line-height:var(--line-height-basis);margin:0;outline:none;padding:0 .125rem;position:relative;text-decoration:none;-webkit-transition:margin .4s ease-out;transition:margin .4s ease-out;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-select:none;white-space:nowrap;z-index:1}.dnb-core-style .dnb-tabs .dnb-tabs__button__title .dnb-icon,.dnb-tabs__button__title .dnb-icon{font-size:1rem;font-size:var(--font-size-small);-webkit-transform:translateY(-.125rem);transform:translateY(-.125rem)}.dnb-core-style .dnb-tabs .dnb-tabs__button .dnb-dummy,.dnb-tabs__button .dnb-dummy{-webkit-box-orient:vertical;-webkit-box-direction:normal;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;height:0;margin-top:.25rem;overflow:hidden;visibility:hidden}.dnb-core-style .dnb-tabs .dnb-tabs__button:after,.dnb-tabs__button:after{bottom:0;content:"";height:1px;left:0;position:absolute;right:0;width:100%;z-index:-1}.dnb-tabs__button__snap{display:-webkit-box;display:-ms-flexbox;display:flex;padding:0 1rem 0 1.5rem;-webkit-transition:padding 1s cubic-bezier(.42,0,0,1);transition:padding 1s cubic-bezier(.42,0,0,1);will-change:padding}@media screen and (max-width:40em){.dnb-tabs__button__snap{padding:0 1rem}}.dnb-tabs__button__snap:first-of-type{padding-left:0}.dnb-tabs__button__snap:last-of-type{padding-right:.5rem}html[data-whatinput=keyboard] .dnb-tabs__button__snap:first-of-type.focus .dnb-tabs__button:focus{margin-left:.5rem}html[data-whatinput=keyboard] .dnb-tabs__button__snap:last-of-type.focus .dnb-tabs__button:focus{margin-right:.5rem}html[data-visual-test] .dnb-tabs .dnb-tabs__button,html[data-visual-test] .dnb-tabs .dnb-tabs__button__snap,html[data-visual-test] .dnb-tabs .dnb-tabs__scroll-nav-button{-webkit-transition:none!important;transition:none!important}.dnb-tabs__content--spacing{padding-top:2rem}
|
|
@@ -13,6 +13,11 @@ export interface TagProps {
|
|
|
13
13
|
* Default: null
|
|
14
14
|
*/
|
|
15
15
|
icon?: IconPrimaryIcon;
|
|
16
|
+
/**
|
|
17
|
+
* If a label is given, typical inside a table or dl (definition list), then you can disable Tag.Group as a dependent of Tag. Use `true` to omit the `Tag group required:` warning.
|
|
18
|
+
* Default: null
|
|
19
|
+
*/
|
|
20
|
+
hasLabel?: boolean;
|
|
16
21
|
/**
|
|
17
22
|
* Custom className on the component root
|
|
18
23
|
* Default: null
|
|
@@ -45,13 +50,7 @@ export interface TagProps {
|
|
|
45
50
|
omitOnKeyUpDeleteEvent?: boolean;
|
|
46
51
|
}
|
|
47
52
|
export declare const defaultProps: {
|
|
48
|
-
className: any;
|
|
49
53
|
skeleton: boolean;
|
|
50
|
-
text: any;
|
|
51
|
-
children: any;
|
|
52
|
-
icon: any;
|
|
53
|
-
onClick: any;
|
|
54
|
-
onDelete: any;
|
|
55
54
|
omitOnKeyUpDeleteEvent: boolean;
|
|
56
55
|
};
|
|
57
56
|
declare const Tag: {
|
package/es/components/tag/Tag.js
CHANGED
|
@@ -3,7 +3,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
3
3
|
|
|
4
4
|
var _IconPrimary;
|
|
5
5
|
|
|
6
|
-
const _excluded = ["className", "skeleton", "children", "text", "onClick", "onDelete", "omitOnKeyUpDeleteEvent"];
|
|
6
|
+
const _excluded = ["className", "skeleton", "children", "text", "hasLabel", "onClick", "onDelete", "omitOnKeyUpDeleteEvent"];
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import classnames from 'classnames';
|
|
9
9
|
import IconPrimary from '../icon-primary/IconPrimary';
|
|
@@ -14,13 +14,7 @@ import { usePropsWithContext } from '../../shared/hooks';
|
|
|
14
14
|
import TagGroup from './TagGroup';
|
|
15
15
|
import { TagGroupContext } from './TagContext';
|
|
16
16
|
export const defaultProps = {
|
|
17
|
-
className: null,
|
|
18
17
|
skeleton: false,
|
|
19
|
-
text: null,
|
|
20
|
-
children: null,
|
|
21
|
-
icon: null,
|
|
22
|
-
onClick: null,
|
|
23
|
-
onDelete: null,
|
|
24
18
|
omitOnKeyUpDeleteEvent: false
|
|
25
19
|
};
|
|
26
20
|
|
|
@@ -36,6 +30,7 @@ const Tag = localProps => {
|
|
|
36
30
|
skeleton,
|
|
37
31
|
children,
|
|
38
32
|
text,
|
|
33
|
+
hasLabel,
|
|
39
34
|
onClick,
|
|
40
35
|
onDelete,
|
|
41
36
|
omitOnKeyUpDeleteEvent
|
|
@@ -69,7 +64,7 @@ const Tag = localProps => {
|
|
|
69
64
|
buttonAttr.icon = getDeleteIcon();
|
|
70
65
|
}
|
|
71
66
|
|
|
72
|
-
if (!tagGroupContext) {
|
|
67
|
+
if (!tagGroupContext && !hasLabel) {
|
|
73
68
|
warn(`Tag group required: A Tag requires a Tag.Group with label description as a parent component. This is to ensure correct semantic and accessibility.`);
|
|
74
69
|
}
|
|
75
70
|
|
|
@@ -90,12 +90,16 @@
|
|
|
90
90
|
|
|
91
91
|
// Default space between tags
|
|
92
92
|
&__group {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
display: inline-flex;
|
|
94
|
+
flex-wrap: wrap;
|
|
95
|
+
gap: 0.5rem;
|
|
96
|
+
|
|
97
|
+
@include IS_IE {
|
|
98
|
+
.dnb-button:not([class*='dnb-space']) {
|
|
99
|
+
margin-bottom: 0.5rem;
|
|
100
|
+
&:not(:last-of-type) {
|
|
101
|
+
margin-right: 0.5rem;
|
|
102
|
+
}
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
105
|
}
|
|
@@ -1116,8 +1116,16 @@ button.dnb-button::-moz-focus-inner {
|
|
|
1116
1116
|
.dnb-tag--removable.dnb-button--size-small.dnb-button--has-icon {
|
|
1117
1117
|
padding-right: 0; }
|
|
1118
1118
|
|
|
1119
|
-
.dnb-tag__group
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1119
|
+
.dnb-tag__group {
|
|
1120
|
+
display: -webkit-inline-box;
|
|
1121
|
+
display: -ms-inline-flexbox;
|
|
1122
|
+
display: inline-flex;
|
|
1123
|
+
-ms-flex-wrap: wrap;
|
|
1124
|
+
flex-wrap: wrap;
|
|
1125
|
+
grid-gap: 0.5rem;
|
|
1126
|
+
gap: 0.5rem; }
|
|
1127
|
+
@media screen and (-ms-high-contrast: none) {
|
|
1128
|
+
.dnb-tag__group .dnb-button:not([class*='dnb-space']) {
|
|
1129
|
+
margin-bottom: 0.5rem; }
|
|
1130
|
+
.dnb-tag__group .dnb-button:not([class*='dnb-space']):not(:last-of-type) {
|
|
1131
|
+
margin-right: 0.5rem; } }
|