@dnb/eufemia 9.28.0 → 9.29.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 +17 -0
- package/cjs/components/dialog/style/dnb-dialog.css +9 -6
- package/cjs/components/dialog/style/dnb-dialog.min.css +1 -1
- package/cjs/components/drawer/style/_drawer.scss +4 -3
- package/cjs/components/drawer/style/dnb-drawer.css +17 -10
- package/cjs/components/drawer/style/dnb-drawer.min.css +1 -1
- package/cjs/components/form-row/FormRowHelpers.d.ts +1 -1
- package/cjs/components/lib.d.ts +1 -89
- package/cjs/components/modal/style/_modal.scss +0 -1
- package/cjs/components/modal/style/dnb-modal.css +9 -6
- package/cjs/components/modal/style/dnb-modal.min.css +1 -1
- package/cjs/components/skeleton/SkeletonHelper.d.ts +2 -1
- package/cjs/components/slider/Slider.d.ts +6 -144
- package/cjs/components/slider/Slider.js +5 -595
- package/cjs/components/slider/SliderHelpers.d.ts +23 -0
- package/cjs/components/slider/SliderHelpers.js +239 -0
- package/cjs/components/slider/SliderInstance.d.ts +6 -0
- package/cjs/components/slider/SliderInstance.js +190 -0
- package/cjs/components/slider/SliderProvider.d.ts +4 -0
- package/cjs/components/slider/SliderProvider.js +264 -0
- package/cjs/components/slider/SliderThumb.d.ts +2 -0
- package/cjs/components/slider/SliderThumb.js +137 -0
- package/cjs/components/slider/SliderTrack.d.ts +6 -0
- package/cjs/components/slider/SliderTrack.js +131 -0
- package/cjs/components/slider/hooks/useSliderEvents.d.ts +11 -0
- package/cjs/components/slider/hooks/useSliderEvents.js +146 -0
- package/cjs/components/slider/hooks/useSliderProps.d.ts +1 -0
- package/cjs/components/slider/hooks/useSliderProps.js +16 -0
- package/cjs/components/slider/style/_slider.scss +19 -48
- package/cjs/components/slider/style/dnb-slider.css +30 -60
- package/cjs/components/slider/style/dnb-slider.min.css +1 -1
- package/cjs/components/slider/style/themes/dnb-slider-theme-ui.css +0 -16
- package/cjs/components/slider/style/themes/dnb-slider-theme-ui.min.css +1 -1
- package/cjs/components/slider/style/themes/dnb-slider-theme-ui.scss +0 -17
- package/cjs/components/slider/types.d.ts +75 -0
- package/cjs/components/slider/types.js +1 -0
- package/cjs/elements/Anchor.d.ts +44 -105
- package/cjs/elements/Anchor.js +48 -138
- package/cjs/elements/Element.d.ts +23 -40
- package/cjs/elements/Element.js +48 -122
- package/cjs/elements/Link.d.ts +18 -1
- package/cjs/elements/lib.d.ts +36 -2
- package/cjs/shared/Context.d.ts +2 -0
- package/cjs/shared/Eufemia.js +1 -1
- package/cjs/shared/helpers/Suffix.d.ts +2 -1
- package/cjs/shared/helpers/Suffix.js +5 -2
- package/cjs/shared/helpers/withCamelCaseProps.d.ts +1 -1
- package/cjs/shared/helpers/withSnakeCaseProps.d.ts +40 -0
- package/cjs/shared/helpers/withSnakeCaseProps.js +168 -0
- package/cjs/shared/locales/en-GB.d.ts +3 -3
- package/cjs/shared/locales/en-GB.js +3 -3
- package/cjs/shared/locales/en-US.d.ts +3 -3
- package/cjs/shared/locales/index.d.ts +6 -6
- package/cjs/shared/locales/nb-NO.d.ts +3 -3
- package/cjs/shared/locales/nb-NO.js +3 -3
- package/cjs/style/dnb-ui-components.css +39 -66
- package/cjs/style/dnb-ui-components.min.css +3 -3
- package/cjs/style/dnb-ui-elements.css +44 -28
- package/cjs/style/dnb-ui-elements.min.css +1 -1
- package/cjs/style/dnb-ui-tags.css +63 -40
- package/cjs/style/dnb-ui-tags.min.css +1 -1
- package/cjs/style/elements/_anchor-mixins.scss +6 -3
- package/cjs/style/themes/theme-eiendom/dnb-theme-eiendom.css +40 -40
- package/cjs/style/themes/theme-eiendom/dnb-theme-eiendom.min.css +2 -2
- package/cjs/style/themes/theme-ui/dnb-theme-ui.css +44 -44
- package/cjs/style/themes/theme-ui/dnb-theme-ui.min.css +2 -2
- package/components/dialog/style/dnb-dialog.css +9 -6
- package/components/dialog/style/dnb-dialog.min.css +1 -1
- package/components/drawer/style/_drawer.scss +4 -3
- package/components/drawer/style/dnb-drawer.css +17 -10
- package/components/drawer/style/dnb-drawer.min.css +1 -1
- package/components/form-row/FormRowHelpers.d.ts +1 -1
- package/components/lib.d.ts +1 -89
- package/components/modal/style/_modal.scss +0 -1
- package/components/modal/style/dnb-modal.css +9 -6
- package/components/modal/style/dnb-modal.min.css +1 -1
- package/components/skeleton/SkeletonHelper.d.ts +2 -1
- package/components/slider/Slider.d.ts +6 -144
- package/components/slider/Slider.js +5 -528
- package/components/slider/SliderHelpers.d.ts +23 -0
- package/components/slider/SliderHelpers.js +152 -0
- package/components/slider/SliderInstance.d.ts +6 -0
- package/components/slider/SliderInstance.js +162 -0
- package/components/slider/SliderProvider.d.ts +4 -0
- package/components/slider/SliderProvider.js +199 -0
- package/components/slider/SliderThumb.d.ts +2 -0
- package/components/slider/SliderThumb.js +109 -0
- package/components/slider/SliderTrack.d.ts +6 -0
- package/components/slider/SliderTrack.js +104 -0
- package/components/slider/hooks/useSliderEvents.d.ts +11 -0
- package/components/slider/hooks/useSliderEvents.js +132 -0
- package/components/slider/hooks/useSliderProps.d.ts +1 -0
- package/components/slider/hooks/useSliderProps.js +5 -0
- package/components/slider/style/_slider.scss +19 -48
- package/components/slider/style/dnb-slider.css +30 -60
- package/components/slider/style/dnb-slider.min.css +1 -1
- package/components/slider/style/themes/dnb-slider-theme-ui.css +0 -16
- package/components/slider/style/themes/dnb-slider-theme-ui.min.css +1 -1
- package/components/slider/style/themes/dnb-slider-theme-ui.scss +0 -17
- package/components/slider/types.d.ts +75 -0
- package/components/slider/types.js +1 -0
- package/elements/Anchor.d.ts +44 -105
- package/elements/Anchor.js +51 -113
- package/elements/Element.d.ts +23 -40
- package/elements/Element.js +44 -92
- package/elements/Link.d.ts +18 -1
- package/elements/lib.d.ts +36 -2
- package/es/components/dialog/style/dnb-dialog.css +9 -6
- package/es/components/dialog/style/dnb-dialog.min.css +1 -1
- package/es/components/drawer/style/_drawer.scss +4 -3
- package/es/components/drawer/style/dnb-drawer.css +17 -10
- package/es/components/drawer/style/dnb-drawer.min.css +1 -1
- package/es/components/form-row/FormRowHelpers.d.ts +1 -1
- package/es/components/lib.d.ts +1 -89
- package/es/components/modal/style/_modal.scss +0 -1
- package/es/components/modal/style/dnb-modal.css +9 -6
- package/es/components/modal/style/dnb-modal.min.css +1 -1
- package/es/components/skeleton/SkeletonHelper.d.ts +2 -1
- package/es/components/slider/Slider.d.ts +6 -144
- package/es/components/slider/Slider.js +5 -484
- package/es/components/slider/SliderHelpers.d.ts +23 -0
- package/es/components/slider/SliderHelpers.js +124 -0
- package/es/components/slider/SliderInstance.d.ts +6 -0
- package/es/components/slider/SliderInstance.js +167 -0
- package/es/components/slider/SliderProvider.d.ts +4 -0
- package/es/components/slider/SliderProvider.js +178 -0
- package/es/components/slider/SliderThumb.d.ts +2 -0
- package/es/components/slider/SliderThumb.js +100 -0
- package/es/components/slider/SliderTrack.d.ts +6 -0
- package/es/components/slider/SliderTrack.js +99 -0
- package/es/components/slider/hooks/useSliderEvents.d.ts +11 -0
- package/es/components/slider/hooks/useSliderEvents.js +129 -0
- package/es/components/slider/hooks/useSliderProps.d.ts +1 -0
- package/es/components/slider/hooks/useSliderProps.js +5 -0
- package/es/components/slider/style/_slider.scss +19 -48
- package/es/components/slider/style/dnb-slider.css +30 -60
- package/es/components/slider/style/dnb-slider.min.css +1 -1
- package/es/components/slider/style/themes/dnb-slider-theme-ui.css +0 -16
- package/es/components/slider/style/themes/dnb-slider-theme-ui.min.css +1 -1
- package/es/components/slider/style/themes/dnb-slider-theme-ui.scss +0 -17
- package/es/components/slider/types.d.ts +75 -0
- package/es/components/slider/types.js +1 -0
- package/es/elements/Anchor.d.ts +44 -105
- package/es/elements/Anchor.js +49 -80
- package/es/elements/Element.d.ts +23 -40
- package/es/elements/Element.js +44 -61
- package/es/elements/Link.d.ts +18 -1
- package/es/elements/lib.d.ts +36 -2
- package/es/shared/Context.d.ts +2 -0
- package/es/shared/Eufemia.js +1 -1
- package/es/shared/helpers/Suffix.d.ts +2 -1
- package/es/shared/helpers/Suffix.js +5 -3
- package/es/shared/helpers/withCamelCaseProps.d.ts +1 -1
- package/es/shared/helpers/withSnakeCaseProps.d.ts +40 -0
- package/es/shared/helpers/withSnakeCaseProps.js +72 -0
- package/es/shared/locales/en-GB.d.ts +3 -3
- package/es/shared/locales/en-GB.js +3 -3
- package/es/shared/locales/en-US.d.ts +3 -3
- package/es/shared/locales/index.d.ts +6 -6
- package/es/shared/locales/nb-NO.d.ts +3 -3
- package/es/shared/locales/nb-NO.js +3 -3
- package/es/style/dnb-ui-components.css +39 -66
- package/es/style/dnb-ui-components.min.css +3 -3
- package/es/style/dnb-ui-elements.css +44 -28
- package/es/style/dnb-ui-elements.min.css +1 -1
- package/es/style/dnb-ui-tags.css +63 -40
- package/es/style/dnb-ui-tags.min.css +1 -1
- package/es/style/elements/_anchor-mixins.scss +6 -3
- package/es/style/themes/theme-eiendom/dnb-theme-eiendom.css +40 -40
- package/es/style/themes/theme-eiendom/dnb-theme-eiendom.min.css +2 -2
- package/es/style/themes/theme-ui/dnb-theme-ui.css +44 -44
- package/es/style/themes/theme-ui/dnb-theme-ui.min.css +2 -2
- package/esm/dnb-ui-basis.min.mjs +1 -1
- package/esm/dnb-ui-components.min.mjs +3 -3
- package/esm/dnb-ui-elements.min.mjs +9 -10
- package/esm/dnb-ui-extensions.min.mjs +4 -4
- package/esm/dnb-ui-lib.min.mjs +3 -3
- package/esm/dnb-ui-web-components.min.mjs +3 -3
- package/package.json +1 -1
- package/shared/Context.d.ts +2 -0
- package/shared/Eufemia.js +1 -1
- package/shared/helpers/Suffix.d.ts +2 -1
- package/shared/helpers/Suffix.js +4 -2
- package/shared/helpers/withCamelCaseProps.d.ts +1 -1
- package/shared/helpers/withSnakeCaseProps.d.ts +40 -0
- package/shared/helpers/withSnakeCaseProps.js +115 -0
- package/shared/locales/en-GB.d.ts +3 -3
- package/shared/locales/en-GB.js +3 -3
- package/shared/locales/en-US.d.ts +3 -3
- package/shared/locales/index.d.ts +6 -6
- package/shared/locales/nb-NO.d.ts +3 -3
- package/shared/locales/nb-NO.js +3 -3
- package/style/dnb-ui-components.css +39 -66
- package/style/dnb-ui-components.min.css +3 -3
- package/style/dnb-ui-elements.css +44 -28
- package/style/dnb-ui-elements.min.css +1 -1
- package/style/dnb-ui-tags.css +63 -40
- package/style/dnb-ui-tags.min.css +1 -1
- package/style/elements/_anchor-mixins.scss +6 -3
- package/style/themes/theme-eiendom/dnb-theme-eiendom.css +40 -40
- package/style/themes/theme-eiendom/dnb-theme-eiendom.min.css +2 -2
- package/style/themes/theme-ui/dnb-theme-ui.css +44 -44
- package/style/themes/theme-ui/dnb-theme-ui.min.css +2 -2
- package/umd/dnb-ui-basis.min.js +1 -1
- package/umd/dnb-ui-components.min.js +5 -5
- package/umd/dnb-ui-elements.min.js +20 -21
- package/umd/dnb-ui-extensions.min.js +3 -3
- package/umd/dnb-ui-lib.min.js +4 -4
- package/umd/dnb-ui-web-components.min.js +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
.dnb-slider__line{background-color:#007272;background-color:var(--color-sea-green)}.dnb-slider__line__after{background-color:#d2f0e9;background-color:var(--color-mint-green-50)}.dnb-slider__state--disabled .dnb-slider__line{background-color:#b3dada;background-color:var(--color-sea-green-30)}.dnb-slider__state--disabled .dnb-slider__line__after{background-color:#e9f8f4;background-color:var(--color-mint-green-25)}.dnb-
|
|
1
|
+
.dnb-slider__line{background-color:#007272;background-color:var(--color-sea-green)}.dnb-slider__line__after{background-color:#d2f0e9;background-color:var(--color-mint-green-50)}.dnb-slider__state--disabled .dnb-slider__line{background-color:#b3dada;background-color:var(--color-sea-green-30)}.dnb-slider__state--disabled .dnb-slider__line__after{background-color:#e9f8f4;background-color:var(--color-mint-green-25)}.dnb-slider__thumb{-webkit-box-shadow:0 8px 16px rgba(51,51,51,.08);box-shadow:0 8px 16px rgba(51,51,51,.08);-webkit-box-shadow:var(--shadow-default);box-shadow:var(--shadow-default)}
|
|
@@ -19,23 +19,6 @@
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
&__track {
|
|
23
|
-
&::before {
|
|
24
|
-
background-color: var(--color-sea-green);
|
|
25
|
-
}
|
|
26
|
-
&::after {
|
|
27
|
-
background-color: var(--color-mint-green-50);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
&__state--disabled#{&}__track {
|
|
31
|
-
&::before {
|
|
32
|
-
background-color: var(--color-sea-green-30);
|
|
33
|
-
}
|
|
34
|
-
&::after {
|
|
35
|
-
background-color: var(--color-mint-green-25);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
22
|
&__thumb {
|
|
40
23
|
@include defaultDropShadow();
|
|
41
24
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { SuffixChildren } from '../../shared/helpers/Suffix';
|
|
4
|
+
import type { formatReturnType, formatOptionParams } from '../number-format/NumberUtils';
|
|
5
|
+
import { IncludeSnakeCase } from '../../shared/helpers/withSnakeCaseProps';
|
|
6
|
+
export declare type ValueTypes = number | Array<number>;
|
|
7
|
+
export declare type onChangeEventProps = {
|
|
8
|
+
value: ValueTypes;
|
|
9
|
+
rawValue: number;
|
|
10
|
+
number?: formatReturnType | null;
|
|
11
|
+
event?: Event;
|
|
12
|
+
/** @deprecated use rawValue instead */
|
|
13
|
+
raw_value?: number;
|
|
14
|
+
};
|
|
15
|
+
export declare type SliderProps = IncludeSnakeCase<{
|
|
16
|
+
id?: string;
|
|
17
|
+
label?: React.ReactNode;
|
|
18
|
+
labelDirection?: 'vertical' | 'horizontal';
|
|
19
|
+
labelSrOnly?: boolean;
|
|
20
|
+
status?: string | boolean;
|
|
21
|
+
statusState?: 'error' | 'info';
|
|
22
|
+
statusProps?: Record<string, unknown>;
|
|
23
|
+
statusNoAnimation?: boolean;
|
|
24
|
+
globalStatusId?: string;
|
|
25
|
+
suffix?: SuffixChildren;
|
|
26
|
+
thumbTitle?: string;
|
|
27
|
+
addTitle?: string;
|
|
28
|
+
subtractTitle?: string;
|
|
29
|
+
min?: number;
|
|
30
|
+
max?: number;
|
|
31
|
+
value?: ValueTypes;
|
|
32
|
+
step?: number;
|
|
33
|
+
vertical?: boolean;
|
|
34
|
+
reverse?: boolean;
|
|
35
|
+
stretch?: boolean;
|
|
36
|
+
numberFormat?: formatOptionParams;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
hideButtons?: boolean;
|
|
39
|
+
skeleton?: boolean;
|
|
40
|
+
class?: string;
|
|
41
|
+
className?: string;
|
|
42
|
+
onChange?: (props: onChangeEventProps) => void;
|
|
43
|
+
onDragStart?: (props: {
|
|
44
|
+
event: MouseEvent | TouchEvent;
|
|
45
|
+
}) => void;
|
|
46
|
+
onDragEnd?: (props: {
|
|
47
|
+
event: MouseEvent | TouchEvent;
|
|
48
|
+
}) => void;
|
|
49
|
+
/** @deprecated */
|
|
50
|
+
onInit?: (props: Omit<onChangeEventProps, 'rawValue'>) => void;
|
|
51
|
+
/** @deprecated The Slider does not support mouse wheel */
|
|
52
|
+
use_scrollwheel?: boolean;
|
|
53
|
+
children?: React.ReactChild;
|
|
54
|
+
}>;
|
|
55
|
+
export declare type ThumbStateEnums = 'initial' | 'normal' | 'activated' | 'released' | 'focused' | 'jumped';
|
|
56
|
+
export declare type SliderContextTypes = {
|
|
57
|
+
isMulti: boolean;
|
|
58
|
+
isReverse: boolean;
|
|
59
|
+
isVertical: boolean;
|
|
60
|
+
thumbState: ThumbStateEnums;
|
|
61
|
+
thumbIndex: React.RefObject<number>;
|
|
62
|
+
showStatus: boolean;
|
|
63
|
+
showButtons: boolean;
|
|
64
|
+
attributes: unknown;
|
|
65
|
+
allProps: SliderProps;
|
|
66
|
+
value: ValueTypes;
|
|
67
|
+
values: Array<number>;
|
|
68
|
+
setValue: (value: ValueTypes) => void;
|
|
69
|
+
setThumbState: (thumbState: ThumbStateEnums) => void;
|
|
70
|
+
setThumbIndex: (thumbIndex: number) => void;
|
|
71
|
+
emitChange: (emitEvent: MouseEvent | TouchEvent, value: number) => void;
|
|
72
|
+
trackRef: React.RefObject<HTMLElement>;
|
|
73
|
+
setJumpedState: () => void;
|
|
74
|
+
jumpedTimeout: React.RefObject<NodeJS.Timeout>;
|
|
75
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/elements/Anchor.d.ts
CHANGED
|
@@ -1,108 +1,47 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export type AnchorSpace =
|
|
3
|
-
| string
|
|
4
|
-
| number
|
|
5
|
-
| boolean
|
|
6
|
-
| {
|
|
7
|
-
/**
|
|
8
|
-
* Use spacing values like: `small`, `1rem`, `1` or , `16px`. Will use `margin-top`.
|
|
9
|
-
*/
|
|
10
|
-
top?: string | number | boolean;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Use spacing values like: `small`, `1rem`, `1` or , `16px`. will use `margin-right`.
|
|
14
|
-
*/
|
|
15
|
-
right?: string | number | boolean;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Use spacing values like: `small`, `1rem`, `1` or , `16px`. will use `margin-bottom`.
|
|
19
|
-
*/
|
|
20
|
-
bottom?: string | number | boolean;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Use spacing values like: `small`, `1rem`, `1` or , `16px`. will use `margin-left`.
|
|
24
|
-
*/
|
|
25
|
-
left?: string | number | boolean;
|
|
26
|
-
};
|
|
27
|
-
export type AnchorTop = string | number | boolean;
|
|
28
|
-
export type AnchorRight = string | number | boolean;
|
|
29
|
-
export type AnchorBottom = string | number | boolean;
|
|
30
|
-
export type AnchorLeft = string | number | boolean;
|
|
31
|
-
export type AnchorElement =
|
|
32
|
-
| ((...args: any[]) => any)
|
|
33
|
-
| Object
|
|
34
|
-
| React.ReactNode;
|
|
35
|
-
export type AnchorTo = string | Object | ((...args: any[]) => any);
|
|
36
|
-
export type AnchorClassName = string | Object | any[];
|
|
37
|
-
export type AnchorTooltip = ((...args: any[]) => any) | React.ReactNode;
|
|
38
|
-
export type AnchorSkeleton = string | boolean;
|
|
39
|
-
|
|
40
1
|
/**
|
|
41
|
-
*
|
|
2
|
+
* HTML Element
|
|
3
|
+
*
|
|
42
4
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* The title shown as a tooltip when target is set to `_blank`.
|
|
87
|
-
*/
|
|
88
|
-
target_blank_title?: string;
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Defines the opening method. Use `_blank` to open a new browser window/tab.
|
|
92
|
-
*/
|
|
93
|
-
target?: string;
|
|
94
|
-
className?: AnchorClassName;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Provide a string or a React Element to be shown as the tooltip content.
|
|
98
|
-
*/
|
|
99
|
-
tooltip?: AnchorTooltip;
|
|
100
|
-
children?: React.ReactNode;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* If set to `true`, an overlaying skeleton with animation will be shown.
|
|
104
|
-
*/
|
|
105
|
-
skeleton?: AnchorSkeleton;
|
|
106
|
-
}
|
|
107
|
-
declare const Anchor: React.FC<AnchorProps>;
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { ISpacingProps } from '../shared/interfaces';
|
|
7
|
+
export declare type AnchorProps = {
|
|
8
|
+
element?: React.ReactNode;
|
|
9
|
+
href?: string;
|
|
10
|
+
to?: string;
|
|
11
|
+
targetBlankTitle?: string;
|
|
12
|
+
target?: string;
|
|
13
|
+
tooltip?: React.ReactNode;
|
|
14
|
+
skeleton?: boolean;
|
|
15
|
+
className?: string;
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
omitClass?: boolean;
|
|
18
|
+
innerRef?: React.ForwardedRef<unknown>;
|
|
19
|
+
id?: string;
|
|
20
|
+
title?: string;
|
|
21
|
+
lang?: string;
|
|
22
|
+
/** @deprecated use innerRef instead */
|
|
23
|
+
inner_ref?: React.ForwardedRef<unknown>;
|
|
24
|
+
/** @deprecated use targetBlankTitle instead */
|
|
25
|
+
target_blank_title?: string;
|
|
26
|
+
} & Partial<Omit<HTMLAnchorElement, 'children'>> & ISpacingProps;
|
|
27
|
+
declare const Anchor: React.ForwardRefExoticComponent<{
|
|
28
|
+
element?: React.ReactNode;
|
|
29
|
+
href?: string;
|
|
30
|
+
to?: string;
|
|
31
|
+
targetBlankTitle?: string;
|
|
32
|
+
target?: string;
|
|
33
|
+
tooltip?: React.ReactNode;
|
|
34
|
+
skeleton?: boolean;
|
|
35
|
+
className?: string;
|
|
36
|
+
children?: React.ReactNode;
|
|
37
|
+
omitClass?: boolean;
|
|
38
|
+
innerRef?: React.ForwardedRef<unknown>;
|
|
39
|
+
id?: string;
|
|
40
|
+
title?: string;
|
|
41
|
+
lang?: string;
|
|
42
|
+
/** @deprecated use innerRef instead */
|
|
43
|
+
inner_ref?: React.ForwardedRef<unknown>;
|
|
44
|
+
/** @deprecated use targetBlankTitle instead */
|
|
45
|
+
target_blank_title?: string;
|
|
46
|
+
} & Partial<Omit<HTMLAnchorElement, "children">> & ISpacingProps & React.RefAttributes<unknown>>;
|
|
108
47
|
export default Anchor;
|
package/elements/Anchor.js
CHANGED
|
@@ -1,125 +1,63 @@
|
|
|
1
|
-
import "core-js/modules/es.object.keys.js";
|
|
2
|
-
import "core-js/modules/es.symbol.js";
|
|
3
|
-
import "core-js/modules/es.array.filter.js";
|
|
4
|
-
import "core-js/modules/es.object.to-string.js";
|
|
5
|
-
import "core-js/modules/es.object.get-own-property-descriptor.js";
|
|
6
|
-
import "core-js/modules/web.dom-collections.for-each.js";
|
|
7
|
-
import "core-js/modules/es.object.get-own-property-descriptors.js";
|
|
8
|
-
import "core-js/modules/es.reflect.construct.js";
|
|
9
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
10
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
11
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
12
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
13
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
14
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
15
|
-
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
16
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
17
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
21
|
-
|
|
22
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
23
|
-
|
|
24
|
-
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; }
|
|
25
|
-
|
|
26
|
-
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; }
|
|
27
|
-
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["id", "element", "className", "children", "tooltip", "omitClass", "innerRef", "targetBlankTitle"];
|
|
28
4
|
import React from 'react';
|
|
29
|
-
import PropTypes from 'prop-types';
|
|
30
5
|
import classnames from 'classnames';
|
|
31
|
-
import { spacingPropTypes } from '../components/space/SpacingHelper';
|
|
32
6
|
import E from './Element';
|
|
33
7
|
import Context from '../shared/Context';
|
|
34
|
-
import { makeUniqueId
|
|
8
|
+
import { makeUniqueId } from '../shared/component-helper';
|
|
35
9
|
import Tooltip from '../components/tooltip/Tooltip';
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
className: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array]),
|
|
49
|
-
tooltip: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
50
|
-
children: PropTypes.node,
|
|
51
|
-
skeleton: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
|
|
52
|
-
}) : void 0;
|
|
53
|
-
Anchor.defaultProps = {
|
|
54
|
-
element: null,
|
|
55
|
-
href: null,
|
|
56
|
-
to: null,
|
|
57
|
-
omitClass: null,
|
|
58
|
-
target_blank_title: null,
|
|
59
|
-
target: null,
|
|
60
|
-
className: null,
|
|
61
|
-
tooltip: null,
|
|
62
|
-
children: null,
|
|
63
|
-
skeleton: null
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
var AnchorInstance = function (_React$PureComponent) {
|
|
67
|
-
_inherits(AnchorInstance, _React$PureComponent);
|
|
68
|
-
|
|
69
|
-
var _super = _createSuper(AnchorInstance);
|
|
70
|
-
|
|
71
|
-
function AnchorInstance(props) {
|
|
72
|
-
var _this;
|
|
73
|
-
|
|
74
|
-
_classCallCheck(this, AnchorInstance);
|
|
75
|
-
|
|
76
|
-
_this = _super.call(this, props);
|
|
77
|
-
|
|
78
|
-
_defineProperty(_assertThisInitialized(_this), "state", {});
|
|
79
|
-
|
|
80
|
-
_this._id = props.id || 'id' + makeUniqueId();
|
|
81
|
-
_this._ref = props.inner_ref || React.createRef();
|
|
82
|
-
return _this;
|
|
10
|
+
import usePropsWithContext from '../shared/hooks/usePropsWithContext';
|
|
11
|
+
var defaultProps = {};
|
|
12
|
+
|
|
13
|
+
function AnchorInstance(localProps) {
|
|
14
|
+
var context = React.useContext(Context);
|
|
15
|
+
var allProps = usePropsWithContext(localProps, defaultProps, {
|
|
16
|
+
skeleton: context === null || context === void 0 ? void 0 : context.skeleton
|
|
17
|
+
}, context === null || context === void 0 ? void 0 : context.getTranslation(localProps).Anchor, context === null || context === void 0 ? void 0 : context.Anchor);
|
|
18
|
+
|
|
19
|
+
if (typeof allProps.inner_ref !== 'undefined') {
|
|
20
|
+
allProps.innerRef = allProps.inner_ref;
|
|
21
|
+
delete allProps.inner_ref;
|
|
83
22
|
}
|
|
84
23
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
skeleton: this.context && this.context.skeleton
|
|
90
|
-
}, this.context.getTranslation(this.props).Anchor, this.context.Anchor);
|
|
91
|
-
|
|
92
|
-
var element = props.element,
|
|
93
|
-
className = props.className,
|
|
94
|
-
children = props.children,
|
|
95
|
-
tooltip = props.tooltip,
|
|
96
|
-
omitClass = props.omitClass,
|
|
97
|
-
inner_ref = props.inner_ref,
|
|
98
|
-
attributes = _objectWithoutProperties(props, _excluded);
|
|
99
|
-
|
|
100
|
-
var showTooltip = props.target === '_blank' && !props.title;
|
|
101
|
-
attributes.className = classnames(className, omitClass !== true && 'dnb-anchor', props.target === '_blank' && typeof children !== 'string' && 'dnb-anchor--no-icon');
|
|
102
|
-
return React.createElement(React.Fragment, null, React.createElement(E, _extends({
|
|
103
|
-
is: element || 'a'
|
|
104
|
-
}, attributes, {
|
|
105
|
-
inner_ref: this._ref
|
|
106
|
-
}), children), showTooltip && React.createElement(Tooltip, {
|
|
107
|
-
show_delay: 100,
|
|
108
|
-
id: this._id + '-tooltip',
|
|
109
|
-
target_element: this._ref,
|
|
110
|
-
tooltip: tooltip
|
|
111
|
-
}, props.title || props.target_blank_title));
|
|
112
|
-
}
|
|
113
|
-
}]);
|
|
114
|
-
|
|
115
|
-
return AnchorInstance;
|
|
116
|
-
}(React.PureComponent);
|
|
117
|
-
|
|
118
|
-
_defineProperty(AnchorInstance, "contextType", Context);
|
|
24
|
+
if (typeof allProps.target_blank_title !== 'undefined') {
|
|
25
|
+
allProps.targetBlankTitle = allProps.target_blank_title;
|
|
26
|
+
delete allProps.target_blank_title;
|
|
27
|
+
}
|
|
119
28
|
|
|
120
|
-
|
|
29
|
+
if (!allProps.innerRef) {
|
|
30
|
+
allProps.innerRef = React.createRef();
|
|
31
|
+
}
|
|
121
32
|
|
|
122
|
-
|
|
33
|
+
var id = allProps.id,
|
|
34
|
+
element = allProps.element,
|
|
35
|
+
className = allProps.className,
|
|
36
|
+
children = allProps.children,
|
|
37
|
+
tooltip = allProps.tooltip,
|
|
38
|
+
omitClass = allProps.omitClass,
|
|
39
|
+
innerRef = allProps.innerRef,
|
|
40
|
+
targetBlankTitle = allProps.targetBlankTitle,
|
|
41
|
+
attributes = _objectWithoutProperties(allProps, _excluded);
|
|
42
|
+
|
|
43
|
+
var internalId = id || 'id' + makeUniqueId();
|
|
44
|
+
var showTooltip = allProps.target === '_blank' && !allProps.title;
|
|
45
|
+
return React.createElement(React.Fragment, null, React.createElement(E, _extends({
|
|
46
|
+
is: element || 'a',
|
|
47
|
+
className: classnames(className, omitClass !== true && 'dnb-anchor', allProps.target === '_blank' && typeof children !== 'string' && 'dnb-anchor--no-icon')
|
|
48
|
+
}, attributes, {
|
|
49
|
+
innerRef: innerRef
|
|
50
|
+
}), children), showTooltip && React.createElement(Tooltip, {
|
|
51
|
+
show_delay: 100,
|
|
52
|
+
id: internalId + '-tooltip',
|
|
53
|
+
target_element: innerRef,
|
|
54
|
+
tooltip: tooltip
|
|
55
|
+
}, allProps.title || targetBlankTitle));
|
|
56
|
+
}
|
|
123
57
|
|
|
124
|
-
|
|
58
|
+
var Anchor = React.forwardRef(function (props, ref) {
|
|
59
|
+
return React.createElement(AnchorInstance, _extends({
|
|
60
|
+
inner_ref: ref
|
|
61
|
+
}, props));
|
|
62
|
+
});
|
|
125
63
|
export default Anchor;
|
package/elements/Element.d.ts
CHANGED
|
@@ -1,43 +1,26 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export type ElementIs =
|
|
3
|
-
| ((...args: any[]) => any)
|
|
4
|
-
| Object
|
|
5
|
-
| React.ReactNode;
|
|
6
|
-
export type ElementSkeleton = string | boolean;
|
|
7
|
-
export type ElementSpace =
|
|
8
|
-
| string
|
|
9
|
-
| number
|
|
10
|
-
| boolean
|
|
11
|
-
| {
|
|
12
|
-
top?: string | number | boolean;
|
|
13
|
-
right?: string | number | boolean;
|
|
14
|
-
bottom?: string | number | boolean;
|
|
15
|
-
left?: string | number | boolean;
|
|
16
|
-
};
|
|
17
|
-
export type ElementTop = string | number | boolean;
|
|
18
|
-
export type ElementRight = string | number | boolean;
|
|
19
|
-
export type ElementBottom = string | number | boolean;
|
|
20
|
-
export type ElementLeft = string | number | boolean;
|
|
21
|
-
export type ElementClassName = string | Object | any[];
|
|
22
|
-
export type ElementCss = string | Object;
|
|
23
|
-
|
|
24
1
|
/**
|
|
25
|
-
*
|
|
2
|
+
* This is mainly a Wrapper, to build more easily HTML Elements
|
|
3
|
+
*
|
|
26
4
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { SkeletonMethods } from '../components/skeleton/SkeletonHelper';
|
|
7
|
+
export declare type ElementProps = {
|
|
8
|
+
is: React.ReactNode;
|
|
9
|
+
skeleton?: boolean;
|
|
10
|
+
skeletonMethod?: SkeletonMethods;
|
|
11
|
+
class?: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
internalClass?: string;
|
|
14
|
+
css?: string;
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
innerRef?: React.ForwardedRef<unknown>;
|
|
17
|
+
/** @deprecated use innerRef instead */
|
|
18
|
+
inner_ref?: React.ForwardedRef<unknown>;
|
|
19
|
+
/** @deprecated use skeletonMethod instead */
|
|
20
|
+
skeleton_method?: SkeletonMethods;
|
|
21
|
+
};
|
|
22
|
+
export declare const defaultProps: {
|
|
23
|
+
skeletonMethod: string;
|
|
24
|
+
};
|
|
25
|
+
declare const Element: React.ForwardRefExoticComponent<ElementProps & React.RefAttributes<unknown>>;
|
|
43
26
|
export default Element;
|