draft-components 2.10.3 → 3.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/css/draft-components-utilities.css +6 -7
- package/css/draft-components-variables.css +437 -0
- package/css/draft-components.css +1199 -617
- package/dist/components/alert/alert.css +163 -0
- package/dist/components/avatar/avatar.css +91 -0
- package/dist/components/avatar/avatar.js +3 -1
- package/dist/components/badge/badge.css +28 -0
- package/dist/components/breadcrumbs/breadcrumbs.css +72 -0
- package/dist/components/button/button.css +241 -0
- package/dist/components/button/button.js +3 -1
- package/dist/components/button/icon-button.js +1 -1
- package/dist/components/button-group/button-group.css +27 -0
- package/dist/components/caption/caption.css +36 -0
- package/dist/components/checkbox/checkbox.css +90 -0
- package/dist/components/checkbox/checkbox.js +3 -1
- package/dist/components/color-picker/color-picker.css +86 -0
- package/dist/components/date-picker/calendar-grid.js +2 -2
- package/dist/components/date-picker/date-helpers.js +3 -3
- package/dist/components/date-picker/date-picker.css +203 -0
- package/dist/components/date-picker/date-range.js +4 -2
- package/dist/components/date-picker/parse-min-max-props.js +3 -3
- package/dist/components/date-picker-popover/date-picker-popover.css +8 -0
- package/dist/components/date-range-picker-popover/date-range-picker-popover.css +73 -0
- package/dist/components/date-range-picker-popover/helpers.js +2 -2
- package/dist/components/dialog/dialog.css +173 -0
- package/dist/components/empty-state/empty-state.css +52 -0
- package/dist/components/file-picker/file-picker.css +74 -0
- package/dist/components/filter-buttons/filter-buttons.css +60 -0
- package/dist/components/filter-buttons/filter-buttons.js +2 -2
- package/dist/components/filtered-search/filter-item.css +30 -0
- package/dist/components/filtered-search/filter-operator-select.css +6 -0
- package/dist/components/filtered-search/filter-token.css +63 -0
- package/dist/components/filtered-search/filter-value-list.css +17 -0
- package/dist/components/filtered-search/filtered-search.css +284 -0
- package/dist/components/filtered-search/model/string-filter.js +4 -2
- package/dist/components/filtered-search/model/string-set-filter.js +4 -2
- package/dist/components/filtered-search/string-filter-input.css +12 -0
- package/dist/components/filtered-search/string-filter-item.js +4 -2
- package/dist/components/filtered-search/string-set-filter-item.js +3 -1
- package/dist/components/form-field/form-field.css +21 -0
- package/dist/components/form-field/form-field.js +3 -1
- package/dist/components/label/label.css +23 -0
- package/dist/components/menu/menu.css +87 -0
- package/dist/components/menu/menu.d.ts +4 -4
- package/dist/components/menu/menu.js +4 -4
- package/dist/components/nav-list/nav-list-item.js +1 -1
- package/dist/components/nav-list/nav-list.css +89 -0
- package/dist/components/password-input/password-input.css +49 -0
- package/dist/components/popover/popover.css +98 -0
- package/dist/components/popover/popover.js +3 -3
- package/dist/components/positioner/calc-position.js +4 -4
- package/dist/components/radio/radio.css +88 -0
- package/dist/components/segmented-control/segmented-control.css +113 -0
- package/dist/components/select/select.css +121 -0
- package/dist/components/selection-control/selection-control.css +36 -0
- package/dist/components/selection-control/selection-control.js +3 -1
- package/dist/components/slide-over/slide-over-body.css +7 -0
- package/dist/components/slide-over/slide-over-header.css +29 -0
- package/dist/components/slide-over/slide-over-header.js +5 -1
- package/dist/components/slide-over/slide-over.css +85 -0
- package/dist/components/slider/get-offset-relative-to-thumb.js +5 -5
- package/dist/components/slider/range-slider.d.ts +21 -21
- package/dist/components/slider/range-slider.js +15 -15
- package/dist/components/slider/slider-thumb.d.ts +16 -17
- package/dist/components/slider/slider-thumb.js +3 -3
- package/dist/components/slider/slider-track.js +7 -7
- package/dist/components/slider/slider.css +261 -0
- package/dist/components/slider/slider.d.ts +17 -17
- package/dist/components/slider/slider.js +2 -2
- package/dist/components/spinner/spinner.css +42 -0
- package/dist/components/spinner/spinner.js +1 -1
- package/dist/components/switch/switch.css +123 -0
- package/dist/components/table/table-head-cell.js +1 -1
- package/dist/components/table/table.css +176 -0
- package/dist/components/tabs/tab.js +1 -1
- package/dist/components/tabs/tabs.css +94 -0
- package/dist/components/tag/tag.css +390 -0
- package/dist/components/text-input/text-input.css +146 -0
- package/dist/components/textarea/textarea.css +82 -0
- package/dist/components/toast/toast.css +154 -0
- package/dist/components/toaster/toaster.css +95 -0
- package/dist/components/toaster/toaster.js +7 -3
- package/dist/components/tooltip/tooltip.css +34 -0
- package/dist/hooks/use-mount-transition.js +2 -2
- package/package.json +23 -18
- package/css/draft-components.dark.css +0 -609
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
.dc-text-input {
|
|
2
|
+
--dc-input-font-size: 14px;
|
|
3
|
+
--dc-input-height: 36px;
|
|
4
|
+
--dc-input-padding-x: 12px;
|
|
5
|
+
--dc-input-border-radius: 7px;
|
|
6
|
+
--dc-input-text-color: var(--dc-control-primary-text-color);
|
|
7
|
+
--dc-input-border-color: var(--dc-control-border-color);
|
|
8
|
+
--dc-input-border-color-error: var(--dc-control-error-color);
|
|
9
|
+
--dc-input-bg: var(--dc-control-bg);
|
|
10
|
+
--dc-input-add-on-color: var(--dc-control-secondary-text-color);
|
|
11
|
+
--dc-input-add-on-bg: none;
|
|
12
|
+
--dc-input-focus-ring-color: var(--dc-control-primary-color);
|
|
13
|
+
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
align-items: stretch;
|
|
17
|
+
min-width: 0;
|
|
18
|
+
max-width: 100%;
|
|
19
|
+
height: var(--dc-input-height);
|
|
20
|
+
font-family: var(--dc-primary-font);
|
|
21
|
+
font-size: var(--dc-input-font-size);
|
|
22
|
+
font-weight: 400;
|
|
23
|
+
line-height: 1;
|
|
24
|
+
color: var(--dc-input-text-color);
|
|
25
|
+
vertical-align: middle;
|
|
26
|
+
color-scheme: light;
|
|
27
|
+
background: var(--dc-input-bg);
|
|
28
|
+
border: 1px solid var(--dc-input-border-color);
|
|
29
|
+
border-radius: var(--dc-input-border-radius);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.dc-text-input > :first-child {
|
|
33
|
+
border-top-left-radius: calc(var(--dc-input-border-radius) - 1px);
|
|
34
|
+
border-bottom-left-radius: calc(var(--dc-input-border-radius) - 1px);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.dc-text-input > :last-child {
|
|
38
|
+
border-top-right-radius: calc(var(--dc-input-border-radius) - 1px);
|
|
39
|
+
border-bottom-right-radius: calc(var(--dc-input-border-radius) - 1px);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.dc-text-input:focus-within {
|
|
43
|
+
border-color: var(--dc-input-focus-ring-color);
|
|
44
|
+
box-shadow: 0 0 0 1px var(--dc-input-focus-ring-color);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.dc-text-input_disabled {
|
|
48
|
+
opacity: var(--dc-disabled-state-opacity);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.dc-text-input_invalid {
|
|
52
|
+
border-color: var(--dc-input-border-color-error);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.dc-text-input_full-width {
|
|
56
|
+
display: flex;
|
|
57
|
+
width: 100%;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.dc-text-input_sm {
|
|
61
|
+
--dc-input-font-size: 13px;
|
|
62
|
+
--dc-input-height: 32px;
|
|
63
|
+
--dc-input-padding-x: 8px;
|
|
64
|
+
--dc-input-border-radius: 6px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.dc-text-input_lg {
|
|
68
|
+
--dc-input-font-size: 15px;
|
|
69
|
+
--dc-input-height: 40px;
|
|
70
|
+
--dc-input-padding-x: 16px;
|
|
71
|
+
--dc-input-border-radius: 8px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.dc-text-input__native {
|
|
75
|
+
flex: auto;
|
|
76
|
+
min-width: 0;
|
|
77
|
+
max-width: 100%;
|
|
78
|
+
padding: 0 var(--dc-input-padding-x);
|
|
79
|
+
margin: 0;
|
|
80
|
+
font: inherit;
|
|
81
|
+
color: inherit;
|
|
82
|
+
-webkit-appearance: none;
|
|
83
|
+
-moz-appearance: none;
|
|
84
|
+
appearance: none;
|
|
85
|
+
background: none;
|
|
86
|
+
border: none;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.dc-text-input__native::-moz-placeholder {
|
|
90
|
+
color: inherit;
|
|
91
|
+
opacity: 0.4;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.dc-text-input__native::placeholder {
|
|
95
|
+
color: inherit;
|
|
96
|
+
opacity: 0.4;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.dc-text-input__native:focus {
|
|
100
|
+
outline: none;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.dc-text-input__slot-left,
|
|
104
|
+
.dc-text-input__slot-right {
|
|
105
|
+
box-sizing: border-box;
|
|
106
|
+
display: inline-flex;
|
|
107
|
+
flex: none;
|
|
108
|
+
align-items: center;
|
|
109
|
+
color: var(--dc-input-add-on-color);
|
|
110
|
+
background: var(--dc-input-add-on-bg);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.dc-text-input__slot-left {
|
|
114
|
+
padding-left: var(--dc-input-padding-x);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.dc-text-input__slot-right {
|
|
118
|
+
padding-right: var(--dc-input-padding-x);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.dc-text-input_has_slot-left:not(.dc-text-input_slot_tinted) .dc-text-input__native {
|
|
122
|
+
padding-left: calc(var(--dc-input-padding-x) / 2);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.dc-text-input_has_slot-right:not(.dc-text-input_slot_tinted) .dc-text-input__native {
|
|
126
|
+
padding-right: calc(var(--dc-input-padding-x) / 2);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.dc-text-input_slot_tinted {
|
|
130
|
+
--dc-input-add-on-bg: rgb(var(--dc-gray-400-rgb) / 10%);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.dc-text-input_slot_tinted .dc-text-input__slot-left {
|
|
134
|
+
padding-right: var(--dc-input-padding-x);
|
|
135
|
+
border-right: 1px solid var(--dc-input-border-color);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.dc-text-input_slot_tinted .dc-text-input__slot-right {
|
|
139
|
+
padding-left: var(--dc-input-padding-x);
|
|
140
|
+
border-left: 1px solid var(--dc-input-border-color);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.dark .dc-text-input,
|
|
144
|
+
.dark.dc-text-input {
|
|
145
|
+
color-scheme: dark;
|
|
146
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
.dc-textarea {
|
|
2
|
+
--dc-textarea-font-size: 14px;
|
|
3
|
+
--dc-textarea-leading: 20px;
|
|
4
|
+
--dc-textarea-padding-y: 8px;
|
|
5
|
+
--dc-textarea-padding-x: 12px;
|
|
6
|
+
--dc-textarea-radius: 7px;
|
|
7
|
+
--dc-textarea-text-color: var(--dc-primary-text-color);
|
|
8
|
+
--dc-textarea-border-color: var(--dc-control-border-color);
|
|
9
|
+
--dc-textarea-border-color-error: var(--dc-control-error-color);
|
|
10
|
+
--dc-textarea-bg: var(--dc-control-bg);
|
|
11
|
+
--dc-textarea-focus-ring-color: var(--dc-control-primary-color);
|
|
12
|
+
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
display: inline-block;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
width: auto;
|
|
17
|
+
min-width: 0;
|
|
18
|
+
max-width: 100%;
|
|
19
|
+
min-height: calc(var(--dc-textarea-leading) + var(--dc-textarea-padding-y) * 2);
|
|
20
|
+
padding: var(--dc-textarea-padding-y) var(--dc-textarea-padding-x);
|
|
21
|
+
margin-top: 0;
|
|
22
|
+
margin-bottom: 0;
|
|
23
|
+
font-family: var(--dc-primary-font);
|
|
24
|
+
font-size: var(--dc-textarea-font-size);
|
|
25
|
+
line-height: var(--dc-textarea-leading);
|
|
26
|
+
color: var(--dc-textarea-text-color);
|
|
27
|
+
color-scheme: light;
|
|
28
|
+
background: var(--dc-textarea-bg);
|
|
29
|
+
border: 1px solid var(--dc-textarea-border-color);
|
|
30
|
+
border-radius: var(--dc-textarea-radius);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.dc-textarea::-moz-placeholder {
|
|
34
|
+
color: inherit;
|
|
35
|
+
opacity: 0.4;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.dc-textarea::placeholder {
|
|
39
|
+
color: inherit;
|
|
40
|
+
opacity: 0.4;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.dc-textarea:focus {
|
|
44
|
+
border-color: var(--dc-textarea-focus-ring-color);
|
|
45
|
+
outline: none;
|
|
46
|
+
box-shadow: 0 0 0 1px var(--dc-textarea-focus-ring-color);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.dc-textarea_disabled {
|
|
50
|
+
opacity: var(--dc-disabled-state-opacity);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.dc-textarea_invalid {
|
|
54
|
+
border-color: var(--dc-textarea-border-color-error);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.dc-textarea_full-width {
|
|
58
|
+
display: block;
|
|
59
|
+
width: 100%;
|
|
60
|
+
resize: vertical;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.dc-textarea_sm {
|
|
64
|
+
--dc-textarea-font-size: 13px;
|
|
65
|
+
--dc-textarea-leading: 16px;
|
|
66
|
+
--dc-textarea-padding-y: 8px;
|
|
67
|
+
--dc-textarea-padding-x: 8px;
|
|
68
|
+
--dc-textarea-radius: 6px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.dc-textarea_lg {
|
|
72
|
+
--dc-textarea-font-size: 15px;
|
|
73
|
+
--dc-textarea-leading: 24px;
|
|
74
|
+
--dc-textarea-padding-y: 12px;
|
|
75
|
+
--dc-textarea-padding-x: 16px;
|
|
76
|
+
--dc-textarea-radius: 8px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.dark .dc-textarea,
|
|
80
|
+
.dark.dc-textarea {
|
|
81
|
+
color-scheme: dark;
|
|
82
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
.dc-toast {
|
|
2
|
+
--dc-toast-text-color: var(--dc-gray-100);
|
|
3
|
+
--dc-toast-secondary-text-color: var(--dc-gray-300);
|
|
4
|
+
--dc-toast-icon-color: var(--dc-gray-200);
|
|
5
|
+
--dc-toast-bg: var(--dc-gray-700);
|
|
6
|
+
--dc-toast-padding: 16px;
|
|
7
|
+
--dc-toast-close-btn-color: var(--dc-gray-50);
|
|
8
|
+
--dc-toast-close-btn-bg: var(--dc-gray-500);
|
|
9
|
+
--dc-toast-btn-text-color: var(--dc-gray-100);
|
|
10
|
+
--dc-toast-btn-bg: rgb(var(--dc-gray-50-rgb) / 15%);
|
|
11
|
+
--dc-toast-btn-bg-hover: rgb(var(--dc-gray-50-rgb) / 30%);
|
|
12
|
+
--dc-toast-btn-focus-ring-color: var(--dc-gray-200);
|
|
13
|
+
|
|
14
|
+
position: relative;
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
min-width: 256px;
|
|
17
|
+
font: var(--dc-text-sm);
|
|
18
|
+
color: var(--dc-toast-text-color);
|
|
19
|
+
text-align: left;
|
|
20
|
+
color-scheme: light;
|
|
21
|
+
background: var(--dc-toast-bg);
|
|
22
|
+
border-radius: 10px;
|
|
23
|
+
box-shadow: var(--dc-shadow-lg);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.dc-toast__close-btn {
|
|
27
|
+
position: absolute;
|
|
28
|
+
top: -8px;
|
|
29
|
+
left: -8px;
|
|
30
|
+
box-sizing: border-box;
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
width: 24px;
|
|
35
|
+
height: 24px;
|
|
36
|
+
padding: 0;
|
|
37
|
+
color: var(--dc-toast-close-btn-color);
|
|
38
|
+
-webkit-appearance: none;
|
|
39
|
+
-moz-appearance: none;
|
|
40
|
+
appearance: none;
|
|
41
|
+
pointer-events: none;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
background: var(--dc-toast-close-btn-bg);
|
|
44
|
+
border: none;
|
|
45
|
+
border-radius: 50%;
|
|
46
|
+
box-shadow:
|
|
47
|
+
var(--dc-shadow-sm),
|
|
48
|
+
var(--dc-shadow-md);
|
|
49
|
+
opacity: 0;
|
|
50
|
+
transition: opacity 150ms ease;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.dc-toast:hover .dc-toast__close-btn {
|
|
54
|
+
pointer-events: all;
|
|
55
|
+
opacity: 1;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.dc-toast__btn {
|
|
59
|
+
box-sizing: border-box;
|
|
60
|
+
padding: 4px 12px;
|
|
61
|
+
font: var(--dc-text-xs);
|
|
62
|
+
color: var(--dc-toast-btn-text-color);
|
|
63
|
+
-webkit-appearance: none;
|
|
64
|
+
-moz-appearance: none;
|
|
65
|
+
appearance: none;
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
background: var(--dc-toast-btn-bg);
|
|
68
|
+
border: none;
|
|
69
|
+
border-radius: 6px;
|
|
70
|
+
transition: 100ms ease;
|
|
71
|
+
transition-property: background-color, box-shadow;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.dc-toast__btn:hover {
|
|
75
|
+
background: var(--dc-toast-btn-bg-hover);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.dc-toast__btn:focus {
|
|
79
|
+
background: var(--dc-toast-btn-bg-hover);
|
|
80
|
+
outline: none;
|
|
81
|
+
box-shadow: 0 0 0 1px var(--dc-toast-btn-focus-ring-color);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.dc-toast__btn:focus:not(:focus-visible) {
|
|
85
|
+
box-shadow: none;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.dc-toast__btn:focus:not(:focus-visible, :hover) {
|
|
89
|
+
background: var(--dc-toast-btn-bg);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.dc-toast__body {
|
|
93
|
+
display: flex;
|
|
94
|
+
flex-grow: 1;
|
|
95
|
+
align-items: flex-start;
|
|
96
|
+
padding: 12px 16px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.dc-toast__actions {
|
|
100
|
+
box-sizing: border-box;
|
|
101
|
+
display: flex;
|
|
102
|
+
flex-direction: column;
|
|
103
|
+
padding: 4px;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.dc-toast__actions > * + * {
|
|
107
|
+
margin-top: 2px;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.dc-toast__content {
|
|
111
|
+
box-sizing: border-box;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.dc-toast__icon {
|
|
115
|
+
display: inline-flex;
|
|
116
|
+
flex-shrink: 0;
|
|
117
|
+
margin-right: 12px;
|
|
118
|
+
color: var(--dc-toast-icon-color);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.dc-toast__title {
|
|
122
|
+
margin: 0;
|
|
123
|
+
font: inherit;
|
|
124
|
+
font-weight: 500;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.dc-toast__message {
|
|
128
|
+
margin-top: 0.25em;
|
|
129
|
+
color: var(--dc-toast-secondary-text-color);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.dark .dc-toast,
|
|
133
|
+
.dark.dc-toast {
|
|
134
|
+
--dc-toast-text-color: var(--dc-gray-800);
|
|
135
|
+
--dc-toast-secondary-text-color: var(--dc-gray-600);
|
|
136
|
+
--dc-toast-icon-color: var(--dc-gray-700);
|
|
137
|
+
--dc-toast-bg: var(--dc-gray-100);
|
|
138
|
+
--dc-toast-close-btn-color: var(--dc-gray-800);
|
|
139
|
+
--dc-toast-close-btn-bg: var(--dc-gray-100);
|
|
140
|
+
--dc-toast-btn-text-color: var(--dc-gray-800);
|
|
141
|
+
--dc-toast-btn-bg: rgb(var(--dc-gray-900-rgb) / 10%);
|
|
142
|
+
--dc-toast-btn-bg-hover: rgb(var(--dc-gray-900-rgb) / 20%);
|
|
143
|
+
--dc-toast-btn-focus-ring-color: var(--dc-gray-700);
|
|
144
|
+
|
|
145
|
+
color-scheme: dark;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.dark .dc-toast .dc-toast__close-btn,
|
|
149
|
+
.dark.dc-toast .dc-toast__close-btn {
|
|
150
|
+
box-shadow:
|
|
151
|
+
0 0 0 1px rgb(var(--dc-black-rgb) / 10%),
|
|
152
|
+
var(--dc-shadow-sm),
|
|
153
|
+
var(--dc-shadow-md);
|
|
154
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
.dc-toasts-list {
|
|
2
|
+
--dc-toaster-padding: 16px;
|
|
3
|
+
--dc-toaster-animation: 200ms ease;
|
|
4
|
+
|
|
5
|
+
position: fixed;
|
|
6
|
+
right: var(--dc-toaster-padding);
|
|
7
|
+
left: var(--dc-toaster-padding);
|
|
8
|
+
z-index: var(--dc-toaster-z-index);
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
padding: 0;
|
|
11
|
+
margin: 0;
|
|
12
|
+
list-style: none;
|
|
13
|
+
color-scheme: light;
|
|
14
|
+
pointer-events: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.dc-toasts-list_top-left,
|
|
18
|
+
.dc-toasts-list_top-center,
|
|
19
|
+
.dc-toasts-list_top-right {
|
|
20
|
+
top: var(--dc-toaster-padding);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.dc-toasts-list_bottom-left,
|
|
24
|
+
.dc-toasts-list_bottom-center,
|
|
25
|
+
.dc-toasts-list_bottom-right {
|
|
26
|
+
bottom: var(--dc-toaster-padding);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.dc-toasts-list > * {
|
|
30
|
+
position: absolute;
|
|
31
|
+
right: 0;
|
|
32
|
+
left: 0;
|
|
33
|
+
transition: transform var(--dc-toaster-animation);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.dc-toasts-list_top-left > *,
|
|
37
|
+
.dc-toasts-list_bottom-left > * {
|
|
38
|
+
text-align: left;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.dc-toasts-list_top-center > *,
|
|
42
|
+
.dc-toasts-list_bottom-center > * {
|
|
43
|
+
text-align: center;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.dc-toasts-list_top-right > *,
|
|
47
|
+
.dc-toasts-list_bottom-right > * {
|
|
48
|
+
text-align: right;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.dc-toasts-list__toast {
|
|
52
|
+
pointer-events: all;
|
|
53
|
+
animation: var(--dc-toaster-animation) forwards;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@keyframes dc-toast-slide-top {
|
|
57
|
+
0% {
|
|
58
|
+
opacity: 0;
|
|
59
|
+
transform: translateY(-100%);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
100% {
|
|
63
|
+
opacity: 1;
|
|
64
|
+
transform: translateY(0);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.dc-toasts-list_top-left .dc-toasts-list__toast,
|
|
69
|
+
.dc-toasts-list_top-center .dc-toasts-list__toast,
|
|
70
|
+
.dc-toasts-list_top-right .dc-toasts-list__toast {
|
|
71
|
+
animation-name: dc-toast-slide-top;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@keyframes dc-toast-slide-bottom {
|
|
75
|
+
0% {
|
|
76
|
+
opacity: 0;
|
|
77
|
+
transform: translateY(0);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
100% {
|
|
81
|
+
opacity: 1;
|
|
82
|
+
transform: translateY(-100%);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.dc-toasts-list_bottom-left .dc-toasts-list__toast,
|
|
87
|
+
.dc-toasts-list_bottom-center .dc-toasts-list__toast,
|
|
88
|
+
.dc-toasts-list_bottom-right .dc-toasts-list__toast {
|
|
89
|
+
animation-name: dc-toast-slide-bottom;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.dark .dc-toaster,
|
|
93
|
+
.dark.dc-toaster {
|
|
94
|
+
color-scheme: dark;
|
|
95
|
+
}
|
|
@@ -9,6 +9,10 @@ const isToastShowEvent = (event) => (event instanceof CustomEvent && event.type
|
|
|
9
9
|
const TOAST_HIDE_EVENT = 'toast_hide';
|
|
10
10
|
const isToastHideEvent = (event) => (event instanceof CustomEvent && event.type === TOAST_HIDE_EVENT);
|
|
11
11
|
export class Toaster {
|
|
12
|
+
_id;
|
|
13
|
+
timeoutMs;
|
|
14
|
+
onShow;
|
|
15
|
+
onHide;
|
|
12
16
|
constructor(params) {
|
|
13
17
|
this._id = 0;
|
|
14
18
|
this.timeoutMs = params?.timeoutMs || 10000;
|
|
@@ -82,9 +86,9 @@ function ToastsList({ toaster, toastGap = 12, toastPosition = 'top-center', toas
|
|
|
82
86
|
if (item instanceof HTMLLIElement) {
|
|
83
87
|
item.style.transform = `translateY(${offset}px)`;
|
|
84
88
|
const d = item.offsetHeight + toastGap;
|
|
85
|
-
if (toastPosition === 'top-right'
|
|
86
|
-
toastPosition === 'top-center'
|
|
87
|
-
toastPosition === 'top-left') {
|
|
89
|
+
if (toastPosition === 'top-right'
|
|
90
|
+
|| toastPosition === 'top-center'
|
|
91
|
+
|| toastPosition === 'top-left') {
|
|
88
92
|
offset += d;
|
|
89
93
|
}
|
|
90
94
|
else {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.dc-tooltip {
|
|
2
|
+
--dc-tooltip-text-color: var(--dc-gray-50);
|
|
3
|
+
--dc-tooltip-bg: var(--dc-gray-700);
|
|
4
|
+
--dc-tooltip-transition-duration: 100ms;
|
|
5
|
+
|
|
6
|
+
top: 0;
|
|
7
|
+
left: 0;
|
|
8
|
+
z-index: var(--dc-overlay-z-index);
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
padding: 4px 8px;
|
|
11
|
+
font: var(--dc-text-xs);
|
|
12
|
+
color: var(--dc-tooltip-text-color);
|
|
13
|
+
color-scheme: light;
|
|
14
|
+
background: var(--dc-tooltip-bg);
|
|
15
|
+
border-radius: 6px;
|
|
16
|
+
box-shadow: var(--dc-shadow-md);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.dc-tooltip_hidden {
|
|
20
|
+
opacity: 0;
|
|
21
|
+
transition: opacity var(--dc-tooltip-transition-duration) ease;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.dc-tooltip_visible {
|
|
25
|
+
opacity: 1;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.dark .dc-tooltip,
|
|
29
|
+
.dark.dc-tooltip {
|
|
30
|
+
--dc-tooltip-text-color: var(--dc-gray-800);
|
|
31
|
+
--dc-tooltip-bg: var(--dc-gray-100);
|
|
32
|
+
|
|
33
|
+
color-scheme: dark;
|
|
34
|
+
}
|
|
@@ -8,8 +8,8 @@ export function useMountTransition({ animateFirstMount = false, isShown, duratio
|
|
|
8
8
|
const [hasEnterToClass, setHasEnterToClass] = useState(false);
|
|
9
9
|
const firstMount = useRef(true);
|
|
10
10
|
const prefersReducedMotion = useMemo(() => window.matchMedia('(prefers-reduced-motion: reduce)'), []);
|
|
11
|
-
const disableTransition = (prefersReducedMotion.matches
|
|
12
|
-
(!animateFirstMount && firstMount.current));
|
|
11
|
+
const disableTransition = (prefersReducedMotion.matches
|
|
12
|
+
|| (!animateFirstMount && firstMount.current));
|
|
13
13
|
if (disableTransition) {
|
|
14
14
|
durationMs = 0;
|
|
15
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "draft-components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "The React based UI components library.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -8,11 +8,14 @@
|
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"import": "./dist/index.js"
|
|
10
10
|
},
|
|
11
|
+
"./components/*": "./dist/components/*",
|
|
12
|
+
"./hooks/*": "./dist/hooks/*",
|
|
13
|
+
"./lib/*": "./dist/lib/*",
|
|
11
14
|
"./css/*": "./css/*"
|
|
12
15
|
},
|
|
13
16
|
"types": "./dist/index.d.ts",
|
|
14
17
|
"engines": {
|
|
15
|
-
"node": ">=
|
|
18
|
+
"node": ">= 18"
|
|
16
19
|
},
|
|
17
20
|
"files": [
|
|
18
21
|
"dist",
|
|
@@ -23,7 +26,7 @@
|
|
|
23
26
|
"test": "vitest run",
|
|
24
27
|
"coverage": "vitest run --coverage",
|
|
25
28
|
"lint": "npm run lint-js && npm run lint-css",
|
|
26
|
-
"lint-js": "eslint '**/*.
|
|
29
|
+
"lint-js": "eslint '**/*.[jt]s?(x)'",
|
|
27
30
|
"lint-css": "stylelint 'src/**/*.css'",
|
|
28
31
|
"typecheck": "tsc --project 'tsconfig.json' --noEmit",
|
|
29
32
|
"prebuild": "npm run typecheck && npm run lint && npm run test",
|
|
@@ -52,7 +55,6 @@
|
|
|
52
55
|
"react-dom": ">= 18"
|
|
53
56
|
},
|
|
54
57
|
"devDependencies": {
|
|
55
|
-
"@alexzimakov/eslint-config": "1.8.0",
|
|
56
58
|
"@heroicons/react": "2.1.1",
|
|
57
59
|
"@storybook/addon-actions": "7.6.7",
|
|
58
60
|
"@storybook/addon-essentials": "7.6.7",
|
|
@@ -60,37 +62,40 @@
|
|
|
60
62
|
"@storybook/addon-themes": "7.6.7",
|
|
61
63
|
"@storybook/react": "7.6.7",
|
|
62
64
|
"@storybook/react-vite": "7.6.7",
|
|
65
|
+
"@stylistic/eslint-plugin": "1.6.3",
|
|
63
66
|
"@testing-library/dom": "9.3.3",
|
|
64
67
|
"@testing-library/jest-dom": "6.2.0",
|
|
65
68
|
"@testing-library/react": "14.1.2",
|
|
66
69
|
"@testing-library/user-event": "14.5.2",
|
|
67
|
-
"@types/node": "20.10.
|
|
68
|
-
"@types/react": "18.2.
|
|
70
|
+
"@types/node": "20.10.7",
|
|
71
|
+
"@types/react": "18.2.47",
|
|
69
72
|
"@types/react-dom": "18.2.18",
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "
|
|
71
|
-
"@typescript-eslint/parser": "
|
|
72
|
-
"@vitest/coverage-istanbul": "1.1.
|
|
73
|
+
"@typescript-eslint/eslint-plugin": "7.1.1",
|
|
74
|
+
"@typescript-eslint/parser": "7.1.1",
|
|
75
|
+
"@vitest/coverage-istanbul": "1.1.3",
|
|
73
76
|
"autoprefixer": "10.4.16",
|
|
74
|
-
"
|
|
77
|
+
"color": "4.2.3",
|
|
78
|
+
"eslint": "8.57.0",
|
|
75
79
|
"eslint-plugin-jsx-a11y": "6.8.0",
|
|
76
|
-
"eslint-plugin-react": "7.
|
|
80
|
+
"eslint-plugin-react": "7.34.0",
|
|
77
81
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
78
|
-
"eslint-plugin-storybook": "0.
|
|
82
|
+
"eslint-plugin-storybook": "0.8.0",
|
|
79
83
|
"eslint-plugin-testing-library": "6.2.0",
|
|
84
|
+
"glob": "10.3.10",
|
|
80
85
|
"husky": "8.0.3",
|
|
81
|
-
"jsdom": "23.0
|
|
86
|
+
"jsdom": "23.2.0",
|
|
82
87
|
"lint-staged": "15.2.0",
|
|
83
|
-
"postcss": "8.4.
|
|
88
|
+
"postcss": "8.4.33",
|
|
84
89
|
"postcss-import": "16.0.0",
|
|
85
90
|
"react": "18.2.0",
|
|
86
91
|
"react-dom": "18.2.0",
|
|
87
92
|
"storybook": "7.6.7",
|
|
88
|
-
"stylelint": "16.1
|
|
93
|
+
"stylelint": "16.2.1",
|
|
94
|
+
"stylelint-config-recess-order": "5.0.0",
|
|
89
95
|
"stylelint-config-standard": "36.0.0",
|
|
90
|
-
"stylelint-order": "6.0.4",
|
|
91
96
|
"typescript": "5.3.3",
|
|
92
|
-
"vite": "5.0.
|
|
93
|
-
"vitest": "1.1.
|
|
97
|
+
"vite": "5.0.11",
|
|
98
|
+
"vitest": "1.1.3"
|
|
94
99
|
},
|
|
95
100
|
"lint-staged": {
|
|
96
101
|
"*.ts?(x)": "npm run lint-js",
|