@midas-ds/components 16.3.3 → 16.4.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 CHANGED
@@ -1,3 +1,9 @@
1
+ ## 16.4.0 (2026-01-15)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **components, date-field, date-picker, search-field:** add clear button ([#995](https://github.com/migrationsverket/midas/pull/995))
6
+
1
7
  ## 16.3.3 (2026-01-14)
2
8
 
3
9
  ### 🧱 Updated Dependencies
@@ -1 +1 @@
1
- ._dateField_y3sba_1{font-family:var(--midas-typography-font-family);display:flex;flex-direction:column;align-items:flex-start}._dateField_y3sba_1[data-readonly] ._inputField_y3sba_7{background-color:transparent;border-bottom-color:var(--midas-border-color-subtle)}._dateField_y3sba_1[data-disabled] ._inputField_y3sba_7{color:var(--midas-text-disabled);cursor:not-allowed;border-bottom-color:var(--midas-border-color-disabled);background-color:var(--midas-field-disabled)}._dateField_y3sba_1[data-invalid] ._inputField_y3sba_7{box-shadow:inset 0 0 0 3px var(--midas-support-border-warning);border-color:transparent}._inputField_y3sba_7{box-sizing:border-box;width:100%;min-height:var(--midas-size-150);display:flex;justify-content:flex-start;align-items:center;background-color:var(--midas-field-01-base);border:1px solid transparent;border-bottom-color:var(--midas-border-color-primary);padding:0 1rem}._inputField_y3sba_7._medium_y3sba_37{min-height:var(--midas-size-130)}._dateField_y3sba_1:not([data-disabled],[data-readonly]) ._inputField_y3sba_7 :hover{background-color:var(--midas-field-01-hover)}@media(forced-colors:active){._inputField_y3sba_7{border:1px solid var(--midas-border-color-primary)}}
1
+ ._dateField_3cnhf_1{font-family:var(--midas-typography-font-family);display:flex;flex-direction:column;align-items:flex-start}._dateField_3cnhf_1[data-readonly] ._inputField_3cnhf_7{background-color:transparent;border-bottom-color:var(--midas-border-color-subtle)}._dateField_3cnhf_1[data-disabled] ._inputField_3cnhf_7{color:var(--midas-text-disabled);cursor:not-allowed;border-bottom-color:var(--midas-border-color-disabled);background-color:var(--midas-field-disabled)}._dateField_3cnhf_1[data-invalid] ._inputField_3cnhf_7{box-shadow:inset 0 0 0 3px var(--midas-support-border-warning);border-color:transparent}._inputField_3cnhf_7{box-sizing:border-box;width:100%;min-height:var(--midas-size-150);display:flex;justify-content:flex-start;align-items:center;background-color:var(--midas-field-01-base);border:1px solid transparent;border-bottom-color:var(--midas-border-color-primary);padding:0 1rem;position:relative}._inputField_3cnhf_7._medium_3cnhf_38{min-height:var(--midas-size-130)}._dateField_3cnhf_1:not([data-disabled],[data-readonly]) ._inputField_3cnhf_7 :hover{background-color:var(--midas-field-01-hover)}._clearButton_3cnhf_47{display:flex;align-items:center;justify-content:center;position:absolute;padding:.5rem;border:none;right:.25rem;top:50%;transform:translateY(-50%);background-color:transparent}._clearButton_3cnhf_47._medium_3cnhf_38{padding:.375rem}@media(forced-colors:active){._inputField_3cnhf_7{border:1px solid var(--midas-border-color-primary)}}
@@ -1 +1 @@
1
- ._datePicker_175bg_1{font-family:var(--midas-typography-font-family);display:flex;flex-direction:column;align-items:flex-start}._inputField_175bg_8{box-sizing:border-box;width:100%;height:var(--midas-size-150);align-items:center;background-color:var(--midas-field-01-base);border-bottom:1px solid var(--midas-border-color-primary);padding-left:1rem;display:flex;justify-content:flex-start;gap:1rem}@media(forced-colors:active){._inputField_175bg_8{border:1px solid var(--midas-border-color-primary)}}._inputField_175bg_8._medium_175bg_24{height:var(--midas-size-130)}._inputField_175bg_8[data-disabled]{cursor:not-allowed;border-color:var(--midas-border-color-disabled)}._inputField_175bg_8:focus-visible,._inputField_175bg_8[data-focus-visible]{outline:none}._inputField_175bg_8[data-focus-visible]{box-shadow:var(--midas-state-focus)}._inputField_175bg_8[data-hovered]:not([data-disabled],._readOnly_175bg_42){background-color:var(--midas-field-01-hover)}._inputField_175bg_8[data-invalid]{border:none;box-shadow:inset 0 0 0 3px var(--midas-support-border-warning)}@media(forced-colors:active){._inputField_175bg_8[data-invalid]{border:1px solid var(--midas-border-color-primary)}}._inputField_175bg_8._readOnly_175bg_42{background-color:transparent;border-color:var(--midas-border-color-subtle)}._inputField_175bg_8 ._calendarButton_175bg_60{border:none;margin-left:auto;padding-right:1rem;padding-left:1rem;color:var(--midas-icon-primary);background-color:transparent;cursor:pointer}._inputField_175bg_8 ._calendarButton_175bg_60._medium_175bg_24[data-invalid]{height:calc(var(--midas-size-130) - var(--midas-size-30))}._inputField_175bg_8 ._calendarButton_175bg_60[data-invalid]{border:none;height:calc(var(--midas-size-150) - var(--midas-size-30));margin-right:3px}._inputField_175bg_8 ._calendarButton_175bg_60[data-disabled]{cursor:not-allowed;color:var(--midas-icon-disabled);border-color:var(--midas-border-color-disabled)}._inputField_175bg_8 ._calendarButton_175bg_60._readOnly_175bg_42{color:var(--midas-icon-read-only)}._inputField_175bg_8 ._calendarButton_175bg_60[data-hovered]:not([data-disabled]){background-color:var(--midas-field-01-hover)}._inputField_175bg_8 ._calendarButton_175bg_60:focus-visible,._inputField_175bg_8 ._calendarButton_175bg_60[data-focus-visible]{outline:none;box-shadow:var(--midas-state-focus)}@media(forced-colors:active){._inputField_175bg_8 ._calendarButton_175bg_60:focus-visible,._inputField_175bg_8 ._calendarButton_175bg_60[data-focus-visible]{outline:3px solid highlight;outline-offset:2px}}._dialog_175bg_108{box-shadow:0 3px 5px #0003}
1
+ ._datePicker_10uve_1{font-family:var(--midas-typography-font-family);display:flex;flex-direction:column;align-items:flex-start}._inputField_10uve_8{box-sizing:border-box;width:100%;height:var(--midas-size-150);align-items:center;background-color:var(--midas-field-01-base);border-bottom:1px solid var(--midas-border-color-primary);padding-left:1rem;display:flex;justify-content:flex-start;gap:1rem}@media(forced-colors:active){._inputField_10uve_8{border:1px solid var(--midas-border-color-primary)}}._inputField_10uve_8._medium_10uve_24{height:var(--midas-size-130)}._inputField_10uve_8[data-disabled]{cursor:not-allowed;border-color:var(--midas-border-color-disabled)}._inputField_10uve_8:focus-visible,._inputField_10uve_8[data-focus-visible]{outline:none}._inputField_10uve_8[data-focus-visible]{box-shadow:var(--midas-state-focus)}._inputField_10uve_8[data-invalid]{border:none;box-shadow:inset 0 0 0 3px var(--midas-support-border-warning)}@media(forced-colors:active){._inputField_10uve_8[data-invalid]{border:1px solid var(--midas-border-color-primary)}}._inputField_10uve_8._readOnly_10uve_51{background-color:transparent;border-color:var(--midas-border-color-subtle)}._inputField_10uve_8 ._buttonGroup_10uve_56{display:flex;margin-left:auto;gap:0}._inputField_10uve_8 ._clearButton_10uve_62{display:flex;align-items:center;justify-content:center;border:none;padding:.5rem;color:var(--midas-icon-primary);background-color:transparent;cursor:pointer}._inputField_10uve_8 ._clearButton_10uve_62._medium_10uve_24{padding:.375rem}._inputField_10uve_8 ._clearButton_10uve_62[data-disabled]{cursor:not-allowed;color:var(--midas-icon-disabled)}._inputField_10uve_8 ._clearButton_10uve_62[data-hovered]:not([data-disabled]){background-color:var(--midas-field-01-hover)}._inputField_10uve_8 ._clearButton_10uve_62:focus-visible,._inputField_10uve_8 ._clearButton_10uve_62[data-focus-visible]{outline:none;box-shadow:var(--midas-state-focus)}@media(forced-colors:active){._inputField_10uve_8 ._clearButton_10uve_62:focus-visible,._inputField_10uve_8 ._clearButton_10uve_62[data-focus-visible]{outline:3px solid highlight;outline-offset:2px}}._inputField_10uve_8 ._calendarButton_10uve_97{display:flex;align-items:center;justify-content:center;border:none;padding:.5rem .75rem;color:var(--midas-icon-primary);background-color:transparent;cursor:pointer}._inputField_10uve_8 ._calendarButton_10uve_97._medium_10uve_24{padding:.375rem .625rem}._inputField_10uve_8 ._calendarButton_10uve_97[data-disabled]{cursor:not-allowed;color:var(--midas-icon-disabled)}._inputField_10uve_8 ._calendarButton_10uve_97._readOnly_10uve_51{color:var(--midas-icon-read-only)}._inputField_10uve_8 ._calendarButton_10uve_97[data-hovered]:not([data-disabled]){background-color:var(--midas-field-01-hover)}._inputField_10uve_8 ._calendarButton_10uve_97:focus-visible,._inputField_10uve_8 ._calendarButton_10uve_97[data-focus-visible]{outline:none;box-shadow:var(--midas-state-focus)}@media(forced-colors:active){._inputField_10uve_8 ._calendarButton_10uve_97:focus-visible,._inputField_10uve_8 ._calendarButton_10uve_97[data-focus-visible]{outline:3px solid highlight;outline-offset:2px}}._dialog_10uve_137{box-shadow:0 3px 5px #0003}
@@ -0,0 +1,21 @@
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { B as o } from "./Button-BYrLbzir.js";
3
+ import { X as i } from "./x-BXShoIAM.js";
4
+ const m = (t) => /* @__PURE__ */ r(
5
+ o,
6
+ {
7
+ variant: "icon",
8
+ slot: null,
9
+ ...t,
10
+ children: /* @__PURE__ */ r(
11
+ i,
12
+ {
13
+ size: 20,
14
+ "aria-hidden": !0
15
+ }
16
+ )
17
+ }
18
+ );
19
+ export {
20
+ m as C
21
+ };
@@ -0,0 +1,91 @@
1
+ import { jsxs as p, jsx as e } from "react/jsx-runtime";
2
+ import * as _ from "react";
3
+ import { DateField as D, DateFieldStateContext as x } from "react-aria-components";
4
+ import { c as d } from "./clsx-AexbMWKp.js";
5
+ import { a as g, D as B } from "./DateInputDivider-CkTB5q5k.js";
6
+ import { F as f } from "./FieldError-Bra5aRT3.js";
7
+ import { a as C, L as b } from "./Label-6SXmzRZE.js";
8
+ import { T as L } from "./Text-TWzJxnto.js";
9
+ import { C as S } from "./ClearButton-DavPe5uU.js";
10
+ import { FocusScope as v, useFocusManager as N } from "@react-aria/focus";
11
+ import { u as V } from "./useLocalizedStringFormatter-BHvsRxDk.js";
12
+ import '../assets/DateField.css';const j = { clear: "Clear date" }, T = { clear: "Rensa datum" }, E = {
13
+ en: j,
14
+ sv: T
15
+ }, I = "_dateField_3cnhf_1", M = "_inputField_3cnhf_7", P = "_medium_3cnhf_38", R = "_clearButton_3cnhf_47", s = {
16
+ dateField: I,
17
+ inputField: M,
18
+ medium: P,
19
+ clearButton: R
20
+ }, W = ({
21
+ isClearable: i,
22
+ size: t,
23
+ isDisabled: o,
24
+ isReadOnly: r
25
+ }) => {
26
+ const l = V(E), a = _.useContext(x), n = N(), c = () => {
27
+ a?.setValue(null), n?.focusFirst();
28
+ };
29
+ return i && a?.value != null && !r ? /* @__PURE__ */ e(
30
+ S,
31
+ {
32
+ onPress: c,
33
+ size: t,
34
+ isDisabled: o,
35
+ "aria-label": l.format("clear"),
36
+ className: d(s.clearButton, {
37
+ [s.medium]: t === "medium"
38
+ })
39
+ }
40
+ ) : null;
41
+ }, Q = ({
42
+ className: i,
43
+ description: t,
44
+ errorMessage: o,
45
+ errorPosition: r = "top",
46
+ label: l,
47
+ size: a = "large",
48
+ popover: n,
49
+ isClearable: c = !1,
50
+ isReadOnly: m,
51
+ isDisabled: u,
52
+ ...F
53
+ }) => /* @__PURE__ */ p(
54
+ D,
55
+ {
56
+ ...F,
57
+ isReadOnly: m,
58
+ isDisabled: u,
59
+ className: d(s.dateField, i),
60
+ children: [
61
+ /* @__PURE__ */ e(C, { popover: n, children: l && /* @__PURE__ */ e(b, { children: l }) }),
62
+ t && /* @__PURE__ */ e(L, { slot: "description", children: t }),
63
+ r === "top" && /* @__PURE__ */ e(f, { children: o }),
64
+ /* @__PURE__ */ e(
65
+ "div",
66
+ {
67
+ className: d(s.inputField, {
68
+ [s.medium]: a === "medium"
69
+ }),
70
+ "data-testid": "date-field_input-field",
71
+ children: /* @__PURE__ */ p(v, { children: [
72
+ /* @__PURE__ */ e(g, { children: (h) => /* @__PURE__ */ e(B, { segment: h }) }),
73
+ /* @__PURE__ */ e(
74
+ W,
75
+ {
76
+ isClearable: c,
77
+ size: a,
78
+ isDisabled: u,
79
+ isReadOnly: m
80
+ }
81
+ )
82
+ ] })
83
+ }
84
+ ),
85
+ r === "bottom" && /* @__PURE__ */ e(f, { children: o })
86
+ ]
87
+ }
88
+ );
89
+ export {
90
+ Q as D
91
+ };
@@ -0,0 +1,191 @@
1
+ import { jsx as e, jsxs as p } from "react/jsx-runtime";
2
+ import { Group as B, Button as F, DatePickerStateContext as b, DateRangePickerStateContext as M, Popover as S, Dialog as N, DatePicker as R, DateRangePicker as G } from "react-aria-components";
3
+ import { a as k } from "./clsx-AexbMWKp.js";
4
+ import { C as L, R as I } from "./RangeCalendar-Bt8q3FZi.js";
5
+ import { a as v, D as P, b as V } from "./DateInputDivider-CkTB5q5k.js";
6
+ import { F as _ } from "./FieldError-Bra5aRT3.js";
7
+ import { a as g, L as y } from "./Label-6SXmzRZE.js";
8
+ import { T as D } from "./Text-TWzJxnto.js";
9
+ import * as f from "react";
10
+ import { C as j } from "./ClearButton-DavPe5uU.js";
11
+ import { FocusScope as w, useFocusManager as O } from "@react-aria/focus";
12
+ import { c as T } from "./createLucideIcon-D4r5Phnh.js";
13
+ import { u as $ } from "./useLocalizedStringFormatter-BHvsRxDk.js";
14
+ import '../assets/DateRangePicker.css';const E = [
15
+ ["path", { d: "M8 2v4", key: "1cmpym" }],
16
+ ["path", { d: "M16 2v4", key: "4m81vk" }],
17
+ ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
18
+ ["path", { d: "M3 10h18", key: "8toen8" }],
19
+ ["path", { d: "M8 14h.01", key: "6423bh" }],
20
+ ["path", { d: "M12 14h.01", key: "1etili" }],
21
+ ["path", { d: "M16 14h.01", key: "1gbofw" }],
22
+ ["path", { d: "M8 18h.01", key: "lrp35t" }],
23
+ ["path", { d: "M12 18h.01", key: "mhygvu" }],
24
+ ["path", { d: "M16 18h.01", key: "kzsmim" }]
25
+ ], W = T("calendar-days", E), q = { clear: "Clear date" }, z = { clear: "Rensa datum" }, A = {
26
+ en: q,
27
+ sv: z
28
+ }, H = "_datePicker_10uve_1", J = "_inputField_10uve_8", K = "_medium_10uve_24", Q = "_readOnly_10uve_51", U = "_buttonGroup_10uve_56", X = "_clearButton_10uve_62", Y = "_calendarButton_10uve_97", Z = "_dialog_10uve_137", r = {
29
+ datePicker: H,
30
+ inputField: J,
31
+ medium: K,
32
+ readOnly: Q,
33
+ buttonGroup: U,
34
+ clearButton: X,
35
+ calendarButton: Y,
36
+ dialog: Z
37
+ }, ee = (t) => !!t && !!t.value && Object.prototype.hasOwnProperty.call(t.value, "start"), te = ({
38
+ isClearable: t,
39
+ isDisabled: c,
40
+ isReadOnly: i,
41
+ size: a
42
+ }) => {
43
+ const n = f.useContext(b), l = f.useContext(M), m = $(A), s = O(), o = l ?? n, h = ee(o) ? !!o.value.start && o.value.end : !!o?.value;
44
+ return t && h && !i ? /* @__PURE__ */ e(
45
+ j,
46
+ {
47
+ onPress: () => {
48
+ o?.setValue(null), s?.focusFirst();
49
+ },
50
+ size: a,
51
+ isDisabled: c,
52
+ "aria-label": m.format("clear"),
53
+ className: k(r.clearButton, {
54
+ [r.medium]: a === "medium"
55
+ })
56
+ }
57
+ ) : null;
58
+ }, C = ({
59
+ children: t,
60
+ isDisabled: c,
61
+ isInvalid: i,
62
+ isReadOnly: a,
63
+ size: n = "large",
64
+ isClearable: l = !1
65
+ }) => /* @__PURE__ */ e(
66
+ B,
67
+ {
68
+ className: k(r.inputField, {
69
+ [r.medium]: n === "medium",
70
+ [r.readOnly]: a
71
+ }),
72
+ children: /* @__PURE__ */ p(w, { children: [
73
+ t,
74
+ /* @__PURE__ */ p("div", { className: r.buttonGroup, children: [
75
+ /* @__PURE__ */ e(
76
+ te,
77
+ {
78
+ isClearable: l,
79
+ isDisabled: c,
80
+ isReadOnly: a,
81
+ size: n
82
+ }
83
+ ),
84
+ /* @__PURE__ */ e(
85
+ F,
86
+ {
87
+ className: k(r.calendarButton, {
88
+ [r.medium]: n === "medium",
89
+ [r.readOnly]: a
90
+ }),
91
+ "data-invalid": i || void 0,
92
+ isDisabled: c,
93
+ children: /* @__PURE__ */ e(
94
+ W,
95
+ {
96
+ "aria-hidden": !0,
97
+ size: 20
98
+ }
99
+ )
100
+ }
101
+ )
102
+ ] })
103
+ ] })
104
+ }
105
+ ), x = ({
106
+ children: t
107
+ }) => /* @__PURE__ */ e(S, { children: /* @__PURE__ */ e(N, { className: r.dialog, children: t }) }), pe = ({
108
+ className: t,
109
+ description: c,
110
+ errorMessage: i,
111
+ errorPosition: a = "top",
112
+ label: n,
113
+ popover: l,
114
+ isClearable: m = !1,
115
+ isReadOnly: s,
116
+ isDisabled: o,
117
+ size: h,
118
+ ...d
119
+ }) => /* @__PURE__ */ p(
120
+ R,
121
+ {
122
+ className: k(r.datePicker, t),
123
+ isReadOnly: s,
124
+ isDisabled: o,
125
+ ...d,
126
+ children: [
127
+ /* @__PURE__ */ e(g, { popover: l, children: n && /* @__PURE__ */ e(y, { children: n }) }),
128
+ c && /* @__PURE__ */ e(D, { slot: "description", children: c }),
129
+ a === "top" && /* @__PURE__ */ e(_, { children: i }),
130
+ /* @__PURE__ */ e(
131
+ C,
132
+ {
133
+ isClearable: m,
134
+ isReadOnly: s,
135
+ isDisabled: o,
136
+ size: h,
137
+ ...d,
138
+ children: /* @__PURE__ */ e(v, { children: (u) => /* @__PURE__ */ e(P, { segment: u }) })
139
+ }
140
+ ),
141
+ a === "bottom" && /* @__PURE__ */ e(_, { children: i }),
142
+ /* @__PURE__ */ e(x, { children: /* @__PURE__ */ e(L, {}) })
143
+ ]
144
+ }
145
+ ), ke = ({
146
+ className: t,
147
+ description: c,
148
+ errorMessage: i,
149
+ errorPosition: a = "top",
150
+ label: n,
151
+ popover: l,
152
+ isClearable: m = !1,
153
+ isReadOnly: s,
154
+ isDisabled: o,
155
+ size: h,
156
+ ...d
157
+ }) => /* @__PURE__ */ p(
158
+ G,
159
+ {
160
+ className: k(r.datePicker, t),
161
+ isReadOnly: s,
162
+ isDisabled: o,
163
+ ...d,
164
+ children: [
165
+ /* @__PURE__ */ e(g, { popover: l, children: n && /* @__PURE__ */ e(y, { children: n }) }),
166
+ c && /* @__PURE__ */ e(D, { slot: "description", children: c }),
167
+ a === "top" && /* @__PURE__ */ e(_, { children: i }),
168
+ /* @__PURE__ */ p(
169
+ C,
170
+ {
171
+ isClearable: m,
172
+ isReadOnly: s,
173
+ isDisabled: o,
174
+ size: h,
175
+ ...d,
176
+ children: [
177
+ /* @__PURE__ */ e(v, { slot: "start", children: (u) => /* @__PURE__ */ e(P, { segment: u }) }),
178
+ /* @__PURE__ */ e(V, {}),
179
+ /* @__PURE__ */ e(v, { slot: "end", children: (u) => /* @__PURE__ */ e(P, { segment: u }) })
180
+ ]
181
+ }
182
+ ),
183
+ a === "bottom" && /* @__PURE__ */ e(_, { children: i }),
184
+ /* @__PURE__ */ e(x, { children: /* @__PURE__ */ e(I, {}) })
185
+ ]
186
+ }
187
+ );
188
+ export {
189
+ pe as D,
190
+ ke as a
191
+ };
@@ -0,0 +1,127 @@
1
+ import { jsxs as u, jsx as t } from "react/jsx-runtime";
2
+ import { s as C } from "./TextField.module-DZslrEPC.js";
3
+ import { B as F } from "./Button-BYrLbzir.js";
4
+ import { C as N } from "./ClearButton-DavPe5uU.js";
5
+ import { c as l } from "./clsx-AexbMWKp.js";
6
+ import * as x from "react";
7
+ import { useSearchFieldState as j } from "react-stately";
8
+ import { useSearchField as p } from "react-aria";
9
+ import { F as _ } from "./FieldError-Bra5aRT3.js";
10
+ import { c as B } from "./createLucideIcon-D4r5Phnh.js";
11
+ import { u as D } from "./useLocalizedStringFormatter-BHvsRxDk.js";
12
+ import '../assets/SearchField.css';const E = [
13
+ ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
14
+ ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
15
+ ], k = B("search", E), P = "_container_basio_1", T = "_inner_basio_10", w = "_inputContainer_basio_15", I = "_medium_basio_21", K = "_icon_basio_26", L = "_clear_basio_39", M = "_input_basio_15", a = {
16
+ container: P,
17
+ inner: T,
18
+ inputContainer: w,
19
+ medium: I,
20
+ icon: K,
21
+ clear: L,
22
+ input: M
23
+ }, R = { search: "Search" }, V = { search: "Sök" }, O = {
24
+ en: R,
25
+ sv: V
26
+ };
27
+ function $(o) {
28
+ return !!o?.length;
29
+ }
30
+ const Z = ({
31
+ errorPosition: o = "top",
32
+ size: i = "large",
33
+ ...e
34
+ }) => {
35
+ const { value: n, setValue: m } = j(e), f = D(O), d = x.useRef(null), { inputProps: r, isInvalid: s, validationErrors: h, clearButtonProps: v } = p(
36
+ {
37
+ ...e,
38
+ label: e.placeholder,
39
+ validationBehavior: "native"
40
+ },
41
+ { value: n, setValue: m },
42
+ d
43
+ ), S = ({ target: c }) => m(c.value), g = () => m(""), b = () => {
44
+ if (e.validate && $(e.validate(n)) || s || !n) {
45
+ d.current?.focus();
46
+ return;
47
+ }
48
+ e.onSubmit && e.onSubmit(n);
49
+ }, y = ({ key: c }) => {
50
+ c === "Enter" && b();
51
+ };
52
+ return /* @__PURE__ */ u(
53
+ "div",
54
+ {
55
+ className: l(a.container, e.className),
56
+ "data-disabled": r.disabled,
57
+ children: [
58
+ o === "top" && /* @__PURE__ */ t(_, { isInvalid: s, children: e.errorMessage ?? h.join(" ") }),
59
+ /* @__PURE__ */ u("div", { className: a.inner, children: [
60
+ /* @__PURE__ */ u(
61
+ "div",
62
+ {
63
+ className: l(a.inputContainer, {
64
+ [a.medium]: i === "medium"
65
+ }),
66
+ children: [
67
+ /* @__PURE__ */ t(
68
+ k,
69
+ {
70
+ size: 20,
71
+ className: a.icon
72
+ }
73
+ ),
74
+ /* @__PURE__ */ t(
75
+ "input",
76
+ {
77
+ ...r,
78
+ ...r.disabled && { "data-disabled": !0 },
79
+ className: l(
80
+ C.input,
81
+ a.input,
82
+ r.className,
83
+ { [a.medium]: i === "medium" }
84
+ ),
85
+ ref: d,
86
+ onChange: S,
87
+ value: n,
88
+ "aria-invalid": s,
89
+ onKeyDown: y,
90
+ "aria-label": e.placeholder,
91
+ "aria-labelledby": ""
92
+ }
93
+ ),
94
+ n.length > 0 && /* @__PURE__ */ t(
95
+ N,
96
+ {
97
+ ...v,
98
+ onPress: g,
99
+ size: i,
100
+ className: l(a.clear, {
101
+ [a.medium]: i === "medium"
102
+ })
103
+ }
104
+ )
105
+ ]
106
+ }
107
+ ),
108
+ /* @__PURE__ */ t(
109
+ F,
110
+ {
111
+ size: i,
112
+ isDisabled: e.isDisabled,
113
+ excludeFromTabOrder: !0,
114
+ onPress: b,
115
+ type: "button",
116
+ children: e.buttonText ? e.buttonText : f.format("search")
117
+ }
118
+ )
119
+ ] }),
120
+ o === "bottom" && /* @__PURE__ */ t(_, { isInvalid: s, children: e.errorMessage ?? h.join(" ") })
121
+ ]
122
+ }
123
+ );
124
+ };
125
+ export {
126
+ Z as S
127
+ };
@@ -0,0 +1,3 @@
1
+ import { MidasButton } from '../button';
2
+ import * as React from 'react';
3
+ export declare const ClearButton: React.FC<MidasButton>;
@@ -0,0 +1 @@
1
+ export { ClearButton } from './ClearButton';
@@ -0,0 +1,4 @@
1
+ import { C as t } from "../chunks/ClearButton-DavPe5uU.js";
2
+ export {
3
+ t as ClearButton
4
+ };
@@ -13,5 +13,9 @@ export interface DateFieldProps extends AriaDateFieldProps<DateValue> {
13
13
  size?: Size;
14
14
  /** An assistive text that helps the user understand the field better. Will be hidden in a popover with an info icon button. */
15
15
  popover?: InfoPopoverProps;
16
+ /** Show a clear button to remove the selected date
17
+ * @default false
18
+ */
19
+ isClearable?: boolean;
16
20
  }
17
21
  export declare const DateField: React.FC<DateFieldProps>;
@@ -1,4 +1,4 @@
1
- import { D as t } from "../chunks/DateField-DPJrihTz.js";
1
+ import { D as t } from "../chunks/DateField-D9CEvqnd.js";
2
2
  import { a as r, b as o, D as p } from "../chunks/DateInputDivider-CkTB5q5k.js";
3
3
  export {
4
4
  t as DateField,
@@ -0,0 +1,11 @@
1
+ declare const _default: {
2
+ "en": {
3
+ "clear": "Clear date"
4
+ },
5
+ "sv": {
6
+ "clear": "Rensa datum"
7
+ }
8
+ }
9
+ ;
10
+
11
+ export default _default;
@@ -13,5 +13,9 @@ export interface DatePickerProps extends AriaDatePickerProps<DateValue> {
13
13
  size?: Size;
14
14
  /** An assistive text that helps the user understand the field better. Will be hidden in a popover with an info icon button. */
15
15
  popover?: InfoPopoverProps;
16
+ /** Show a clear button to remove the selected date
17
+ * @default false
18
+ */
19
+ isClearable?: boolean;
16
20
  }
17
21
  export declare const DatePicker: React.FC<DatePickerProps>;
@@ -1,6 +1,6 @@
1
1
  import { DatePickerProps } from './DatePicker';
2
2
  import * as React from 'react';
3
- interface DatePickerInputFieldProps extends Pick<DatePickerProps, 'isDisabled' | 'isInvalid' | 'isReadOnly' | 'size'> {
3
+ interface DatePickerInputFieldProps extends Pick<DatePickerProps, 'isDisabled' | 'isInvalid' | 'isReadOnly' | 'size' | 'isClearable'> {
4
4
  children?: React.ReactNode;
5
5
  }
6
6
  export declare const DatePickerInputField: React.FC<DatePickerInputFieldProps>;
@@ -13,5 +13,9 @@ export interface DateRangePickerProps extends AriaDateRangePickerProps<DateValue
13
13
  size?: Size;
14
14
  /** An assistive text that helps the user understand the field better. Will be hidden in a popover with an info icon button. */
15
15
  popover?: InfoPopoverProps;
16
+ /** Show a clear button to remove the selected date range
17
+ * @default false
18
+ */
19
+ isClearable?: boolean;
16
20
  }
17
21
  export declare const DateRangePicker: React.FC<DateRangePickerProps>;
@@ -1,4 +1,4 @@
1
- import { D as r, a as t } from "../chunks/DateRangePicker-DzgK_p0d.js";
1
+ import { D as r, a as t } from "../chunks/DateRangePicker-DGfdhIjR.js";
2
2
  export {
3
3
  r as DatePicker,
4
4
  t as DateRangePicker
@@ -0,0 +1,11 @@
1
+ declare const _default: {
2
+ "en": {
3
+ "clear": "Clear date"
4
+ },
5
+ "sv": {
6
+ "clear": "Rensa datum"
7
+ }
8
+ }
9
+ ;
10
+
11
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import { DatePickerState, DateRangePickerState } from 'react-aria-components';
2
+ export declare const isRangePickerState: (state: DateRangePickerState | DatePickerState | null) => state is DateRangePickerState;
package/index.js CHANGED
@@ -10,9 +10,9 @@ import { C as R } from "./chunks/Checkbox-BTAfwDxU.js";
10
10
  import { C as F } from "./chunks/CheckboxGroup-C6LIpj_R.js";
11
11
  import { C as v } from "./chunks/ColorSchemeSwitch-CaqrCGTA.js";
12
12
  import { C as h, a as H, b as y } from "./chunks/ComboBox-BXcuyHPd.js";
13
- import { D as N } from "./chunks/DateField-DPJrihTz.js";
13
+ import { D as N } from "./chunks/DateField-D9CEvqnd.js";
14
14
  import { a as E, b as Q, D as Z } from "./chunks/DateInputDivider-CkTB5q5k.js";
15
- import { D as q, a as J } from "./chunks/DateRangePicker-DzgK_p0d.js";
15
+ import { D as q, a as J } from "./chunks/DateRangePicker-DGfdhIjR.js";
16
16
  import { F as O } from "./chunks/FieldError-Bra5aRT3.js";
17
17
  import { D as V, F as W } from "./chunks/FileUpload-h1PxqQmb.js";
18
18
  import { G as Y } from "./chunks/Grid-B-WgMwON.js";
@@ -28,7 +28,7 @@ import { M as Bo } from "./chunks/Dialog-DprWZBKT.js";
28
28
  import { P as So } from "./chunks/Popover-BcEtFiU1.js";
29
29
  import { P as Io } from "./chunks/ProgressBar-67lCngwJ.js";
30
30
  import { R as Po, a as Ro } from "./chunks/Radio-XQA8CylD.js";
31
- import { S as Fo } from "./chunks/SearchField-CxoPi6Ql.js";
31
+ import { S as Fo } from "./chunks/SearchField-Jqn3dKGs.js";
32
32
  import { S as vo } from "./chunks/Select-BNCz_ox4.js";
33
33
  import { S as ho } from "./chunks/Select-CyYUhMOg.js";
34
34
  import { S as yo } from "./chunks/Skeleton-DqIHQLQl.js";
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "description": "Midas Components",
15
15
  "homepage": "https://designsystem.migrationsverket.se/",
16
16
  "license": "CC0-1.0",
17
- "version": "16.3.3",
17
+ "version": "16.4.0",
18
18
  "module": "./index.js",
19
19
  "type": "module",
20
20
  "main": "./index.js",
@@ -1,4 +1,4 @@
1
- import { S as a } from "../chunks/SearchField-CxoPi6Ql.js";
1
+ import { S as a } from "../chunks/SearchField-Jqn3dKGs.js";
2
2
  export {
3
3
  a as SearchField
4
4
  };
@@ -1,46 +0,0 @@
1
- import { jsxs as F, jsx as e } from "react/jsx-runtime";
2
- import { DateField as u } from "react-aria-components";
3
- import { c as m } from "./clsx-AexbMWKp.js";
4
- import { a as _, D as f } from "./DateInputDivider-CkTB5q5k.js";
5
- import { F as s } from "./FieldError-Bra5aRT3.js";
6
- import { a as h, L as D } from "./Label-6SXmzRZE.js";
7
- import { T as b } from "./Text-TWzJxnto.js";
8
- import '../assets/DateField.css';const x = "_dateField_y3sba_1", y = "_inputField_y3sba_7", L = "_medium_y3sba_37", i = {
9
- dateField: x,
10
- inputField: y,
11
- medium: L
12
- }, S = ({
13
- className: r,
14
- description: t,
15
- errorMessage: d,
16
- errorPosition: a = "top",
17
- label: l,
18
- size: o = "large",
19
- popover: n,
20
- ...p
21
- }) => /* @__PURE__ */ F(
22
- u,
23
- {
24
- ...p,
25
- className: m(i.dateField, r),
26
- children: [
27
- /* @__PURE__ */ e(h, { popover: n, children: l && /* @__PURE__ */ e(D, { children: l }) }),
28
- t && /* @__PURE__ */ e(b, { slot: "description", children: t }),
29
- a === "top" && /* @__PURE__ */ e(s, { children: d }),
30
- /* @__PURE__ */ e(
31
- "div",
32
- {
33
- className: m(i.inputField, {
34
- [i.medium]: o === "medium"
35
- }),
36
- "data-testid": "date-field_input-field",
37
- children: /* @__PURE__ */ e(_, { children: (c) => /* @__PURE__ */ e(f, { segment: c }) })
38
- }
39
- ),
40
- a === "bottom" && /* @__PURE__ */ e(s, { children: d })
41
- ]
42
- }
43
- );
44
- export {
45
- S as D
46
- };
@@ -1,117 +0,0 @@
1
- import { jsxs as l, jsx as e } from "react/jsx-runtime";
2
- import { Group as P, Button as b, Popover as f, Dialog as v, DatePicker as x, DateRangePicker as F } from "react-aria-components";
3
- import { a as m } from "./clsx-AexbMWKp.js";
4
- import { C as M, R as N } from "./RangeCalendar-Bt8q3FZi.js";
5
- import { a as p, D as k, b as B } from "./DateInputDivider-CkTB5q5k.js";
6
- import { F as h } from "./FieldError-Bra5aRT3.js";
7
- import { a as u, L as y } from "./Label-6SXmzRZE.js";
8
- import { T as _ } from "./Text-TWzJxnto.js";
9
- import { c as C } from "./createLucideIcon-D4r5Phnh.js";
10
- import '../assets/DateRangePicker.css';const I = [
11
- ["path", { d: "M8 2v4", key: "1cmpym" }],
12
- ["path", { d: "M16 2v4", key: "4m81vk" }],
13
- ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
14
- ["path", { d: "M3 10h18", key: "8toen8" }],
15
- ["path", { d: "M8 14h.01", key: "6423bh" }],
16
- ["path", { d: "M12 14h.01", key: "1etili" }],
17
- ["path", { d: "M16 14h.01", key: "1gbofw" }],
18
- ["path", { d: "M8 18h.01", key: "lrp35t" }],
19
- ["path", { d: "M12 18h.01", key: "mhygvu" }],
20
- ["path", { d: "M16 18h.01", key: "kzsmim" }]
21
- ], L = C("calendar-days", I), O = "_datePicker_175bg_1", R = "_inputField_175bg_8", j = "_medium_175bg_24", w = "_readOnly_175bg_42", T = "_calendarButton_175bg_60", $ = "_dialog_175bg_108", a = {
22
- datePicker: O,
23
- inputField: R,
24
- medium: j,
25
- readOnly: w,
26
- calendarButton: T,
27
- dialog: $
28
- }, g = ({
29
- children: i,
30
- isDisabled: r,
31
- isInvalid: n,
32
- isReadOnly: t,
33
- size: d = "large"
34
- }) => /* @__PURE__ */ l(
35
- P,
36
- {
37
- className: m(a.inputField, {
38
- [a.medium]: d === "medium",
39
- [a.readOnly]: t
40
- }),
41
- children: [
42
- i,
43
- /* @__PURE__ */ e(
44
- b,
45
- {
46
- className: m(a.calendarButton, {
47
- [a.medium]: d === "medium",
48
- [a.readOnly]: t
49
- }),
50
- "data-invalid": n || void 0,
51
- isDisabled: r,
52
- children: /* @__PURE__ */ e(
53
- L,
54
- {
55
- "aria-hidden": !0,
56
- size: 20
57
- }
58
- )
59
- }
60
- )
61
- ]
62
- }
63
- ), D = ({
64
- children: i
65
- }) => /* @__PURE__ */ e(f, { children: /* @__PURE__ */ e(v, { className: a.dialog, children: i }) }), K = ({
66
- className: i,
67
- description: r,
68
- errorMessage: n,
69
- errorPosition: t = "top",
70
- label: d,
71
- popover: s,
72
- ...c
73
- }) => /* @__PURE__ */ l(
74
- x,
75
- {
76
- className: m(a.datePicker, i),
77
- ...c,
78
- children: [
79
- /* @__PURE__ */ e(u, { popover: s, children: d && /* @__PURE__ */ e(y, { children: d }) }),
80
- r && /* @__PURE__ */ e(_, { slot: "description", children: r }),
81
- t === "top" && /* @__PURE__ */ e(h, { children: n }),
82
- /* @__PURE__ */ e(g, { ...c, children: /* @__PURE__ */ e(p, { children: (o) => /* @__PURE__ */ e(k, { segment: o }) }) }),
83
- t === "bottom" && /* @__PURE__ */ e(h, { children: n }),
84
- /* @__PURE__ */ e(D, { children: /* @__PURE__ */ e(M, {}) })
85
- ]
86
- }
87
- ), Q = ({
88
- className: i,
89
- description: r,
90
- errorMessage: n,
91
- errorPosition: t = "top",
92
- label: d,
93
- popover: s,
94
- ...c
95
- }) => /* @__PURE__ */ l(
96
- F,
97
- {
98
- className: m(a.datePicker, i),
99
- ...c,
100
- children: [
101
- /* @__PURE__ */ e(u, { popover: s, children: d && /* @__PURE__ */ e(y, { children: d }) }),
102
- r && /* @__PURE__ */ e(_, { slot: "description", children: r }),
103
- t === "top" && /* @__PURE__ */ e(h, { children: n }),
104
- /* @__PURE__ */ l(g, { ...c, children: [
105
- /* @__PURE__ */ e(p, { slot: "start", children: (o) => /* @__PURE__ */ e(k, { segment: o }) }),
106
- /* @__PURE__ */ e(B, {}),
107
- /* @__PURE__ */ e(p, { slot: "end", children: (o) => /* @__PURE__ */ e(k, { segment: o }) })
108
- ] }),
109
- t === "bottom" && /* @__PURE__ */ e(h, { children: n }),
110
- /* @__PURE__ */ e(D, { children: /* @__PURE__ */ e(N, {}) })
111
- ]
112
- }
113
- );
114
- export {
115
- K as D,
116
- Q as a
117
- };
@@ -1,135 +0,0 @@
1
- import { jsxs as u, jsx as n } from "react/jsx-runtime";
2
- import { s as N } from "./TextField.module-DZslrEPC.js";
3
- import { B as _ } from "./Button-BYrLbzir.js";
4
- import { c as l } from "./clsx-AexbMWKp.js";
5
- import * as x from "react";
6
- import { useSearchFieldState as j } from "react-stately";
7
- import { useSearchField as C } from "react-aria";
8
- import { F as f } from "./FieldError-Bra5aRT3.js";
9
- import { c as p } from "./createLucideIcon-D4r5Phnh.js";
10
- import { X as B } from "./x-BXShoIAM.js";
11
- import { u as D } from "./useLocalizedStringFormatter-BHvsRxDk.js";
12
- import '../assets/SearchField.css';const E = [
13
- ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
14
- ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
15
- ], k = p("search", E), P = "_container_basio_1", T = "_inner_basio_10", w = "_inputContainer_basio_15", I = "_medium_basio_21", K = "_icon_basio_26", L = "_clear_basio_39", M = "_input_basio_15", a = {
16
- container: P,
17
- inner: T,
18
- inputContainer: w,
19
- medium: I,
20
- icon: K,
21
- clear: L,
22
- input: M
23
- }, R = { search: "Search" }, V = { search: "Sök" }, O = {
24
- en: R,
25
- sv: V
26
- };
27
- function X(r) {
28
- return !!r?.length;
29
- }
30
- const Z = ({
31
- errorPosition: r = "top",
32
- size: t = "large",
33
- ...e
34
- }) => {
35
- const { value: i, setValue: d } = j(e), v = D(O), m = x.useRef(null), { inputProps: o, isInvalid: s, validationErrors: h, clearButtonProps: S } = C(
36
- {
37
- ...e,
38
- label: e.placeholder,
39
- validationBehavior: "native"
40
- },
41
- { value: i, setValue: d },
42
- m
43
- ), g = ({ target: c }) => d(c.value), y = () => d(""), b = () => {
44
- if (e.validate && X(e.validate(i)) || s || !i) {
45
- m.current?.focus();
46
- return;
47
- }
48
- e.onSubmit && e.onSubmit(i);
49
- }, F = ({ key: c }) => {
50
- c === "Enter" && b();
51
- };
52
- return /* @__PURE__ */ u(
53
- "div",
54
- {
55
- className: l(a.container, e.className),
56
- "data-disabled": o.disabled,
57
- children: [
58
- r === "top" && /* @__PURE__ */ n(f, { isInvalid: s, children: e.errorMessage ?? h.join(" ") }),
59
- /* @__PURE__ */ u("div", { className: a.inner, children: [
60
- /* @__PURE__ */ u(
61
- "div",
62
- {
63
- className: l(a.inputContainer, {
64
- [a.medium]: t === "medium"
65
- }),
66
- children: [
67
- /* @__PURE__ */ n(
68
- k,
69
- {
70
- size: 20,
71
- className: a.icon
72
- }
73
- ),
74
- /* @__PURE__ */ n(
75
- "input",
76
- {
77
- ...o,
78
- ...o.disabled && { "data-disabled": !0 },
79
- className: l(
80
- N.input,
81
- a.input,
82
- o.className,
83
- { [a.medium]: t === "medium" }
84
- ),
85
- ref: m,
86
- onChange: g,
87
- value: i,
88
- "aria-invalid": s,
89
- onKeyDown: F,
90
- "aria-label": e.placeholder,
91
- "aria-labelledby": ""
92
- }
93
- ),
94
- i.length > 0 && /* @__PURE__ */ n(
95
- _,
96
- {
97
- variant: "icon",
98
- size: t,
99
- className: l(a.clear, {
100
- [a.medium]: t === "medium"
101
- }),
102
- onPress: y,
103
- ...S,
104
- children: /* @__PURE__ */ n(
105
- B,
106
- {
107
- size: 20,
108
- "aria-hidden": !0
109
- }
110
- )
111
- }
112
- )
113
- ]
114
- }
115
- ),
116
- /* @__PURE__ */ n(
117
- _,
118
- {
119
- size: t,
120
- isDisabled: e.isDisabled,
121
- excludeFromTabOrder: !0,
122
- onPress: b,
123
- type: "button",
124
- children: e.buttonText ? e.buttonText : v.format("search")
125
- }
126
- )
127
- ] }),
128
- r === "bottom" && /* @__PURE__ */ n(f, { isInvalid: s, children: e.errorMessage ?? h.join(" ") })
129
- ]
130
- }
131
- );
132
- };
133
- export {
134
- Z as S
135
- };