@helsenorge/datepicker 6.3.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.
@@ -0,0 +1,27 @@
1
+ import { CSSProperties } from 'react';
2
+ import { PopOverVariant } from '@helsenorge/designsystem-react/components/PopOver';
3
+ /**
4
+ * Beregn om hjelpeboblen skal vises over eller under kontrolleren
5
+ * @param controllerSize DOMRect for controlleren
6
+ * @param bubbleSize DOMRect for hjelpeboblen
7
+ * @param variant Ønsket plassering av hjelpeboblen (over/under/automatisk)
8
+ * @returns Om hjelpeboblen skal vises over eller under
9
+ */
10
+ export declare const getVerticalPosition: (controllerSize: DOMRect, bubbleSize: DOMRect) => keyof typeof PopOverVariant;
11
+ /**
12
+ * Finn riktig plassering av hjelpeboblen
13
+ * @param controllerSize DOMRect for controlleren
14
+ * @param bubbleSize DOMRect for hjelpeboblen
15
+ * @param variant Ønsket plassering av hjelpeboblen (over/under)
16
+ * @returns CSSProperties som plasserer hjelpeboblen riktig
17
+ */
18
+ export declare const getBubbleStyle: (controllerSize: DOMRect, bubbleSize: DOMRect) => CSSProperties;
19
+ /**
20
+ * Finn riktig plassering av pilen
21
+ * @param bubbleStyle CSSProperties for hjelpeboblen
22
+ * @param controllerSize DOMRect for kontrolleren
23
+ * @param verticalPosition Ønsket plassering av hjelpeboblen (over/under)
24
+ * @returns CSSProperties som plasserer pilen riktig
25
+ */
26
+ export declare const getArrowStyle: (bubbleStyle: CSSProperties, controllerSize: DOMRect, verticalPosition: keyof typeof PopOverVariant) => CSSProperties;
27
+ //# sourceMappingURL=position-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"position-utils.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/position-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AAkBnF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,mBAAoB,OAAO,cAAc,OAAO,KAAG,MAAM,qBAMxF,CAAC;AA6JF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,mBAAoB,OAAO,cAAc,OAAO,KAAG,aA0B7E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,gBACX,aAAa,kBACV,OAAO,oBACL,MAAM,qBAAqB,KAC5C,aA+BF,CAAC"}
@@ -0,0 +1,303 @@
1
+ @use 'sass:map';
2
+ @import '@helsenorge/designsystem-react/scss/spacers';
3
+ @import '@helsenorge/designsystem-react/scss/breakpoints';
4
+ @import '@helsenorge/designsystem-react/scss/palette';
5
+ @import '@helsenorge/designsystem-react/scss/font-settings';
6
+ @import '@helsenorge/designsystem-react/scss/title';
7
+
8
+ .date-time-picker-wrapper {
9
+ display: flex;
10
+ align-items: flex-end;
11
+ flex-flow: row wrap;
12
+ border: none;
13
+ padding: 0;
14
+ margin: 0;
15
+
16
+ @media (min-width: map.get($grid-breakpoints, sm)) {
17
+ flex-flow: row nowrap;
18
+ }
19
+
20
+ &__date-picker {
21
+ flex: 100%;
22
+ margin-right: getSpacer(l);
23
+
24
+ @media (min-width: map.get($grid-breakpoints, sm)) {
25
+ flex: unset;
26
+ }
27
+ }
28
+
29
+ &__legend {
30
+ @include legend;
31
+
32
+ margin-bottom: getSpacer(m);
33
+ margin-top: 0;
34
+ }
35
+ }
36
+
37
+ .time-separator {
38
+ display: flex;
39
+ align-items: center;
40
+ padding: 0 getSpacer(2xs);
41
+ }
42
+
43
+ .datepicker-popup-container {
44
+ position: fixed;
45
+ visibility: hidden;
46
+ z-index: 10;
47
+
48
+ &--visible {
49
+ visibility: visible;
50
+ }
51
+ }
52
+
53
+ .datepicker-popup-arrow {
54
+ --drop-shadow-color: #{$blueberry500};
55
+
56
+ width: 0;
57
+ height: 0;
58
+ position: fixed;
59
+ visibility: hidden;
60
+ border-style: solid;
61
+ border-color: transparent;
62
+ z-index: 10;
63
+
64
+ &--visible {
65
+ visibility: visible;
66
+ }
67
+
68
+ &--over {
69
+ border-width: 0.625rem;
70
+ border-bottom-color: $white;
71
+ filter: drop-shadow(var(--drop-shadow-color) 0 0.125rem 0.375rem 0.125rem);
72
+ filter: drop-shadow(0 -0.185rem 0 var(--drop-shadow-color));
73
+ }
74
+
75
+ &--under {
76
+ border-width: 0.625rem;
77
+ border-top-color: $white;
78
+ filter: drop-shadow(var(--drop-shadow-color) 0 0.125rem 0.375rem 0.125rem);
79
+ filter: drop-shadow(0 0.2rem 0 var(--drop-shadow-color));
80
+ }
81
+ }
82
+
83
+ .date-button {
84
+ position: absolute;
85
+ z-index: 9;
86
+ right: 0.1rem;
87
+ top: 0.1rem;
88
+
89
+ &__inner {
90
+ min-height: 2.5rem;
91
+
92
+ @media (min-width: map.get($grid-breakpoints, md)) {
93
+ min-height: 3.125rem;
94
+ }
95
+ }
96
+ }
97
+
98
+ .footer-wrapper {
99
+ display: flex;
100
+ align-items: flex-end;
101
+ justify-content: flex-end;
102
+ }
103
+
104
+ // Overstyrer klasser til datedaypicker pakken https://github.com/gpbl/react-day-picker/blob/main/src/style.css
105
+ /* stylelint-disable */
106
+ .root {
107
+ --rdp-cell-size: getSpacer(l);
108
+ --rdp-background-color: #e7edff;
109
+
110
+ background-color: $white;
111
+ padding: getSpacer(s) getSpacer(s) getSpacer(xs);
112
+ border: 2px solid $blueberry500;
113
+ }
114
+
115
+ .month {
116
+ width: 100%;
117
+ }
118
+
119
+ .table {
120
+ width: 100%;
121
+ margin: 0 getSpacer(3xs) * -1 getSpacer(4xs) * -1;
122
+ border-spacing: getSpacer(3xs) getSpacer(4xs);
123
+ border-collapse: separate;
124
+
125
+ @media (min-width: map.get($grid-breakpoints, sm)) {
126
+ margin: 0 getSpacer(xs) * -1 getSpacer(3xs) * -1;
127
+ border-spacing: getSpacer(xs) getSpacer(3xs);
128
+ }
129
+ }
130
+
131
+ .head_cell {
132
+ color: $neutral700;
133
+ font-family: 'Source Sans Pro', sans-serif;
134
+ font-size: $font-size-sm;
135
+ font-weight: 400;
136
+ text-transform: capitalize;
137
+ }
138
+
139
+ .day {
140
+ font-size: $font-size-sm;
141
+ font-weight: 600;
142
+ font-family: 'Source Sans Pro', sans-serif;
143
+ color: $blueberry600;
144
+ display: flex;
145
+ overflow: hidden;
146
+ align-items: center;
147
+ justify-content: center;
148
+ box-sizing: border-box;
149
+ width: getSpacer(l);
150
+ max-width: getSpacer(l);
151
+ height: getSpacer(l);
152
+ margin: 0;
153
+ border: 2px solid transparent;
154
+ border-radius: 0;
155
+
156
+ &:focus-visible:not([disabled]),
157
+ &:focus:not([disabled]) {
158
+ background-color: $neutral100;
159
+ color: $blueberry600;
160
+ text-decoration: underline 2px $blueberry600;
161
+ outline: none;
162
+ }
163
+
164
+ &:hover:not([disabled]):not(._day_selected) {
165
+ background-color: $neutral100;
166
+ }
167
+
168
+ &--today {
169
+ background-color: $blueberry100;
170
+ color: $blueberry600;
171
+
172
+ &:hover:not([disabled]):not(._day_selected) {
173
+ background-color: $blueberry200;
174
+ }
175
+
176
+ &:focus-visible:not([disabled]),
177
+ &:focus:not([disabled]) {
178
+ background-color: $blueberry200;
179
+ text-decoration: underline 2px $blueberry600;
180
+ outline: none;
181
+ }
182
+ }
183
+
184
+ &--disabled:not(.day_selected) {
185
+ opacity: 1 !important;
186
+ color: $neutral400;
187
+
188
+ &:hover {
189
+ background-color: $white;
190
+ }
191
+ }
192
+ }
193
+
194
+ .day_selected {
195
+ background-color: $blueberry500;
196
+ color: $white;
197
+
198
+ &:hover:not([disabled]):not(._day_selected) {
199
+ background-color: $blueberry700;
200
+ }
201
+
202
+ &:focus-visible:not([disabled]),
203
+ &:focus:not([disabled]) {
204
+ background-color: $blueberry700;
205
+ color: $white;
206
+ text-decoration: underline 2px $white;
207
+ outline: none;
208
+ }
209
+ }
210
+
211
+ .day:hover {
212
+ background-color: $neutral100;
213
+ }
214
+
215
+ .dropdown {
216
+ appearance: none;
217
+ position: absolute;
218
+ z-index: 2;
219
+ top: 0;
220
+ bottom: 0;
221
+ left: 0;
222
+ width: 100%;
223
+ margin: 0;
224
+ padding: 0;
225
+ cursor: pointer;
226
+ opacity: 0;
227
+ border: none;
228
+ background-color: transparent;
229
+ font-size: $font-size-sm;
230
+ line-height: inherit;
231
+ text-transform: capitalize;
232
+
233
+ &:disabled {
234
+ opacity: unset;
235
+ color: unset;
236
+ }
237
+
238
+ &:focus-visible:not([disabled]) + .caption_label,
239
+ &:focus:not([disabled]) + .caption_label {
240
+ box-shadow: 0 0 0 4px $neutral900;
241
+ border-radius: 0;
242
+ }
243
+ }
244
+
245
+ .caption_label {
246
+ position: relative;
247
+ z-index: 1;
248
+ display: inline-flex;
249
+ align-items: center;
250
+ margin: 0;
251
+ white-space: nowrap;
252
+ color: currentColor;
253
+ border: 2px solid transparent;
254
+ font-size: $font-size-sm;
255
+ font-family: 'Source Sans Pro', sans-serif;
256
+ font-weight: 600;
257
+ }
258
+
259
+ .dropdown_month,
260
+ .dropdown_year {
261
+ color: $blueberry600;
262
+ position: relative;
263
+ display: inline-flex;
264
+ align-items: center;
265
+ text-transform: capitalize;
266
+ font-size: $font-size-md;
267
+ font-weight: 600;
268
+ }
269
+
270
+ .dropdown_month {
271
+ margin-right: getSpacer(2xs);
272
+ }
273
+
274
+ .nav_button {
275
+ display: inline-flex;
276
+ align-items: center;
277
+ justify-content: center;
278
+ width: 2.375rem;
279
+ height: 2.375rem;
280
+ padding: 0.25em;
281
+ border-radius: 0;
282
+
283
+ &[disabled] {
284
+ margin-left: getSpacer(xs);
285
+ }
286
+
287
+ &:focus-visible:not([disabled]),
288
+ &:focus:not([disabled]) {
289
+ box-shadow: 0 0 0 4px $neutral900;
290
+ background-color: $neutral100;
291
+ }
292
+
293
+ &:hover:not([disabled]):not(.day_selected) {
294
+ background-color: $neutral100;
295
+ }
296
+ }
297
+
298
+ .nav_button_next,
299
+ .nav_button_next[disabled],
300
+ .nav_button_next[disabled]:not(.day_selected) {
301
+ margin-left: getSpacer(2xs);
302
+ }
303
+ /* stylelint-enable */
@@ -0,0 +1,36 @@
1
+ export type Styles = {
2
+ _day_selected: string;
3
+ caption_label: string;
4
+ 'date-button': string;
5
+ 'date-button__inner': string;
6
+ 'date-time-picker-wrapper': string;
7
+ 'date-time-picker-wrapper__date-picker': string;
8
+ 'date-time-picker-wrapper__legend': string;
9
+ 'datepicker-popup-arrow': string;
10
+ 'datepicker-popup-arrow--over': string;
11
+ 'datepicker-popup-arrow--under': string;
12
+ 'datepicker-popup-arrow--visible': string;
13
+ 'datepicker-popup-container': string;
14
+ 'datepicker-popup-container--visible': string;
15
+ day: string;
16
+ day_selected: string;
17
+ 'day--disabled': string;
18
+ 'day--today': string;
19
+ dropdown: string;
20
+ dropdown_month: string;
21
+ dropdown_year: string;
22
+ 'footer-wrapper': string;
23
+ head_cell: string;
24
+ month: string;
25
+ nav_button: string;
26
+ nav_button_next: string;
27
+ root: string;
28
+ table: string;
29
+ 'time-separator': string;
30
+ };
31
+
32
+ export type ClassNames = keyof Styles;
33
+
34
+ declare const styles: Styles;
35
+
36
+ export default styles;
@@ -0,0 +1,18 @@
1
+ export declare const parseInputDate: (dateString: string) => Date | null;
2
+ export declare const isValidDate: (dateString: string) => boolean;
3
+ /** react-hook-form fromDate and toDate validation */
4
+ export declare const validateMinMaxDate: (date: string, errorMessage: string, minDate?: Date, maxDate?: Date) => string | true;
5
+ /** react-hook-form fromDate and toDate validation */
6
+ export declare const validateDisabledDates: (date: string, disabledDates: Date[], errorMessage: string) => string | true;
7
+ /** react-hook-form fromTime and toTime validation */
8
+ export declare const validateMinTimeMaxTime: (time: {
9
+ hour: number;
10
+ minute: number;
11
+ }, errorMessage: string, minTime?: {
12
+ hour: number;
13
+ minute: number;
14
+ }, maxTime?: {
15
+ hour: number;
16
+ minute: number;
17
+ }) => string | true;
18
+ //# sourceMappingURL=validate-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-utils.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/validate-utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,eAAgB,MAAM,KAAG,IAAI,GAAG,IAW1D,CAAC;AAEF,eAAO,MAAM,WAAW,eAAgB,MAAM,KAAG,OAGhD,CAAC;AAEF,qDAAqD;AACrD,eAAO,MAAM,kBAAkB,SAAU,MAAM,gBAAgB,MAAM,YAAY,IAAI,YAAY,IAAI,KAAG,MAAM,GAAG,IAqBhH,CAAC;AAEF,qDAAqD;AACrD,eAAO,MAAM,qBAAqB,SAAU,MAAM,iBAAiB,IAAI,EAAE,gBAAgB,MAAM,KAAG,MAAM,GAAG,IAU1G,CAAC;AAEF,qDAAqD;AACrD,eAAO,MAAM,sBAAsB,SAC3B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,gBACxB,MAAM,YACV;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,YAChC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,KACzC,MAAM,GAAG,IAUX,CAAC"}
package/index.css ADDED
@@ -0,0 +1 @@
1
+ ._root_2a8vt_1{--rdp-cell-size: 40px;--rdp-caption-font-size: 18px;--rdp-accent-color: #0000ff;--rdp-background-color: #e7edff;--rdp-accent-color-dark: #3003e1;--rdp-background-color-dark: #180270;--rdp-outline: 2px solid var(--rdp-accent-color);--rdp-outline-selected: 3px solid var(--rdp-accent-color);--rdp-selected-color: #fff;margin:1em}._vhidden_2a8vt_16{box-sizing:border-box;padding:0;margin:0;background:transparent;border:0;-moz-appearance:none;-webkit-appearance:none;appearance:none;position:absolute!important;top:0;width:1px!important;height:1px!important;padding:0!important;overflow:hidden!important;clip:rect(1px,1px,1px,1px)!important;border:0!important}._button_reset_2a8vt_36{appearance:none;position:relative;margin:0;padding:0;cursor:default;color:inherit;background:none;font:inherit;-moz-appearance:none;-webkit-appearance:none}._button_reset_2a8vt_36:focus-visible{outline:none}._button_2a8vt_36{border:2px solid transparent}._button_2a8vt_36[disabled]:not(._day_selected_2a8vt_59){opacity:.25}._button_2a8vt_36:not([disabled]){cursor:pointer}._button_2a8vt_36:focus-visible:not([disabled]){color:inherit;background-color:var(--rdp-background-color);border:var(--rdp-outline)}._button_2a8vt_36:hover:not([disabled]):not(._day_selected_2a8vt_59){background-color:var(--rdp-background-color)}._months_2a8vt_77{display:flex}._month_2a8vt_77{margin:0 1em}._month_2a8vt_77:first-child{margin-left:0}._month_2a8vt_77:last-child{margin-right:0}._table_2a8vt_93{margin:0;max-width:calc(var(--rdp-cell-size) * 7);border-collapse:collapse}._with_weeknumber_2a8vt_99 ._table_2a8vt_93{max-width:calc(var(--rdp-cell-size) * 8);border-collapse:collapse}._caption_2a8vt_104{display:flex;align-items:center;justify-content:space-between;padding:0;text-align:left}._multiple_months_2a8vt_112 ._caption_2a8vt_104{position:relative;display:block;text-align:center}._caption_dropdowns_2a8vt_118{position:relative;display:inline-flex}._caption_label_2a8vt_123{position:relative;z-index:1;display:inline-flex;align-items:center;margin:0;padding:0 .25em;white-space:nowrap;color:currentColor;border:0;border:2px solid transparent;font-family:inherit;font-size:var(--rdp-caption-font-size);font-weight:700}._nav_2a8vt_139{white-space:nowrap}._multiple_months_2a8vt_112 ._caption_start_2a8vt_143 ._nav_2a8vt_139{position:absolute;top:50%;left:0;transform:translateY(-50%)}._multiple_months_2a8vt_112 ._caption_end_2a8vt_150 ._nav_2a8vt_139{position:absolute;top:50%;right:0;transform:translateY(-50%)}._nav_button_2a8vt_157{display:inline-flex;align-items:center;justify-content:center;width:var(--rdp-cell-size);height:var(--rdp-cell-size);padding:.25em;border-radius:100%}._dropdown_year_2a8vt_171,._dropdown_month_2a8vt_172{position:relative;display:inline-flex;align-items:center}._dropdown_2a8vt_171{-webkit-appearance:none;-moz-appearance:none;appearance:none;position:absolute;z-index:2;top:0;bottom:0;left:0;width:100%;margin:0;padding:0;cursor:inherit;opacity:0;border:none;background-color:transparent;font-family:inherit;font-size:inherit;line-height:inherit}._dropdown_2a8vt_171[disabled]{opacity:unset;color:unset}._dropdown_2a8vt_171:focus-visible:not([disabled])+._caption_label_2a8vt_123{background-color:var(--rdp-background-color);border:var(--rdp-outline);border-radius:6px}._dropdown_icon_2a8vt_208{margin:0 0 0 5px}._head_2a8vt_212{border:0}._head_row_2a8vt_216,._row_2a8vt_217{height:100%}._head_cell_2a8vt_221{vertical-align:middle;font-size:.75em;font-weight:700;text-align:center;height:100%;height:var(--rdp-cell-size);padding:0;text-transform:uppercase}._tbody_2a8vt_232{border:0}._tfoot_2a8vt_236{margin:.5em}._cell_2a8vt_240{width:var(--rdp-cell-size);height:100%;height:var(--rdp-cell-size);padding:0;text-align:center}._weeknumber_2a8vt_248{font-size:.75em}._weeknumber_2a8vt_248,._day_2a8vt_59{display:flex;overflow:hidden;align-items:center;justify-content:center;box-sizing:border-box;width:var(--rdp-cell-size);max-width:var(--rdp-cell-size);height:var(--rdp-cell-size);margin:0;border:2px solid transparent;border-radius:100%}._day_today_2a8vt_267:not(._day_outside_2a8vt_267){font-weight:700}._day_selected_2a8vt_59,._day_selected_2a8vt_59:focus-visible,._day_selected_2a8vt_59:hover{color:var(--rdp-selected-color);opacity:1;background-color:var(--rdp-accent-color)}._day_outside_2a8vt_267{opacity:.5}._day_selected_2a8vt_59:focus-visible{outline:var(--rdp-outline);outline-offset:2px;z-index:1}._root_2a8vt_1:not([dir=rtl]) ._day_range_start_2a8vt_290:not(._day_range_end_2a8vt_290){border-top-right-radius:0;border-bottom-right-radius:0}._root_2a8vt_1:not([dir=rtl]) ._day_range_end_2a8vt_290:not(._day_range_start_2a8vt_290){border-top-left-radius:0;border-bottom-left-radius:0}._root_2a8vt_1[dir=rtl] ._day_range_start_2a8vt_290:not(._day_range_end_2a8vt_290){border-top-left-radius:0;border-bottom-left-radius:0}._root_2a8vt_1[dir=rtl] ._day_range_end_2a8vt_290:not(._day_range_start_2a8vt_290){border-top-right-radius:0;border-bottom-right-radius:0}._day_range_end_2a8vt_290._day_range_start_2a8vt_290{border-radius:100%}._day_range_middle_2a8vt_314{border-radius:0}
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@helsenorge/datepicker",
3
+ "type": "module",
4
+ "description": "The official Helsenorge datepicker.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/helsenorge/designsystem"
8
+ },
9
+ "homepage": "https://helsenorge.design",
10
+ "version": "6.3.0",
11
+ "author": "Helsenorge",
12
+ "license": "MIT",
13
+ "dependencies": {
14
+ "react-day-picker": "^8.10.0"
15
+ },
16
+ "peerDependencies": {
17
+ "@helsenorge/designsystem-react": "^6.0.0",
18
+ "classnames": "^2.5.1",
19
+ "date-fns": "^3.3.1",
20
+ "react": "^17.0.2",
21
+ "react-dom": "^17.0.2"
22
+ },
23
+ "sideEffects": false
24
+ }