@eka-care/medassist-widget 0.1.83 → 0.1.85

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,414 @@
1
+ import { A as x, y as E, q as X, d as _, R as j, b as O, T as Y, D as y, e as J, u as l, P as S, f as Q, S as D, g as T, h as M, i as N } from "./medassist-widget.js";
2
+ import { C as Z } from "./medassist-widget-check-BaHLRs-2.js";
3
+ var V = j[" useInsertionEffect ".trim().toString()] || O;
4
+ function ee({
5
+ prop: e,
6
+ defaultProp: r,
7
+ onChange: c = () => {
8
+ },
9
+ caller: a
10
+ }) {
11
+ const [s, o, i] = re({
12
+ defaultProp: r,
13
+ onChange: c
14
+ }), d = e !== void 0, t = d ? e : s;
15
+ {
16
+ const b = x(e !== void 0);
17
+ E(() => {
18
+ const h = b.current;
19
+ if (h !== d) {
20
+ const p = h ? "controlled" : "uncontrolled", g = d ? "controlled" : "uncontrolled";
21
+ }
22
+ b.current = d;
23
+ }, [d, a]);
24
+ }
25
+ const v = X(
26
+ (b) => {
27
+ if (d) {
28
+ const h = te(b) ? b(e) : b;
29
+ h !== e && i.current?.(h);
30
+ } else
31
+ o(b);
32
+ },
33
+ [d, e, o, i]
34
+ );
35
+ return [t, v];
36
+ }
37
+ function re({
38
+ defaultProp: e,
39
+ onChange: r
40
+ }) {
41
+ const [c, a] = _(e), s = x(c), o = x(r);
42
+ return V(() => {
43
+ o.current = r;
44
+ }, [r]), E(() => {
45
+ s.current !== c && (o.current?.(c), s.current = c);
46
+ }, [c, s]), [c, a, o];
47
+ }
48
+ function te(e) {
49
+ return typeof e == "function";
50
+ }
51
+ function ne(e) {
52
+ const r = x({ value: e, previous: e });
53
+ return Y(() => (r.current.value !== e && (r.current.previous = r.current.value, r.current.value = e), r.current.previous), [e]);
54
+ }
55
+ function oe(e) {
56
+ const [r, c] = _(void 0);
57
+ return O(() => {
58
+ if (e) {
59
+ c({ width: e.offsetWidth, height: e.offsetHeight });
60
+ const a = new ResizeObserver((s) => {
61
+ if (!Array.isArray(s) || !s.length)
62
+ return;
63
+ const o = s[0];
64
+ let i, d;
65
+ if ("borderBoxSize" in o) {
66
+ const t = o.borderBoxSize, v = Array.isArray(t) ? t[0] : t;
67
+ i = v.inlineSize, d = v.blockSize;
68
+ } else
69
+ i = e.offsetWidth, d = e.offsetHeight;
70
+ c({ width: i, height: d });
71
+ });
72
+ return a.observe(e, { box: "border-box" }), () => a.unobserve(e);
73
+ } else
74
+ c(void 0);
75
+ }, [e]), r;
76
+ }
77
+ var P = "Checkbox", [ce] = J(P), [se, z] = ce(P);
78
+ function ie(e) {
79
+ const {
80
+ __scopeCheckbox: r,
81
+ checked: c,
82
+ children: a,
83
+ defaultChecked: s,
84
+ disabled: o,
85
+ form: i,
86
+ name: d,
87
+ onCheckedChange: t,
88
+ required: v,
89
+ value: b = "on",
90
+ // @ts-expect-error
91
+ internal_do_not_use_render: h
92
+ } = e, [p, g] = ee({
93
+ prop: c,
94
+ defaultProp: s ?? !1,
95
+ onChange: t,
96
+ caller: P
97
+ }), [C, n] = _(null), [m, u] = _(null), f = x(!1), w = C ? !!i || !!C.closest("form") : (
98
+ // We set this to true by default so that events bubble to forms without JS (SSR)
99
+ !0
100
+ ), I = {
101
+ checked: p,
102
+ disabled: o,
103
+ setChecked: g,
104
+ control: C,
105
+ setControl: n,
106
+ name: d,
107
+ form: i,
108
+ value: b,
109
+ hasConsumerStoppedPropagationRef: f,
110
+ required: v,
111
+ defaultChecked: k(s) ? !1 : s,
112
+ isFormControl: w,
113
+ bubbleInput: m,
114
+ setBubbleInput: u
115
+ };
116
+ return /* @__PURE__ */ l(
117
+ se,
118
+ {
119
+ scope: r,
120
+ ...I,
121
+ children: ae(h) ? h(I) : a
122
+ }
123
+ );
124
+ }
125
+ var $ = "CheckboxTrigger", q = y(
126
+ ({ __scopeCheckbox: e, onKeyDown: r, onClick: c, ...a }, s) => {
127
+ const {
128
+ control: o,
129
+ value: i,
130
+ disabled: d,
131
+ checked: t,
132
+ required: v,
133
+ setControl: b,
134
+ setChecked: h,
135
+ hasConsumerStoppedPropagationRef: p,
136
+ isFormControl: g,
137
+ bubbleInput: C
138
+ } = z($, e), n = T(s, b), m = x(t);
139
+ return E(() => {
140
+ const u = o?.form;
141
+ if (u) {
142
+ const f = () => h(m.current);
143
+ return u.addEventListener("reset", f), () => u.removeEventListener("reset", f);
144
+ }
145
+ }, [o, h]), /* @__PURE__ */ l(
146
+ S.button,
147
+ {
148
+ type: "button",
149
+ role: "checkbox",
150
+ "aria-checked": k(t) ? "mixed" : t,
151
+ "aria-required": v,
152
+ "data-state": G(t),
153
+ "data-disabled": d ? "" : void 0,
154
+ disabled: d,
155
+ value: i,
156
+ ...a,
157
+ ref: n,
158
+ onKeyDown: M(r, (u) => {
159
+ u.key === "Enter" && u.preventDefault();
160
+ }),
161
+ onClick: M(c, (u) => {
162
+ h((f) => k(f) ? !0 : !f), C && g && (p.current = u.isPropagationStopped(), p.current || u.stopPropagation());
163
+ })
164
+ }
165
+ );
166
+ }
167
+ );
168
+ q.displayName = $;
169
+ var A = y(
170
+ (e, r) => {
171
+ const {
172
+ __scopeCheckbox: c,
173
+ name: a,
174
+ checked: s,
175
+ defaultChecked: o,
176
+ required: i,
177
+ disabled: d,
178
+ value: t,
179
+ onCheckedChange: v,
180
+ form: b,
181
+ ...h
182
+ } = e;
183
+ return /* @__PURE__ */ l(
184
+ ie,
185
+ {
186
+ __scopeCheckbox: c,
187
+ checked: s,
188
+ defaultChecked: o,
189
+ disabled: d,
190
+ required: i,
191
+ onCheckedChange: v,
192
+ name: a,
193
+ form: b,
194
+ value: t,
195
+ internal_do_not_use_render: ({ isFormControl: p }) => /* @__PURE__ */ l(D, { children: [
196
+ /* @__PURE__ */ l(
197
+ q,
198
+ {
199
+ ...h,
200
+ ref: r,
201
+ __scopeCheckbox: c
202
+ }
203
+ ),
204
+ p && /* @__PURE__ */ l(
205
+ U,
206
+ {
207
+ __scopeCheckbox: c
208
+ }
209
+ )
210
+ ] })
211
+ }
212
+ );
213
+ }
214
+ );
215
+ A.displayName = P;
216
+ var F = "CheckboxIndicator", H = y(
217
+ (e, r) => {
218
+ const { __scopeCheckbox: c, forceMount: a, ...s } = e, o = z(F, c);
219
+ return /* @__PURE__ */ l(
220
+ Q,
221
+ {
222
+ present: a || k(o.checked) || o.checked === !0,
223
+ children: /* @__PURE__ */ l(
224
+ S.span,
225
+ {
226
+ "data-state": G(o.checked),
227
+ "data-disabled": o.disabled ? "" : void 0,
228
+ ...s,
229
+ ref: r,
230
+ style: { pointerEvents: "none", ...e.style }
231
+ }
232
+ )
233
+ }
234
+ );
235
+ }
236
+ );
237
+ H.displayName = F;
238
+ var L = "CheckboxBubbleInput", U = y(
239
+ ({ __scopeCheckbox: e, ...r }, c) => {
240
+ const {
241
+ control: a,
242
+ hasConsumerStoppedPropagationRef: s,
243
+ checked: o,
244
+ defaultChecked: i,
245
+ required: d,
246
+ disabled: t,
247
+ name: v,
248
+ value: b,
249
+ form: h,
250
+ bubbleInput: p,
251
+ setBubbleInput: g
252
+ } = z(L, e), C = T(c, g), n = ne(o), m = oe(a);
253
+ E(() => {
254
+ const f = p;
255
+ if (!f) return;
256
+ const w = window.HTMLInputElement.prototype, B = Object.getOwnPropertyDescriptor(
257
+ w,
258
+ "checked"
259
+ ).set, K = !s.current;
260
+ if (n !== o && B) {
261
+ const W = new Event("click", { bubbles: K });
262
+ f.indeterminate = k(o), B.call(f, k(o) ? !1 : o), f.dispatchEvent(W);
263
+ }
264
+ }, [p, n, o, s]);
265
+ const u = x(k(o) ? !1 : o);
266
+ return /* @__PURE__ */ l(
267
+ S.input,
268
+ {
269
+ type: "checkbox",
270
+ "aria-hidden": !0,
271
+ defaultChecked: i ?? u.current,
272
+ required: d,
273
+ disabled: t,
274
+ name: v,
275
+ value: b,
276
+ form: h,
277
+ ...r,
278
+ tabIndex: -1,
279
+ ref: C,
280
+ style: {
281
+ ...r.style,
282
+ ...m,
283
+ position: "absolute",
284
+ pointerEvents: "none",
285
+ opacity: 0,
286
+ margin: 0,
287
+ // We transform because the input is absolutely positioned but we have
288
+ // rendered it **after** the button. This pulls it back to sit on top
289
+ // of the button.
290
+ transform: "translateX(-100%)"
291
+ }
292
+ }
293
+ );
294
+ }
295
+ );
296
+ U.displayName = L;
297
+ function ae(e) {
298
+ return typeof e == "function";
299
+ }
300
+ function k(e) {
301
+ return e === "indeterminate";
302
+ }
303
+ function G(e) {
304
+ return k(e) ? "indeterminate" : e ? "checked" : "unchecked";
305
+ }
306
+ const R = y(({ className: e, ...r }, c) => /* @__PURE__ */ l(
307
+ A,
308
+ {
309
+ ref: c,
310
+ className: N(
311
+ "grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
312
+ e
313
+ ),
314
+ ...r,
315
+ children: /* @__PURE__ */ l(
316
+ H,
317
+ {
318
+ className: N("grid place-content-center text-current"),
319
+ children: /* @__PURE__ */ l(Z, { className: "h-4 w-4" })
320
+ }
321
+ )
322
+ }
323
+ ));
324
+ R.displayName = A.displayName;
325
+ function ue({
326
+ options: e,
327
+ selectedValues: r,
328
+ onSelectionChange: c,
329
+ additionalOption: a,
330
+ className: s,
331
+ required: o = !0,
332
+ maxSelections: i,
333
+ // error,
334
+ disabled: d
335
+ }) {
336
+ const t = a ? {
337
+ id: `extra-${a}`,
338
+ label: a === "all_of_the_above" ? "All of the above" : "None of the above",
339
+ value: a === "all_of_the_above" ? "All of the above" : "None of the above"
340
+ } : null, v = (n) => t ? n.filter((m) => m !== t.value) : n, b = (n) => t ? a === "none_of_the_above" ? n ? [t.value] : [] : a === "all_of_the_above" ? n ? [...e.map((m) => m.value), t.value] : v(r) : n ? [...r, t.value] : v(r) : r, h = (n, m) => {
341
+ const u = t ? v(r) : r;
342
+ return m ? i && u.length >= i ? null : [...u, n] : u.filter((f) => f !== n);
343
+ }, p = (n) => !(o && n.length === 0 && r.length === 1), g = (n, m) => {
344
+ const f = t && n === t.value ? b(m) : h(n, m);
345
+ f !== null && p(f) && c(f);
346
+ }, C = t ? r.filter((n) => n !== t.value).length : r.length;
347
+ return e.length ? /* @__PURE__ */ l(
348
+ "div",
349
+ {
350
+ className: N(
351
+ s
352
+ ),
353
+ children: [
354
+ /* @__PURE__ */ l("div", { className: "space-y-3", children: [
355
+ e.map((n) => {
356
+ const m = d || i && C >= i && !r.includes(n.value);
357
+ let u = r.includes(n.value);
358
+ return /* @__PURE__ */ l("div", { className: "flex items-center space-x-3", children: [
359
+ /* @__PURE__ */ l(
360
+ R,
361
+ {
362
+ id: n.id,
363
+ checked: u,
364
+ disabled: !!m,
365
+ onCheckedChange: (f) => g(n.value, !!f),
366
+ className: "mt-0.5 border border-muted-foreground text-primary-foreground"
367
+ }
368
+ ),
369
+ /* @__PURE__ */ l(
370
+ "label",
371
+ {
372
+ htmlFor: n.id,
373
+ className: N(
374
+ // Using the same muted color scheme as your other components
375
+ "text-sm font-normal leading-4 cursor-pointer",
376
+ m ? "text-muted-foreground cursor-not-allowed" : u ? "text-primary" : "text-secondary-foreground"
377
+ // Dark grey like other components
378
+ ),
379
+ children: n.label
380
+ }
381
+ )
382
+ ] }, n.id);
383
+ }),
384
+ t && /* @__PURE__ */ l(D, { children: [
385
+ /* @__PURE__ */ l("div", { className: "border-t border-border-medium my-3" }),
386
+ /* @__PURE__ */ l("div", { className: "flex items-center space-x-3", children: [
387
+ /* @__PURE__ */ l(
388
+ R,
389
+ {
390
+ id: t.id,
391
+ checked: r.includes(t.value),
392
+ onCheckedChange: (n) => g(t.value, n),
393
+ className: "mt-0.5 border border-muted-foreground"
394
+ }
395
+ ),
396
+ /* @__PURE__ */ l(
397
+ "label",
398
+ {
399
+ htmlFor: t.id,
400
+ className: "text-sm font-medium leading-none cursor-pointer text-secondary-foreground",
401
+ children: t.label
402
+ }
403
+ )
404
+ ] })
405
+ ] })
406
+ ] }),
407
+ i && C >= i && /* @__PURE__ */ l("p", { className: "text-sm text-blue-600 mt-3", children: i === 1 ? "You can select only 1 option" : `Maximum ${i} selections allowed` })
408
+ ]
409
+ }
410
+ ) : null;
411
+ }
412
+ export {
413
+ ue as MultiSelectGroup
414
+ };