@bethinkpl/design-system 42.0.0 → 44.0.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/dist/design-system.css +1 -1
- package/dist/design-system.js +17470 -13135
- package/dist/design-system.js.map +1 -1
- package/dist/lib/js/components/Cards/Card/Card.consts.d.ts +14 -0
- package/dist/lib/js/components/Cards/Card/Card.vue.d.ts +10 -5
- package/dist/lib/js/components/Cards/CardExpandable/CardExpandable.vue.d.ts +33 -15
- package/dist/lib/js/components/Form/PinInputField/PinInputField.consts.d.ts +14 -0
- package/dist/lib/js/components/Form/PinInputField/PinInputField.types.d.ts +12 -0
- package/dist/lib/js/components/Form/PinInputField/PinInputField.utils.d.ts +2 -0
- package/dist/lib/js/components/Form/PinInputField/PinInputField.vue.d.ts +91 -0
- package/dist/lib/js/components/Form/PinInputField/index.d.ts +5 -0
- package/dist/lib/js/components/Form/PinInputField/usePinInputFieldWithinForm.d.ts +8 -0
- package/dist/lib/js/components/Form/SelectField/SelectField.types.d.ts +26 -0
- package/dist/lib/js/components/Form/SelectField/SelectField.utils.d.ts +7 -0
- package/dist/lib/js/components/Form/SelectField/SelectField.vue.d.ts +107 -0
- package/dist/lib/js/components/Form/SelectField/SelectFieldOption.vue.d.ts +19 -0
- package/dist/lib/js/components/Form/SelectField/index.d.ts +4 -0
- package/dist/lib/js/components/Form/SelectField/useSelectFieldWithinForm.d.ts +8 -0
- package/dist/lib/js/components/Form/TextAreaField/TextAreaField.types.d.ts +9 -0
- package/dist/lib/js/components/Form/TextAreaField/TextAreaField.vue.d.ts +76 -0
- package/dist/lib/js/components/Form/TextAreaField/TextAreaFieldAutosized.vue.d.ts +6 -0
- package/dist/lib/js/components/Form/TextAreaField/index.d.ts +4 -0
- package/dist/lib/js/components/LabelValue/LabelValueItem/LabelValueItem.vue.d.ts +12 -1
- package/dist/lib/js/components/Pagination/Pagination.vue.d.ts +2 -0
- package/dist/lib/js/components/SelectList/SelectListItem/SelectListItem.vue.d.ts +2 -0
- package/dist/lib/js/components/SelectList/SelectListItemToggle/SelectListItemToggle.vue.d.ts +2 -0
- package/dist/lib/js/components/SurveyQuestions/SurveyQuestionOpenEnded/SurveyQuestionOpenEnded.vue.d.ts +33 -15
- package/dist/lib/js/components/SurveyQuestions/SurveyQuestionScale/SurveyQuestionScale.vue.d.ts +33 -15
- package/dist/lib/js/components/Toast/Toast.consts.d.ts +11 -9
- package/dist/lib/js/components/Toast/Toast.vue.d.ts +51 -415
- package/dist/lib/js/composables/useFormFieldWithinForm.d.ts +3 -3
- package/dist/lib/js/composables/useTextFieldWithinForm.d.ts +8 -0
- package/dist/lib/js/index.d.ts +6 -0
- package/lib/js/components/Cards/Card/Card.consts.ts +18 -0
- package/lib/js/components/Cards/Card/Card.spec.ts +159 -33
- package/lib/js/components/Cards/Card/Card.stories.ts +21 -2
- package/lib/js/components/Cards/Card/Card.vue +90 -23
- package/lib/js/components/Dropdown/Dropdown.vue +6 -10
- package/lib/js/components/Form/CheckboxGroupField/CheckboxGroupField.spec.ts +15 -0
- package/lib/js/components/Form/CheckboxGroupField/CheckboxGroupField.vue +5 -2
- package/lib/js/components/Form/Form.stories.ts +37 -2
- package/lib/js/components/Form/InputField/InputField.spec.ts +11 -1
- package/lib/js/components/Form/InputField/InputField.vue +7 -4
- package/lib/js/components/Form/PinInputField/PinInputField.consts.ts +18 -0
- package/lib/js/components/Form/PinInputField/PinInputField.spec.ts +394 -0
- package/lib/js/components/Form/PinInputField/PinInputField.stories.ts +124 -0
- package/lib/js/components/Form/PinInputField/PinInputField.types.ts +42 -0
- package/lib/js/components/Form/PinInputField/PinInputField.utils.ts +5 -0
- package/lib/js/components/Form/PinInputField/PinInputField.vue +211 -0
- package/lib/js/components/Form/PinInputField/index.ts +6 -0
- package/lib/js/components/Form/PinInputField/usePinInputFieldWithinForm.ts +29 -0
- package/lib/js/components/Form/SelectField/SelectField.spec.ts +495 -0
- package/lib/js/components/Form/SelectField/SelectField.stories.ts +282 -0
- package/lib/js/components/Form/SelectField/SelectField.types.ts +65 -0
- package/lib/js/components/Form/SelectField/SelectField.utils.ts +83 -0
- package/lib/js/components/Form/SelectField/SelectField.vue +342 -0
- package/lib/js/components/Form/SelectField/SelectFieldOption.vue +51 -0
- package/lib/js/components/Form/SelectField/index.ts +5 -0
- package/lib/js/components/Form/SelectField/useSelectFieldWithinForm.ts +27 -0
- package/lib/js/components/Form/TextAreaField/TextAreaField.spec.ts +341 -0
- package/lib/js/components/Form/TextAreaField/TextAreaField.stories.ts +99 -0
- package/lib/js/components/Form/TextAreaField/TextAreaField.types.ts +23 -0
- package/lib/js/components/Form/TextAreaField/TextAreaField.vue +190 -0
- package/lib/js/components/Form/TextAreaField/TextAreaFieldAutosized.vue +19 -0
- package/lib/js/components/Form/TextAreaField/index.ts +5 -0
- package/lib/js/components/LabelValue/LabelValueItem/LabelValueItem.spec.ts +26 -0
- package/lib/js/components/LabelValue/LabelValueItem/LabelValueItem.stories.ts +16 -3
- package/lib/js/components/LabelValue/LabelValueItem/LabelValueItem.vue +5 -0
- package/lib/js/components/LoadingBar/LoadingBar.spec.ts +84 -0
- package/lib/js/components/LoadingBar/LoadingBar.vue +30 -19
- package/lib/js/components/SelectList/SelectListItem/SelectListItem.spec.ts +77 -0
- package/lib/js/components/SelectList/SelectListItem/SelectListItem.vue +4 -1
- package/lib/js/components/Toast/Toast.consts.ts +4 -2
- package/lib/js/components/Toast/Toast.spec.ts +177 -0
- package/lib/js/components/Toast/Toast.stories.ts +65 -31
- package/lib/js/components/Toast/Toast.vue +176 -195
- package/lib/js/composables/useFormFieldWithinForm.ts +4 -4
- package/lib/js/{components/Form/InputField/useInputFieldWithinForm.ts → composables/useTextFieldWithinForm.ts} +7 -2
- package/lib/js/index.ts +6 -0
- package/lib/js/styles/Shadows/Shadows.stories.scss +16 -0
- package/lib/js/styles/Shadows/Shadows.stories.ts +4 -0
- package/lib/styles/mixins/_dropdown-surface.scss +24 -0
- package/lib/styles/settings/_shadows.scss +18 -0
- package/package.json +1 -1
- package/dist/lib/js/components/Form/InputField/useInputFieldWithinForm.d.ts +0 -8
|
@@ -10,6 +10,26 @@ export default {
|
|
|
10
10
|
decorators: [withActions],
|
|
11
11
|
} as Meta<typeof DsToast>;
|
|
12
12
|
|
|
13
|
+
const toastTemplate = `<ds-toast
|
|
14
|
+
v-if="isVisible"
|
|
15
|
+
:title="title"
|
|
16
|
+
:size="size"
|
|
17
|
+
:position="position"
|
|
18
|
+
:color="color"
|
|
19
|
+
:footer-primary-button-text="footerPrimaryButtonText"
|
|
20
|
+
:footer-primary-button-icon="ICONS[footerPrimaryButtonIcon]"
|
|
21
|
+
:footer-secondary-button-text="footerSecondaryButtonText"
|
|
22
|
+
:footer-secondary-button-icon="ICONS[footerSecondaryButtonIcon]"
|
|
23
|
+
:is-disappearing="isDisappearing"
|
|
24
|
+
:disappearing-timeout="disappearingTimeout"
|
|
25
|
+
:is-closable="isClosable"
|
|
26
|
+
@close="isVisible = false"
|
|
27
|
+
>
|
|
28
|
+
<template #content>
|
|
29
|
+
<span v-html="content" />
|
|
30
|
+
</template>
|
|
31
|
+
</ds-toast>`;
|
|
32
|
+
|
|
13
33
|
const StoryTemplate: StoryFn<typeof DsToast> = (args) => ({
|
|
14
34
|
components: { DsToast },
|
|
15
35
|
setup() {
|
|
@@ -19,40 +39,41 @@ const StoryTemplate: StoryFn<typeof DsToast> = (args) => ({
|
|
|
19
39
|
return {
|
|
20
40
|
ICONS: Object.freeze(ICONS),
|
|
21
41
|
isVisible: true,
|
|
22
|
-
boundariesSelectorId:
|
|
23
|
-
this.boundariesSelector != null ? `#${this.boundariesSelector}` : null,
|
|
24
42
|
};
|
|
25
43
|
},
|
|
26
|
-
template: `<div style="
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<div
|
|
46
|
-
|
|
44
|
+
template: `<div style="height: 1200px; width: 100%;">
|
|
45
|
+
${toastTemplate}
|
|
46
|
+
</div>`,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// `position: none` leaves the placement to the consumer — here the wrapper anchors the toast to the
|
|
50
|
+
// bottom right of its own container instead of the viewport.
|
|
51
|
+
const ClientPositionedStoryTemplate: StoryFn<typeof DsToast> = (args) => ({
|
|
52
|
+
components: { DsToast },
|
|
53
|
+
setup() {
|
|
54
|
+
return args;
|
|
55
|
+
},
|
|
56
|
+
data() {
|
|
57
|
+
return {
|
|
58
|
+
ICONS: Object.freeze(ICONS),
|
|
59
|
+
isVisible: true,
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
template: `<div style="height: 400px; padding: 24px; width: 100%;">
|
|
63
|
+
<div style="position: relative; height: 100%; border: 1px black solid;">
|
|
64
|
+
<div style="position: absolute; bottom: 16px; right: 16px;">
|
|
65
|
+
${toastTemplate}
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
47
68
|
</div>`,
|
|
48
69
|
});
|
|
49
70
|
|
|
50
71
|
export const Interactive = StoryTemplate.bind({});
|
|
51
72
|
|
|
52
73
|
const args = {
|
|
74
|
+
title: 'Opcjonalny Title wpisz tutaj',
|
|
53
75
|
size: TOAST_SIZES.MEDIUM,
|
|
54
76
|
position: TOAST_POSITIONS.CENTER,
|
|
55
|
-
boundariesSelector: null,
|
|
56
77
|
color: TOAST_COLORS.INFO,
|
|
57
78
|
footerPrimaryButtonText: 'primary',
|
|
58
79
|
footerPrimaryButtonIcon: null,
|
|
@@ -60,10 +81,14 @@ const args = {
|
|
|
60
81
|
footerSecondaryButtonIcon: null,
|
|
61
82
|
isDisappearing: false,
|
|
62
83
|
disappearingTimeout: '0',
|
|
84
|
+
isClosable: true,
|
|
63
85
|
content: 'Wpłynąłem na suchego przestwór oceanu',
|
|
64
86
|
} as Args;
|
|
65
87
|
|
|
66
88
|
const argTypes = {
|
|
89
|
+
title: {
|
|
90
|
+
control: 'text',
|
|
91
|
+
},
|
|
67
92
|
size: {
|
|
68
93
|
control: 'select',
|
|
69
94
|
options: Object.values(TOAST_SIZES),
|
|
@@ -72,10 +97,6 @@ const argTypes = {
|
|
|
72
97
|
control: 'select',
|
|
73
98
|
options: Object.values(TOAST_POSITIONS),
|
|
74
99
|
},
|
|
75
|
-
boundariesSelector: {
|
|
76
|
-
control: 'select',
|
|
77
|
-
options: [null, 'left', 'right'],
|
|
78
|
-
},
|
|
79
100
|
color: {
|
|
80
101
|
control: 'select',
|
|
81
102
|
options: Object.values(TOAST_COLORS),
|
|
@@ -88,20 +109,33 @@ const argTypes = {
|
|
|
88
109
|
control: 'select',
|
|
89
110
|
options: [null, ...Object.keys(ICONS)],
|
|
90
111
|
},
|
|
112
|
+
isClosable: {
|
|
113
|
+
control: 'boolean',
|
|
114
|
+
},
|
|
91
115
|
content: {
|
|
92
116
|
control: 'text',
|
|
93
117
|
},
|
|
94
118
|
} as ArgTypes;
|
|
95
119
|
|
|
120
|
+
const actionsParameters = {
|
|
121
|
+
actions: {
|
|
122
|
+
handles: ['close', 'primary-button-click', 'secondary-button-click'],
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
|
|
96
126
|
Interactive.argTypes = argTypes;
|
|
97
127
|
Interactive.args = args;
|
|
98
128
|
|
|
99
129
|
Interactive.parameters = {
|
|
100
|
-
|
|
101
|
-
handles: ['close', 'primary-button-click', 'secondary-button-click'],
|
|
102
|
-
},
|
|
130
|
+
...actionsParameters,
|
|
103
131
|
design: {
|
|
104
132
|
type: 'figma',
|
|
105
133
|
url: 'https://www.figma.com/design/izQdYyiBR1GQgFkaOIfIJI/LMS---DS-Components?node-id=8091-108960',
|
|
106
134
|
},
|
|
107
135
|
};
|
|
136
|
+
|
|
137
|
+
export const ClientPositioned = ClientPositionedStoryTemplate.bind({});
|
|
138
|
+
|
|
139
|
+
ClientPositioned.argTypes = argTypes;
|
|
140
|
+
ClientPositioned.args = { ...args, position: TOAST_POSITIONS.NONE };
|
|
141
|
+
ClientPositioned.parameters = actionsParameters;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div
|
|
3
|
+
:class="['ds-toast', toastSize, toastPosition, toastColor, { '-ds-closable': isClosable }]"
|
|
4
|
+
>
|
|
3
5
|
<ds-card :loading-bar-color="color" has-loading-bar :loading-bar-time="disappearingTimeout">
|
|
4
6
|
<template #content>
|
|
5
|
-
<div class="ds-
|
|
6
|
-
<
|
|
7
|
+
<div class="ds-toast__body">
|
|
8
|
+
<div v-if="title" class="ds-toast__title">{{ title }}</div>
|
|
9
|
+
<div class="ds-toast__content">
|
|
10
|
+
<slot name="content" />
|
|
11
|
+
</div>
|
|
7
12
|
</div>
|
|
8
13
|
</template>
|
|
9
14
|
<template
|
|
@@ -14,6 +19,7 @@
|
|
|
14
19
|
<ds-button
|
|
15
20
|
v-if="footerSecondaryButtonText.length"
|
|
16
21
|
:color="buttonSecondaryColor"
|
|
22
|
+
:size="buttonSize"
|
|
17
23
|
:icon-right="footerSecondaryButtonIcon"
|
|
18
24
|
:type="BUTTON_TYPES.OUTLINED"
|
|
19
25
|
:radius="BUTTON_RADIUSES.ROUNDED"
|
|
@@ -23,6 +29,7 @@
|
|
|
23
29
|
<ds-button
|
|
24
30
|
v-if="footerPrimaryButtonText.length"
|
|
25
31
|
:color="buttonPrimaryColor"
|
|
32
|
+
:size="buttonSize"
|
|
26
33
|
:icon-right="footerPrimaryButtonIcon"
|
|
27
34
|
:radius="BUTTON_RADIUSES.ROUNDED"
|
|
28
35
|
@click="$emit('primary-button-click')"
|
|
@@ -31,49 +38,113 @@
|
|
|
31
38
|
</div>
|
|
32
39
|
</template>
|
|
33
40
|
</ds-card>
|
|
41
|
+
<div v-if="isClosable" class="ds-toast__close">
|
|
42
|
+
<ds-icon-button
|
|
43
|
+
:icon="ICONS.FA_XMARK"
|
|
44
|
+
:size="ICON_BUTTON_SIZES.SMALL"
|
|
45
|
+
:color="ICON_BUTTON_COLORS.NEUTRAL_WEAK"
|
|
46
|
+
@click="close"
|
|
47
|
+
/>
|
|
48
|
+
</div>
|
|
34
49
|
</div>
|
|
35
50
|
</template>
|
|
36
51
|
|
|
37
52
|
<style scoped lang="scss">
|
|
53
|
+
@import '../../../styles/settings/colors/tokens';
|
|
38
54
|
@import '../../../styles/settings/spacings';
|
|
39
55
|
@import '../../../styles/settings/typography/tokens';
|
|
40
56
|
@import '../../../styles/settings/media-queries';
|
|
41
57
|
|
|
42
58
|
.ds-toast {
|
|
43
|
-
|
|
59
|
+
$root: &;
|
|
60
|
+
|
|
61
|
+
max-width: var(--ds-toast-max-width);
|
|
62
|
+
// anchors the absolutely positioned close button, including under `position: none`
|
|
63
|
+
position: relative;
|
|
44
64
|
width: 100%;
|
|
45
65
|
|
|
46
66
|
&.-ds-size-small {
|
|
47
|
-
max-width: 320px
|
|
48
|
-
padding: $space-8;
|
|
67
|
+
--ds-toast-max-width: 320px;
|
|
49
68
|
}
|
|
50
69
|
|
|
51
70
|
&.-ds-size-medium {
|
|
52
|
-
max-width: 500px
|
|
53
|
-
|
|
71
|
+
--ds-toast-max-width: 500px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&.-ds-size-large {
|
|
75
|
+
--ds-toast-max-width: 700px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// The viewport spacing lives in the offsets rather than in padding, so it applies only to the
|
|
79
|
+
// fixed positions — `none` lets the consumer place (and space) the toast themselves.
|
|
80
|
+
&.-ds-position-left,
|
|
81
|
+
&.-ds-position-center,
|
|
82
|
+
&.-ds-position-right {
|
|
83
|
+
--ds-toast-offset: #{$space-8};
|
|
84
|
+
|
|
85
|
+
bottom: var(--ds-toast-offset);
|
|
86
|
+
max-width: min(var(--ds-toast-max-width), calc(100% - var(--ds-toast-offset) * 2));
|
|
87
|
+
position: fixed;
|
|
54
88
|
|
|
55
89
|
@media (#{breakpoint-s()}) {
|
|
56
|
-
|
|
57
|
-
|
|
90
|
+
&.-ds-size-medium,
|
|
91
|
+
&.-ds-size-large {
|
|
92
|
+
--ds-toast-offset: #{$space-12};
|
|
93
|
+
}
|
|
58
94
|
}
|
|
59
95
|
}
|
|
60
96
|
|
|
61
97
|
&.-ds-position-left {
|
|
62
|
-
|
|
63
|
-
left: 0;
|
|
98
|
+
left: var(--ds-toast-offset);
|
|
64
99
|
}
|
|
65
100
|
|
|
66
101
|
&.-ds-position-right {
|
|
67
|
-
|
|
68
|
-
right: 0;
|
|
102
|
+
right: var(--ds-toast-offset);
|
|
69
103
|
}
|
|
70
104
|
|
|
71
105
|
&.-ds-position-center {
|
|
72
|
-
bottom: 0;
|
|
73
106
|
left: 50%;
|
|
74
107
|
transform: translateX(-50%);
|
|
75
108
|
}
|
|
76
109
|
|
|
110
|
+
&__body {
|
|
111
|
+
display: flex;
|
|
112
|
+
flex-direction: column;
|
|
113
|
+
row-gap: $space-2;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&__close {
|
|
117
|
+
position: absolute;
|
|
118
|
+
right: $space-1;
|
|
119
|
+
top: $space-3;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&__title {
|
|
123
|
+
@include heading-s-default-bold;
|
|
124
|
+
|
|
125
|
+
color: $color-neutral-text-strong;
|
|
126
|
+
|
|
127
|
+
#{$root}.-ds-size-large & {
|
|
128
|
+
@include heading-m-default-bold;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
#{$root}.-ds-color-success & {
|
|
132
|
+
color: $color-success-text-strong;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
#{$root}.-ds-color-warning & {
|
|
136
|
+
color: $color-warning-text-strong;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
#{$root}.-ds-color-danger & {
|
|
140
|
+
color: $color-danger-text-strong;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
#{$root}.-ds-color-info & {
|
|
144
|
+
color: $color-info-text-strong;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
77
148
|
&__content {
|
|
78
149
|
@include text-m-default-regular;
|
|
79
150
|
}
|
|
@@ -87,9 +158,15 @@
|
|
|
87
158
|
}
|
|
88
159
|
</style>
|
|
89
160
|
|
|
90
|
-
<script lang="ts">
|
|
91
|
-
import DsButton, {
|
|
161
|
+
<script lang="ts" setup>
|
|
162
|
+
import DsButton, {
|
|
163
|
+
BUTTON_COLORS,
|
|
164
|
+
BUTTON_RADIUSES,
|
|
165
|
+
BUTTON_SIZES,
|
|
166
|
+
BUTTON_TYPES,
|
|
167
|
+
} from '../Buttons/Button';
|
|
92
168
|
import DsCard from '../Cards/Card';
|
|
169
|
+
import DsIconButton, { ICON_BUTTON_COLORS, ICON_BUTTON_SIZES } from '../Buttons/IconButton';
|
|
93
170
|
import {
|
|
94
171
|
TOAST_COLORS,
|
|
95
172
|
TOAST_POSITIONS,
|
|
@@ -98,184 +175,88 @@ import {
|
|
|
98
175
|
ToastPositions,
|
|
99
176
|
ToastSizes,
|
|
100
177
|
} from './Toast.consts';
|
|
101
|
-
import {
|
|
102
|
-
import { ICONS } from '../Icons/Icon';
|
|
103
|
-
|
|
104
|
-
function calculateBoundariesOffset(boundariesElement: HTMLElement) {
|
|
105
|
-
const borderLeftWidth = window.getComputedStyle(boundariesElement).borderLeftWidth;
|
|
106
|
-
const borderRightWidth = window.getComputedStyle(boundariesElement).borderRightWidth;
|
|
107
|
-
const boundingClientRect = boundariesElement.getBoundingClientRect();
|
|
108
|
-
const boundariesOffsetLeft = boundingClientRect.left + parseInt(borderLeftWidth, 10);
|
|
109
|
-
const boundariesOffsetRight =
|
|
110
|
-
boundingClientRect.right - parseInt(borderRightWidth, 10) - parseInt(borderLeftWidth, 10);
|
|
111
|
-
const boundariesOffsetWidth = boundingClientRect.width;
|
|
112
|
-
return {
|
|
113
|
-
left: {
|
|
114
|
-
left: `${boundariesOffsetLeft}px`,
|
|
115
|
-
},
|
|
116
|
-
right: {
|
|
117
|
-
left: `${boundariesOffsetRight}px`,
|
|
118
|
-
transform: 'translateX(-100%)',
|
|
119
|
-
},
|
|
120
|
-
center: {
|
|
121
|
-
left: `${boundariesOffsetLeft + boundariesOffsetWidth / 2}px`,
|
|
122
|
-
transform: 'translateX(-50%)',
|
|
123
|
-
},
|
|
124
|
-
};
|
|
125
|
-
}
|
|
178
|
+
import { computed, onMounted, onUnmounted } from 'vue';
|
|
179
|
+
import { ICONS, IconItem } from '../Icons/Icon';
|
|
126
180
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
BUTTON_TYPES: Object.freeze(BUTTON_TYPES),
|
|
206
|
-
TOAST_SIZES: Object.freeze(TOAST_SIZES),
|
|
207
|
-
TOAST_POSITIONS: Object.freeze(TOAST_POSITIONS),
|
|
208
|
-
};
|
|
209
|
-
},
|
|
210
|
-
computed: {
|
|
211
|
-
buttonPrimaryColor() {
|
|
212
|
-
return this.color === TOAST_COLORS.DANGER
|
|
213
|
-
? BUTTON_COLORS.NEUTRAL
|
|
214
|
-
: BUTTON_COLORS.PRIMARY;
|
|
215
|
-
},
|
|
216
|
-
buttonSecondaryColor() {
|
|
217
|
-
return this.color === TOAST_COLORS.DANGER
|
|
218
|
-
? BUTTON_COLORS.DANGER
|
|
219
|
-
: BUTTON_COLORS.NEUTRAL;
|
|
220
|
-
},
|
|
221
|
-
toastPosition() {
|
|
222
|
-
return `-ds-position-${this.position.toLowerCase()}`;
|
|
223
|
-
},
|
|
224
|
-
toastSize() {
|
|
225
|
-
return `-ds-size-${this.size.toLowerCase()}`;
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
mounted() {
|
|
229
|
-
this.setBoundariesSelectorElement();
|
|
230
|
-
this.calculateStyles();
|
|
231
|
-
this.boundariesSelectorElementResizeObserver?.disconnect();
|
|
232
|
-
this.boundariesSelectorElementResizeObserver = new ResizeObserver(() => {
|
|
233
|
-
this.calculateStyles();
|
|
234
|
-
});
|
|
235
|
-
if (this.boundariesSelectorElement) {
|
|
236
|
-
this.boundariesSelectorElementResizeObserver.observe(this.boundariesSelectorElement);
|
|
237
|
-
} else {
|
|
238
|
-
//window resize does not work for some reason, so we observe body
|
|
239
|
-
this.boundariesSelectorElementResizeObserver.observe(document.querySelector('body'));
|
|
240
|
-
}
|
|
241
|
-
if (this.isDisappearing && this.disappearingTimeout !== '0') {
|
|
242
|
-
setTimeout(
|
|
243
|
-
() => this.$emit('close'),
|
|
244
|
-
parseInt(this.disappearingTimeout, 10) * 1000 + 100, // 100 ms is to let loading bar animation to finish
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
beforeUnmount() {
|
|
249
|
-
this.boundariesSelectorElementResizeObserver.disconnect();
|
|
250
|
-
this.boundariesSelectorElementResizeObserver = null;
|
|
251
|
-
},
|
|
252
|
-
updated() {
|
|
253
|
-
const { right, left } = this.$el.getClientRects()[0];
|
|
254
|
-
if (parseInt(left, 10) < 0 || right > document.documentElement.clientWidth) {
|
|
255
|
-
this.styles = {
|
|
256
|
-
left: '50%',
|
|
257
|
-
transform: 'translateX(-50%)',
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
methods: {
|
|
262
|
-
calculateStyles() {
|
|
263
|
-
if (this.boundariesSelectorElement) {
|
|
264
|
-
this.styles = calculateBoundariesOffset(this.boundariesSelectorElement)[
|
|
265
|
-
this.position
|
|
266
|
-
];
|
|
267
|
-
} else {
|
|
268
|
-
this.styles = {};
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
|
-
setBoundariesSelectorElement() {
|
|
272
|
-
if (typeof this.boundariesSelector === 'string') {
|
|
273
|
-
this.boundariesSelectorElement =
|
|
274
|
-
document.querySelector(this.boundariesSelector) || null;
|
|
275
|
-
} else if (this.boundariesSelector instanceof HTMLElement) {
|
|
276
|
-
this.boundariesSelectorElement = this.boundariesSelector;
|
|
277
|
-
}
|
|
278
|
-
},
|
|
279
|
-
},
|
|
181
|
+
const {
|
|
182
|
+
title = '',
|
|
183
|
+
size = TOAST_SIZES.MEDIUM,
|
|
184
|
+
position = TOAST_POSITIONS.CENTER,
|
|
185
|
+
color = TOAST_COLORS.INFO,
|
|
186
|
+
footerPrimaryButtonText = '',
|
|
187
|
+
footerPrimaryButtonIcon = null,
|
|
188
|
+
footerSecondaryButtonText = '',
|
|
189
|
+
footerSecondaryButtonIcon = null,
|
|
190
|
+
isDisappearing = true,
|
|
191
|
+
disappearingTimeout = '0',
|
|
192
|
+
isClosable = false,
|
|
193
|
+
} = defineProps<{
|
|
194
|
+
title?: string;
|
|
195
|
+
size?: ToastSizes;
|
|
196
|
+
position?: ToastPositions;
|
|
197
|
+
color?: ToastColors;
|
|
198
|
+
footerPrimaryButtonText?: string;
|
|
199
|
+
footerPrimaryButtonIcon?: IconItem | null;
|
|
200
|
+
footerSecondaryButtonText?: string;
|
|
201
|
+
footerSecondaryButtonIcon?: IconItem | null;
|
|
202
|
+
isDisappearing?: boolean;
|
|
203
|
+
/** Seconds, as a numeric string. `'0'` disables the auto-close. */
|
|
204
|
+
disappearingTimeout?: string;
|
|
205
|
+
isClosable?: boolean;
|
|
206
|
+
}>();
|
|
207
|
+
|
|
208
|
+
const emit = defineEmits<{
|
|
209
|
+
close: [];
|
|
210
|
+
'primary-button-click': [];
|
|
211
|
+
'secondary-button-click': [];
|
|
212
|
+
}>();
|
|
213
|
+
|
|
214
|
+
defineSlots<{
|
|
215
|
+
content?: () => any;
|
|
216
|
+
}>();
|
|
217
|
+
|
|
218
|
+
const buttonPrimaryColor = computed(() =>
|
|
219
|
+
color === TOAST_COLORS.DANGER ? BUTTON_COLORS.NEUTRAL : BUTTON_COLORS.PRIMARY,
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
const buttonSecondaryColor = computed(() =>
|
|
223
|
+
color === TOAST_COLORS.DANGER ? BUTTON_COLORS.DANGER : BUTTON_COLORS.NEUTRAL,
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
const buttonSize = computed(() =>
|
|
227
|
+
size === TOAST_SIZES.SMALL ? BUTTON_SIZES.SMALL : BUTTON_SIZES.MEDIUM,
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
const toastSize = computed(() => `-ds-size-${size.toLowerCase()}`);
|
|
231
|
+
|
|
232
|
+
const toastPosition = computed(() => `-ds-position-${position.toLowerCase()}`);
|
|
233
|
+
|
|
234
|
+
const toastColor = computed(() => `-ds-color-${color}`);
|
|
235
|
+
|
|
236
|
+
let disappearingTimeoutId: ReturnType<typeof setTimeout> | null = null;
|
|
237
|
+
|
|
238
|
+
const clearDisappearingTimeout = () => {
|
|
239
|
+
if (disappearingTimeoutId !== null) {
|
|
240
|
+
clearTimeout(disappearingTimeoutId);
|
|
241
|
+
disappearingTimeoutId = null;
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// `close` is emitted at most once per toast — dismissing it by hand cancels the pending auto-close
|
|
246
|
+
// so consumers driving a queue (or analytics) off the event never see it twice.
|
|
247
|
+
const close = () => {
|
|
248
|
+
clearDisappearingTimeout();
|
|
249
|
+
emit('close');
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
onMounted(() => {
|
|
253
|
+
if (isDisappearing && disappearingTimeout !== '0') {
|
|
254
|
+
disappearingTimeoutId = setTimeout(
|
|
255
|
+
close,
|
|
256
|
+
parseInt(disappearingTimeout, 10) * 1000 + 100, // 100 ms is to let loading bar animation to finish
|
|
257
|
+
);
|
|
258
|
+
}
|
|
280
259
|
});
|
|
260
|
+
|
|
261
|
+
onUnmounted(clearDisappearingTimeout);
|
|
281
262
|
</script>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { inject, MaybeRefOrGetter, ref, Ref, toValue } from 'vue';
|
|
2
2
|
import { FormContextKey, useField } from 'vee-validate';
|
|
3
3
|
|
|
4
|
-
export function useFormFieldWithinForm<T
|
|
4
|
+
export function useFormFieldWithinForm<T>(
|
|
5
5
|
name: MaybeRefOrGetter<string | undefined>,
|
|
6
|
-
modelValue: Ref<T
|
|
6
|
+
modelValue: Ref<T>,
|
|
7
7
|
) {
|
|
8
8
|
const nameValue = toValue(name);
|
|
9
9
|
const form = inject(FormContextKey, null);
|
|
@@ -14,9 +14,9 @@ export function useFormFieldWithinForm<T = string>(
|
|
|
14
14
|
);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const field = nameValue ? useField<
|
|
17
|
+
const field = nameValue ? useField<T>(nameValue, undefined) : null;
|
|
18
18
|
|
|
19
|
-
const value = field ? field.value : modelValue;
|
|
19
|
+
const value: Ref<T> = field ? field.value : modelValue;
|
|
20
20
|
|
|
21
21
|
return {
|
|
22
22
|
field,
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { MaybeRefOrGetter, ref, Ref } from 'vue';
|
|
2
|
-
import { useFormFieldWithinForm } from '
|
|
2
|
+
import { useFormFieldWithinForm } from './useFormFieldWithinForm';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* vee-validate bridge shared by the free-text fields (`InputField`, `TextAreaField`). Validation on
|
|
6
|
+
* `input` only starts once the field has been blurred, so a half-typed value is never marked
|
|
7
|
+
* invalid while the user is still filling it in.
|
|
8
|
+
*/
|
|
9
|
+
export function useTextFieldWithinForm(
|
|
5
10
|
name: MaybeRefOrGetter<string | undefined>,
|
|
6
11
|
modelValue: Ref<string | undefined>,
|
|
7
12
|
) {
|
package/lib/js/index.ts
CHANGED
|
@@ -53,9 +53,15 @@ export { default as NumberInCircle } from './components/NumberInCircle';
|
|
|
53
53
|
export { default as DsNumberInCircle } from './components/NumberInCircle';
|
|
54
54
|
export * from './components/NumberInCircle/NumberInCircle.consts';
|
|
55
55
|
export { default as DsPasswordField } from './components/Form/PasswordField';
|
|
56
|
+
export { default as DsPinInputField } from './components/Form/PinInputField';
|
|
57
|
+
export * from './components/Form/PinInputField';
|
|
58
|
+
export { default as DsSelectField } from './components/Form/SelectField';
|
|
59
|
+
export * from './components/Form/SelectField';
|
|
56
60
|
export { default as TabItem } from './components/TabItem';
|
|
57
61
|
export { default as DsTabItem } from './components/TabItem';
|
|
58
62
|
export * from './components/TabItem/TabItem.consts';
|
|
63
|
+
export { default as DsTextAreaField } from './components/Form/TextAreaField';
|
|
64
|
+
export * from './components/Form/TextAreaField';
|
|
59
65
|
export { default as Tile } from './components/Tile';
|
|
60
66
|
export { default as DsTile } from './components/Tile';
|
|
61
67
|
export * from './components/Tile/Tile.consts';
|
|
@@ -23,6 +23,22 @@
|
|
|
23
23
|
box-shadow: $shadow-xl;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
&.-ds-shadowTopS {
|
|
27
|
+
box-shadow: $shadow-top-s;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&.-ds-shadowTopM {
|
|
31
|
+
box-shadow: $shadow-top-m;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&.-ds-shadowTopL {
|
|
35
|
+
box-shadow: $shadow-top-l;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&.-ds-shadowTopXl {
|
|
39
|
+
box-shadow: $shadow-top-xl;
|
|
40
|
+
}
|
|
41
|
+
|
|
26
42
|
&.-ds-shadowInsetS {
|
|
27
43
|
box-shadow: $shadow-inset-s;
|
|
28
44
|
}
|