@krak-stack/registry 0.8.2 → 0.9.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 +13 -0
- package/dist/components/ui/animated-list.js +5 -0
- package/dist/components/ui/app-switcher.d.ts +2 -1
- package/dist/components/ui/app-switcher.js +5 -1
- package/dist/components/ui/async-action-button.d.ts +2 -1
- package/dist/components/ui/async-action-button.js +3 -1
- package/dist/components/ui/bulk-list-input.d.ts +2 -1
- package/dist/components/ui/bulk-list-input.js +6 -1
- package/dist/components/ui/calendar.d.ts +10 -0
- package/dist/components/ui/choice-cards.d.ts +1 -0
- package/dist/components/ui/choice-cards.js +7 -1
- package/dist/components/ui/color-picker.d.ts +2 -1
- package/dist/components/ui/color-picker.js +4 -1
- package/dist/components/ui/cron-expression-editor.d.ts +3 -1
- package/dist/components/ui/cron-expression-editor.js +13 -3
- package/dist/components/ui/danger-confirmation.d.ts +1 -0
- package/dist/components/ui/danger-confirmation.js +5 -1
- package/dist/components/ui/date-picker.d.ts +33 -0
- package/dist/components/ui/date-picker.js +470 -0
- package/dist/components/ui/date-picker.schema.d.ts +9 -0
- package/dist/components/ui/editable-text.js +8 -1
- package/dist/components/ui/form.d.ts +5 -5
- package/dist/components/ui/image-crop-editor.js +10 -1
- package/dist/components/ui/phone-number-input.d.ts +3 -1
- package/dist/components/ui/phone-number-input.js +53 -13
- package/dist/components/ui/phone-number-input.schema.d.ts +7 -0
- package/dist/components/ui/secret-value.js +6 -0
- package/dist/components/ui/select-with-custom-input.d.ts +36 -0
- package/dist/components/ui/select-with-custom-input.js +275 -0
- package/dist/components/ui/sidebar-layout.js +1 -0
- package/dist/components/ui/stepper.js +8 -0
- package/dist/components/ui/timezone-select.d.ts +2 -1
- package/dist/components/ui/timezone-select.js +5 -1
- package/dist/components/ui/toast.d.ts +18 -0
- package/dist/components/ui/toast.js +121 -0
- package/dist/components/ui/unsaved-changes-guard.d.ts +2 -1
- package/dist/components/ui/unsaved-changes-guard.js +4 -1
- package/dist/components/ui/upload-attachment.js +3 -0
- package/dist/lib/docs.js +1 -0
- package/dist/services/notification/client/index.js +4 -7
- package/dist/services/notification/public.js +4 -7
- package/package.json +15 -1
|
@@ -16,5 +16,7 @@ export type PhoneNumberInputProps = Omit<ComponentProps<typeof Input>, "value" |
|
|
|
16
16
|
locale?: string;
|
|
17
17
|
label?: string;
|
|
18
18
|
withExtension?: boolean;
|
|
19
|
+
containerClassName?: string;
|
|
20
|
+
contentClassName?: string;
|
|
19
21
|
};
|
|
20
|
-
export declare const PhoneNumberInput: ({ value, country, onCountryChange, onValueChange, countries, locale, label, id, onBlur, name, withExtension, onKeyDown, ...props }: PhoneNumberInputProps) => import("react").JSX.Element;
|
|
22
|
+
export declare const PhoneNumberInput: ({ value, country, onCountryChange, onValueChange, countries, locale, label, id, onBlur, name, withExtension, onKeyDown, className, containerClassName, contentClassName, ...props }: PhoneNumberInputProps) => import("react").JSX.Element;
|
|
@@ -3,8 +3,8 @@ import { useId, useLayoutEffect, useRef as useRef2 } from "react";
|
|
|
3
3
|
import {
|
|
4
4
|
getCountries,
|
|
5
5
|
AsYouType,
|
|
6
|
-
getCountryCallingCode,
|
|
7
|
-
parsePhoneNumberFromString
|
|
6
|
+
getCountryCallingCode as getCountryCallingCode2,
|
|
7
|
+
parsePhoneNumberFromString as parsePhoneNumberFromString2
|
|
8
8
|
} from "libphonenumber-js/max";
|
|
9
9
|
|
|
10
10
|
// ../../src/components/ui/input.tsx
|
|
@@ -446,13 +446,36 @@ function VirtualizedCombobox(props) {
|
|
|
446
446
|
|
|
447
447
|
// ../../src/components/ui/phone-number-input.tsx
|
|
448
448
|
import { ChevronsUpDown as ChevronsUpDown2 } from "lucide-react";
|
|
449
|
+
|
|
450
|
+
// ../../src/components/ui/phone-number-input.schema.ts
|
|
451
|
+
import { Schema } from "effect";
|
|
452
|
+
import {
|
|
453
|
+
getCountryCallingCode,
|
|
454
|
+
parsePhoneNumberFromString
|
|
455
|
+
} from "libphonenumber-js/max";
|
|
456
|
+
var E164DigitsSchema = Schema.String.check(Schema.isPattern(/^\d*$/), Schema.isMaxLength(15)).annotate({ identifier: "E164Digits" });
|
|
457
|
+
var getPhoneNumberDigits = (value, country) => {
|
|
458
|
+
if (!value)
|
|
459
|
+
return "";
|
|
460
|
+
const parsed = parsePhoneNumberFromString(value, {
|
|
461
|
+
defaultCountry: country,
|
|
462
|
+
extract: false
|
|
463
|
+
});
|
|
464
|
+
if (parsed)
|
|
465
|
+
return parsed.number.slice(1);
|
|
466
|
+
const digits = value.replace(/(?:ext\.?|x|#|;ext=)\s*\d+\s*$/i, "").replace(/\D/g, "");
|
|
467
|
+
return value.trimStart().startsWith("+") ? digits : `${getCountryCallingCode(country)}${digits}`;
|
|
468
|
+
};
|
|
469
|
+
var fitsE164DigitLimit = (value, country) => Schema.is(E164DigitsSchema)(getPhoneNumberDigits(value, country));
|
|
470
|
+
|
|
471
|
+
// ../../src/components/ui/phone-number-input.tsx
|
|
449
472
|
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
450
473
|
var normalizePhoneNumber = (value, country) => {
|
|
451
|
-
const phone =
|
|
474
|
+
const phone = parsePhoneNumberFromString2(value, {
|
|
452
475
|
defaultCountry: country,
|
|
453
476
|
extract: false
|
|
454
477
|
});
|
|
455
|
-
return phone?.isValid() ? {
|
|
478
|
+
return phone?.isValid() && fitsE164DigitLimit(value, country) ? {
|
|
456
479
|
e164: phone.number,
|
|
457
480
|
extension: phone.ext ?? null,
|
|
458
481
|
country: phone.country ?? null
|
|
@@ -471,6 +494,9 @@ var PhoneNumberInput = ({
|
|
|
471
494
|
name,
|
|
472
495
|
withExtension = false,
|
|
473
496
|
onKeyDown,
|
|
497
|
+
className,
|
|
498
|
+
containerClassName,
|
|
499
|
+
contentClassName,
|
|
474
500
|
...props
|
|
475
501
|
}) => {
|
|
476
502
|
const generatedId = useId();
|
|
@@ -480,11 +506,11 @@ var PhoneNumberInput = ({
|
|
|
480
506
|
const names = new Intl.DisplayNames([language], { type: "region" });
|
|
481
507
|
const options = [...new Set([country, ...countries])].sort((a, b) => (names.of(a) ?? a).localeCompare(names.of(b) ?? b, language));
|
|
482
508
|
const valid = normalizePhoneNumber(value, country);
|
|
483
|
-
const parsed =
|
|
509
|
+
const parsed = parsePhoneNumberFromString2(value, {
|
|
484
510
|
defaultCountry: country,
|
|
485
511
|
extract: false
|
|
486
512
|
});
|
|
487
|
-
const callingCode = value.trim().startsWith("+") ? parsed?.countryCallingCode ??
|
|
513
|
+
const callingCode = value.trim().startsWith("+") ? parsed?.countryCallingCode ?? getCountryCallingCode2(country) : getCountryCallingCode2(country);
|
|
488
514
|
const nationalDraft = value.trim().startsWith(`+${callingCode}`) ? value.trim().slice(callingCode.length + 1).trimStart() : value;
|
|
489
515
|
const extension = parsed?.ext ?? "";
|
|
490
516
|
const nationalDigits = (extension ? nationalDraft.replace(/(?:ext\.?|x|#|;ext=)\s*\d+\s*$/i, "") : nationalDraft).replace(/\D/g, "");
|
|
@@ -508,17 +534,23 @@ var PhoneNumberInput = ({
|
|
|
508
534
|
const emitNational = (draft, nextExtension = extension) => {
|
|
509
535
|
const digits = draft.replace(/\D/g, "");
|
|
510
536
|
const next = digits ? `+${callingCode} ${digits}${nextExtension ? ` ext. ${nextExtension}` : ""}` : "";
|
|
537
|
+
if (!fitsE164DigitLimit(next, country)) {
|
|
538
|
+
pendingCaret.current = null;
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
511
541
|
onValueChange(next, normalizePhoneNumber(next, country));
|
|
512
542
|
};
|
|
513
543
|
const countryLabel = french ? "Pays du numéro" : "Phone country";
|
|
514
544
|
const items = options.map((code) => ({
|
|
515
545
|
value: code,
|
|
516
|
-
label: `${names.of(code)} (${code}) +${
|
|
546
|
+
label: `${names.of(code)} (${code}) +${getCountryCallingCode2(code)}`
|
|
517
547
|
}));
|
|
518
548
|
return /* @__PURE__ */ jsxs2("div", {
|
|
519
|
-
|
|
549
|
+
"data-slot": "phone-number-input",
|
|
550
|
+
className: cn("grid gap-2", containerClassName),
|
|
520
551
|
children: [
|
|
521
552
|
/* @__PURE__ */ jsx5("label", {
|
|
553
|
+
"data-slot": "phone-number-label",
|
|
522
554
|
htmlFor: inputId,
|
|
523
555
|
className: "text-sm font-medium",
|
|
524
556
|
children: label ?? (french ? "Numéro de téléphone" : "Phone number")
|
|
@@ -530,6 +562,7 @@ var PhoneNumberInput = ({
|
|
|
530
562
|
disabled: props.disabled
|
|
531
563
|
}) : null,
|
|
532
564
|
/* @__PURE__ */ jsxs2("div", {
|
|
565
|
+
"data-slot": "phone-number-controls",
|
|
533
566
|
className: "flex min-w-0 gap-2",
|
|
534
567
|
children: [
|
|
535
568
|
/* @__PURE__ */ jsx5(VirtualizedCombobox, {
|
|
@@ -539,7 +572,7 @@ var PhoneNumberInput = ({
|
|
|
539
572
|
value: items.find((item) => item.value === country) ?? null,
|
|
540
573
|
placeholder: country,
|
|
541
574
|
emptyLabel: french ? "Aucun pays correspondant." : "No matching countries.",
|
|
542
|
-
contentClassName: "w-72! max-w-[calc(100vw-2rem)]!",
|
|
575
|
+
contentClassName: cn("w-72! max-w-[calc(100vw-2rem)]!", contentClassName),
|
|
543
576
|
disabled: props.disabled || props.readOnly,
|
|
544
577
|
trigger: /* @__PURE__ */ jsxs2(Button, {
|
|
545
578
|
type: "button",
|
|
@@ -568,25 +601,28 @@ var PhoneNumberInput = ({
|
|
|
568
601
|
const selected = options.find((option) => option === item?.value);
|
|
569
602
|
if (!selected || selected === country)
|
|
570
603
|
return;
|
|
604
|
+
const next = nationalDigits ? `+${getCountryCallingCode2(selected)} ${nationalDigits}${extension ? ` ext. ${extension}` : ""}` : "";
|
|
605
|
+
if (!fitsE164DigitLimit(next, selected))
|
|
606
|
+
return;
|
|
571
607
|
onCountryChange(selected);
|
|
572
|
-
const next = nationalDigits ? `+${getCountryCallingCode(selected)} ${nationalDigits}${extension ? ` ext. ${extension}` : ""}` : "";
|
|
573
608
|
onValueChange(next, normalizePhoneNumber(next, selected));
|
|
574
609
|
}
|
|
575
610
|
}),
|
|
576
611
|
/* @__PURE__ */ jsx5(Input, {
|
|
577
612
|
...props,
|
|
613
|
+
"data-component": "phone-number-national",
|
|
578
614
|
id: inputId,
|
|
579
615
|
type: "tel",
|
|
580
616
|
inputMode: "numeric",
|
|
581
617
|
autoComplete: props.autoComplete ?? "tel-national",
|
|
582
|
-
className: "min-w-0 flex-1",
|
|
618
|
+
className: cn("min-w-0 flex-1", className),
|
|
583
619
|
value: nationalValue,
|
|
584
620
|
"aria-invalid": Boolean(value) && !valid,
|
|
585
621
|
"aria-describedby": `${inputId}-status ${props["aria-describedby"] ?? ""}`,
|
|
586
622
|
onChange: (event) => {
|
|
587
623
|
const draft = event.target.value;
|
|
588
624
|
const international = draft.trimStart().startsWith("+");
|
|
589
|
-
const pasted =
|
|
625
|
+
const pasted = parsePhoneNumberFromString2(draft, {
|
|
590
626
|
defaultCountry: country,
|
|
591
627
|
extract: false
|
|
592
628
|
});
|
|
@@ -600,6 +636,8 @@ var PhoneNumberInput = ({
|
|
|
600
636
|
}
|
|
601
637
|
const digits = draft.replace(/\D/g, "");
|
|
602
638
|
const next = pasted?.isValid() ? `${pasted.number}${pasted.ext ? ` ext. ${pasted.ext}` : ""}` : digits ? `${international ? "+" : `+${callingCode} `}${digits}` : "";
|
|
639
|
+
if (!fitsE164DigitLimit(next, country))
|
|
640
|
+
return;
|
|
603
641
|
const details = normalizePhoneNumber(next, country);
|
|
604
642
|
if (international && details?.country && options.includes(details.country) && details.country !== country)
|
|
605
643
|
onCountryChange(details.country);
|
|
@@ -637,7 +675,7 @@ var PhoneNumberInput = ({
|
|
|
637
675
|
},
|
|
638
676
|
onBlur: (event) => {
|
|
639
677
|
if (!props.readOnly && !props.disabled && valid) {
|
|
640
|
-
const formatted =
|
|
678
|
+
const formatted = parsePhoneNumberFromString2(value, {
|
|
641
679
|
defaultCountry: country,
|
|
642
680
|
extract: false
|
|
643
681
|
})?.formatInternational();
|
|
@@ -650,6 +688,7 @@ var PhoneNumberInput = ({
|
|
|
650
688
|
]
|
|
651
689
|
}),
|
|
652
690
|
withExtension || extension ? /* @__PURE__ */ jsxs2("div", {
|
|
691
|
+
"data-slot": "phone-number-extension",
|
|
653
692
|
className: "grid max-w-32 gap-1.5",
|
|
654
693
|
children: [
|
|
655
694
|
/* @__PURE__ */ jsx5("label", {
|
|
@@ -669,6 +708,7 @@ var PhoneNumberInput = ({
|
|
|
669
708
|
]
|
|
670
709
|
}) : null,
|
|
671
710
|
/* @__PURE__ */ jsx5("p", {
|
|
711
|
+
"data-slot": "phone-number-status",
|
|
672
712
|
id: `${inputId}-status`,
|
|
673
713
|
className: "text-muted-foreground text-xs",
|
|
674
714
|
children: valid ? `${valid.e164}${valid.extension ? ` ext. ${valid.extension}` : ""}` : french ? "Saisissez un numéro complet. La validation ne vérifie pas son propriétaire." : "Enter a complete number. Validation does not verify ownership."
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { type CountryCode } from "libphonenumber-js/max";
|
|
3
|
+
/** ITU-T E.164: up to 15 digits, including the country calling code, excluding extensions. */
|
|
4
|
+
export declare const E164DigitsSchema: Schema.String;
|
|
5
|
+
/** Use the parser’s national-prefix normalization when available, even for incomplete/invalid numbers. */
|
|
6
|
+
export declare const getPhoneNumberDigits: (value: string, country: CountryCode) => string;
|
|
7
|
+
export declare const fitsE164DigitLimit: (value: string, country: CountryCode) => boolean;
|
|
@@ -175,9 +175,13 @@ var SecretValue = ({
|
|
|
175
175
|
return () => clearTimeout(timer);
|
|
176
176
|
}, [revealed, autoHideDelay, value]);
|
|
177
177
|
return /* @__PURE__ */ jsxs2("div", {
|
|
178
|
+
"data-slot": "secret-value",
|
|
179
|
+
"data-state": revealed ? "revealed" : "hidden",
|
|
180
|
+
"data-disabled": disabled || undefined,
|
|
178
181
|
className: cn("flex min-w-0 items-center gap-2", className),
|
|
179
182
|
children: [
|
|
180
183
|
/* @__PURE__ */ jsx3("code", {
|
|
184
|
+
"data-slot": "secret-value-content",
|
|
181
185
|
className: "min-w-0 flex-1 text-sm break-all",
|
|
182
186
|
"aria-label": revealed ? undefined : `${label}: ${copy.hidden}`,
|
|
183
187
|
children: revealed ? value : /* @__PURE__ */ jsx3("span", {
|
|
@@ -186,6 +190,7 @@ var SecretValue = ({
|
|
|
186
190
|
})
|
|
187
191
|
}),
|
|
188
192
|
/* @__PURE__ */ jsx3(Button, {
|
|
193
|
+
"data-component": "secret-value-toggle",
|
|
189
194
|
type: "button",
|
|
190
195
|
size: "icon-sm",
|
|
191
196
|
variant: "ghost",
|
|
@@ -200,6 +205,7 @@ var SecretValue = ({
|
|
|
200
205
|
})
|
|
201
206
|
}),
|
|
202
207
|
copyable ? /* @__PURE__ */ jsx3(CopyButton, {
|
|
208
|
+
"data-component": "secret-value-copy",
|
|
203
209
|
type: "button",
|
|
204
210
|
value,
|
|
205
211
|
valueDescription: label,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type SelectWithCustomInputOption = {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
input?: {
|
|
6
|
+
label: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
maxLength?: number;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export type SelectWithCustomInputValue = {
|
|
13
|
+
option: string;
|
|
14
|
+
customValue?: string;
|
|
15
|
+
};
|
|
16
|
+
export type SelectWithCustomInputProps = {
|
|
17
|
+
label: string;
|
|
18
|
+
options: readonly SelectWithCustomInputOption[];
|
|
19
|
+
value: SelectWithCustomInputValue | null;
|
|
20
|
+
onValueChange: (value: SelectWithCustomInputValue | null) => void;
|
|
21
|
+
name?: string;
|
|
22
|
+
customName?: string;
|
|
23
|
+
required?: boolean;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
readOnly?: boolean;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
error?: string;
|
|
29
|
+
locale?: string;
|
|
30
|
+
className?: string;
|
|
31
|
+
triggerClassName?: string;
|
|
32
|
+
contentClassName?: string;
|
|
33
|
+
inputClassName?: string;
|
|
34
|
+
};
|
|
35
|
+
/** Option identifiers and custom text stay separate; the host owns the option catalog. */
|
|
36
|
+
export declare const SelectWithCustomInput: ({ label, options, value, onValueChange, name, customName, required, disabled, readOnly, placeholder, description, error, locale, className, triggerClassName, contentClassName, inputClassName, }: SelectWithCustomInputProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
// ../../src/components/ui/select-with-custom-input.tsx
|
|
2
|
+
import { useId, useRef } from "react";
|
|
3
|
+
|
|
4
|
+
// ../../src/components/ui/input.tsx
|
|
5
|
+
import { Input as InputPrimitive } from "@base-ui/react/input";
|
|
6
|
+
|
|
7
|
+
// ../../src/lib/utils.ts
|
|
8
|
+
import { cn } from "cn";
|
|
9
|
+
|
|
10
|
+
// ../../src/components/ui/input.tsx
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
function Input({ className, type, ...props }) {
|
|
13
|
+
return /* @__PURE__ */ jsx(InputPrimitive, {
|
|
14
|
+
type,
|
|
15
|
+
"data-slot": "input",
|
|
16
|
+
className: cn("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", className),
|
|
17
|
+
...props
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// ../../src/components/ui/select.tsx
|
|
22
|
+
import { Select as SelectPrimitive } from "@base-ui/react/select";
|
|
23
|
+
import { ChevronDownIcon, CheckIcon, ChevronUpIcon } from "lucide-react";
|
|
24
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
25
|
+
"use client";
|
|
26
|
+
var Select = SelectPrimitive.Root;
|
|
27
|
+
function SelectValue({ className, ...props }) {
|
|
28
|
+
return /* @__PURE__ */ jsx2(SelectPrimitive.Value, {
|
|
29
|
+
"data-slot": "select-value",
|
|
30
|
+
className: cn("flex flex-1 text-left", className),
|
|
31
|
+
...props
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function SelectTrigger({
|
|
35
|
+
className,
|
|
36
|
+
size = "default",
|
|
37
|
+
children,
|
|
38
|
+
...props
|
|
39
|
+
}) {
|
|
40
|
+
return /* @__PURE__ */ jsxs(SelectPrimitive.Trigger, {
|
|
41
|
+
"data-slot": "select-trigger",
|
|
42
|
+
"data-size": size,
|
|
43
|
+
className: cn("flex w-fit items-center justify-between gap-1.5 rounded-md border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
|
|
44
|
+
...props,
|
|
45
|
+
children: [
|
|
46
|
+
children,
|
|
47
|
+
/* @__PURE__ */ jsx2(SelectPrimitive.Icon, {
|
|
48
|
+
render: /* @__PURE__ */ jsx2(ChevronDownIcon, {
|
|
49
|
+
className: "text-muted-foreground pointer-events-none size-4"
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function SelectContent({
|
|
56
|
+
className,
|
|
57
|
+
children,
|
|
58
|
+
side = "bottom",
|
|
59
|
+
sideOffset = 4,
|
|
60
|
+
align = "center",
|
|
61
|
+
alignOffset = 0,
|
|
62
|
+
alignItemWithTrigger = true,
|
|
63
|
+
...props
|
|
64
|
+
}) {
|
|
65
|
+
return /* @__PURE__ */ jsx2(SelectPrimitive.Portal, {
|
|
66
|
+
children: /* @__PURE__ */ jsx2(SelectPrimitive.Positioner, {
|
|
67
|
+
side,
|
|
68
|
+
sideOffset,
|
|
69
|
+
align,
|
|
70
|
+
alignOffset,
|
|
71
|
+
alignItemWithTrigger,
|
|
72
|
+
className: "isolate z-50",
|
|
73
|
+
children: /* @__PURE__ */ jsxs(SelectPrimitive.Popup, {
|
|
74
|
+
"data-slot": "select-content",
|
|
75
|
+
"data-align-trigger": alignItemWithTrigger,
|
|
76
|
+
className: cn("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className),
|
|
77
|
+
...props,
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ jsx2(SelectScrollUpButton, {}),
|
|
80
|
+
/* @__PURE__ */ jsx2(SelectPrimitive.List, {
|
|
81
|
+
children
|
|
82
|
+
}),
|
|
83
|
+
/* @__PURE__ */ jsx2(SelectScrollDownButton, {})
|
|
84
|
+
]
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function SelectItem({
|
|
90
|
+
className,
|
|
91
|
+
children,
|
|
92
|
+
...props
|
|
93
|
+
}) {
|
|
94
|
+
return /* @__PURE__ */ jsxs(SelectPrimitive.Item, {
|
|
95
|
+
"data-slot": "select-item",
|
|
96
|
+
className: cn("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className),
|
|
97
|
+
...props,
|
|
98
|
+
children: [
|
|
99
|
+
/* @__PURE__ */ jsx2(SelectPrimitive.ItemText, {
|
|
100
|
+
className: "flex flex-1 shrink-0 gap-2 whitespace-nowrap",
|
|
101
|
+
children
|
|
102
|
+
}),
|
|
103
|
+
/* @__PURE__ */ jsx2(SelectPrimitive.ItemIndicator, {
|
|
104
|
+
render: /* @__PURE__ */ jsx2("span", {
|
|
105
|
+
className: "pointer-events-none absolute right-2 flex size-4 items-center justify-center"
|
|
106
|
+
}),
|
|
107
|
+
children: /* @__PURE__ */ jsx2(CheckIcon, {
|
|
108
|
+
className: "pointer-events-none"
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function SelectScrollUpButton({
|
|
115
|
+
className,
|
|
116
|
+
...props
|
|
117
|
+
}) {
|
|
118
|
+
return /* @__PURE__ */ jsx2(SelectPrimitive.ScrollUpArrow, {
|
|
119
|
+
"data-slot": "select-scroll-up-button",
|
|
120
|
+
className: cn("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4", className),
|
|
121
|
+
...props,
|
|
122
|
+
children: /* @__PURE__ */ jsx2(ChevronUpIcon, {})
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function SelectScrollDownButton({
|
|
126
|
+
className,
|
|
127
|
+
...props
|
|
128
|
+
}) {
|
|
129
|
+
return /* @__PURE__ */ jsx2(SelectPrimitive.ScrollDownArrow, {
|
|
130
|
+
"data-slot": "select-scroll-down-button",
|
|
131
|
+
className: cn("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4", className),
|
|
132
|
+
...props,
|
|
133
|
+
children: /* @__PURE__ */ jsx2(ChevronDownIcon, {})
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// ../../src/components/ui/select-with-custom-input.tsx
|
|
138
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
139
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
140
|
+
"use client";
|
|
141
|
+
var SelectWithCustomInput = ({
|
|
142
|
+
label,
|
|
143
|
+
options,
|
|
144
|
+
value,
|
|
145
|
+
onValueChange,
|
|
146
|
+
name,
|
|
147
|
+
customName,
|
|
148
|
+
required,
|
|
149
|
+
disabled,
|
|
150
|
+
readOnly,
|
|
151
|
+
placeholder,
|
|
152
|
+
description,
|
|
153
|
+
error,
|
|
154
|
+
locale,
|
|
155
|
+
className,
|
|
156
|
+
triggerClassName,
|
|
157
|
+
contentClassName,
|
|
158
|
+
inputClassName
|
|
159
|
+
}) => {
|
|
160
|
+
const id = useId();
|
|
161
|
+
const language = useKrakstackLocale(locale);
|
|
162
|
+
const selected = options.find((option) => option.value === value?.option);
|
|
163
|
+
const input = useRef(null);
|
|
164
|
+
const focusInput = useRef(false);
|
|
165
|
+
const describedBy = [description && `${id}-description`, error && `${id}-error`].filter(Boolean).join(" ") || undefined;
|
|
166
|
+
return /* @__PURE__ */ jsxs2("div", {
|
|
167
|
+
"data-slot": "select-with-custom-input",
|
|
168
|
+
"data-state": selected?.input ? "custom" : "preset",
|
|
169
|
+
className: cn("grid min-w-0 gap-2", className),
|
|
170
|
+
children: [
|
|
171
|
+
/* @__PURE__ */ jsx3("label", {
|
|
172
|
+
htmlFor: id,
|
|
173
|
+
"data-slot": "select-with-custom-input-label",
|
|
174
|
+
className: "text-sm font-medium",
|
|
175
|
+
children: label
|
|
176
|
+
}),
|
|
177
|
+
/* @__PURE__ */ jsxs2(Select, {
|
|
178
|
+
items: options,
|
|
179
|
+
value: value?.option ?? null,
|
|
180
|
+
name,
|
|
181
|
+
required,
|
|
182
|
+
disabled,
|
|
183
|
+
readOnly,
|
|
184
|
+
onValueChange: (next) => {
|
|
185
|
+
const option = options.find((option) => option.value === next);
|
|
186
|
+
if (disabled || readOnly || option?.disabled)
|
|
187
|
+
return;
|
|
188
|
+
if (!option) {
|
|
189
|
+
onValueChange(null);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (option.value === value?.option)
|
|
193
|
+
return;
|
|
194
|
+
focusInput.current = Boolean(option.input);
|
|
195
|
+
onValueChange(option.input ? { option: option.value, customValue: "" } : { option: option.value });
|
|
196
|
+
},
|
|
197
|
+
children: [
|
|
198
|
+
/* @__PURE__ */ jsx3(SelectTrigger, {
|
|
199
|
+
id,
|
|
200
|
+
"data-component": "select-with-custom-input-trigger",
|
|
201
|
+
"aria-invalid": Boolean(error),
|
|
202
|
+
"aria-describedby": describedBy,
|
|
203
|
+
className: cn("w-full min-w-0", triggerClassName),
|
|
204
|
+
children: /* @__PURE__ */ jsx3(SelectValue, {
|
|
205
|
+
placeholder: placeholder ?? (language.startsWith("fr") ? "Sélectionner une option" : "Select an option")
|
|
206
|
+
})
|
|
207
|
+
}),
|
|
208
|
+
/* @__PURE__ */ jsx3(SelectContent, {
|
|
209
|
+
"data-component": "select-with-custom-input-content",
|
|
210
|
+
className: contentClassName,
|
|
211
|
+
finalFocus: () => {
|
|
212
|
+
const target = focusInput.current ? input.current : null;
|
|
213
|
+
focusInput.current = false;
|
|
214
|
+
return target ?? true;
|
|
215
|
+
},
|
|
216
|
+
children: options.map((option) => /* @__PURE__ */ jsx3(SelectItem, {
|
|
217
|
+
value: option.value,
|
|
218
|
+
disabled: option.disabled,
|
|
219
|
+
children: option.label
|
|
220
|
+
}, option.value))
|
|
221
|
+
})
|
|
222
|
+
]
|
|
223
|
+
}),
|
|
224
|
+
selected?.input ? /* @__PURE__ */ jsxs2("div", {
|
|
225
|
+
"data-slot": "select-with-custom-input-field",
|
|
226
|
+
className: "grid gap-2",
|
|
227
|
+
children: [
|
|
228
|
+
/* @__PURE__ */ jsx3("label", {
|
|
229
|
+
htmlFor: `${id}-custom`,
|
|
230
|
+
className: "text-sm font-medium",
|
|
231
|
+
children: selected.input.label
|
|
232
|
+
}),
|
|
233
|
+
/* @__PURE__ */ jsx3(Input, {
|
|
234
|
+
ref: input,
|
|
235
|
+
id: `${id}-custom`,
|
|
236
|
+
"data-component": "select-with-custom-input-text",
|
|
237
|
+
name: customName ?? (name ? `${name}Custom` : undefined),
|
|
238
|
+
value: value?.customValue ?? "",
|
|
239
|
+
disabled,
|
|
240
|
+
readOnly,
|
|
241
|
+
required: selected.input.required,
|
|
242
|
+
maxLength: selected.input.maxLength,
|
|
243
|
+
placeholder: selected.input.placeholder,
|
|
244
|
+
"aria-invalid": Boolean(error),
|
|
245
|
+
"aria-describedby": describedBy,
|
|
246
|
+
className: inputClassName,
|
|
247
|
+
onChange: (event) => {
|
|
248
|
+
if (!disabled && !readOnly)
|
|
249
|
+
onValueChange({
|
|
250
|
+
option: selected.value,
|
|
251
|
+
customValue: event.target.value
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
})
|
|
255
|
+
]
|
|
256
|
+
}) : null,
|
|
257
|
+
description ? /* @__PURE__ */ jsx3("p", {
|
|
258
|
+
id: `${id}-description`,
|
|
259
|
+
"data-slot": "select-with-custom-input-description",
|
|
260
|
+
className: "text-muted-foreground text-xs",
|
|
261
|
+
children: description
|
|
262
|
+
}) : null,
|
|
263
|
+
error ? /* @__PURE__ */ jsx3("p", {
|
|
264
|
+
id: `${id}-error`,
|
|
265
|
+
"data-slot": "select-with-custom-input-error",
|
|
266
|
+
role: "alert",
|
|
267
|
+
className: "text-destructive text-sm",
|
|
268
|
+
children: error
|
|
269
|
+
}) : null
|
|
270
|
+
]
|
|
271
|
+
});
|
|
272
|
+
};
|
|
273
|
+
export {
|
|
274
|
+
SelectWithCustomInput
|
|
275
|
+
};
|
|
@@ -638,6 +638,7 @@ function AppSidebar({ collapsible, footer, groups, header }) {
|
|
|
638
638
|
});
|
|
639
639
|
return /* @__PURE__ */ jsx5(SidebarMenuItem, {
|
|
640
640
|
children: /* @__PURE__ */ jsxs4(SidebarMenuButton, {
|
|
641
|
+
className: "h-auto min-h-8",
|
|
641
642
|
onClick: closeMobileSidebar,
|
|
642
643
|
render,
|
|
643
644
|
tooltip: item.label(),
|
|
@@ -63,6 +63,7 @@ var Stepper = ({
|
|
|
63
63
|
children: labels.progress(currentIndex + 1, steps.length)
|
|
64
64
|
}),
|
|
65
65
|
/* @__PURE__ */ jsx("ol", {
|
|
66
|
+
"data-slot": "stepper-list",
|
|
66
67
|
className: cn("flex gap-2", variant === "underline" && "flex-wrap gap-x-6 gap-y-1", variant === "underline" && orientation === "horizontal" && "justify-center", orientation === "vertical" && "flex-col", orientation === "responsive" && "lg:flex-col"),
|
|
67
68
|
children: steps.map((step, index) => {
|
|
68
69
|
const active = step.id === currentStep;
|
|
@@ -70,9 +71,11 @@ var Stepper = ({
|
|
|
70
71
|
const content = /* @__PURE__ */ jsxs(Fragment, {
|
|
71
72
|
children: [
|
|
72
73
|
variant === "segmented" ? /* @__PURE__ */ jsx("span", {
|
|
74
|
+
"data-slot": "stepper-indicator",
|
|
73
75
|
"aria-hidden": "true",
|
|
74
76
|
className: cn("bg-muted block h-1.5 w-full rounded-full motion-safe:transition-colors motion-safe:duration-150", state === "completed" && "bg-primary/50", active && "bg-primary", state === "error" && "bg-destructive")
|
|
75
77
|
}) : variant === "labelled" ? /* @__PURE__ */ jsx("span", {
|
|
78
|
+
"data-slot": "stepper-indicator",
|
|
76
79
|
"aria-hidden": "true",
|
|
77
80
|
className: cn("flex size-8 shrink-0 items-center justify-center rounded-full border text-xs font-medium motion-safe:transition-colors motion-safe:duration-150 [&_svg]:size-4", state === "completed" && "border-primary/30 bg-primary/10 text-primary", active && "border-primary bg-primary text-primary-foreground", state === "error" && "border-destructive text-destructive"),
|
|
78
81
|
children: state === "error" ? /* @__PURE__ */ jsx(CircleAlert, {}) : state === "completed" && !active ? /* @__PURE__ */ jsx(Check, {}) : step.icon ?? index + 1
|
|
@@ -81,10 +84,12 @@ var Stepper = ({
|
|
|
81
84
|
className: cn("min-w-0 break-words", variant === "segmented" && "sr-only", orientation === "responsive" && variant === "labelled" && "sr-only lg:not-sr-only"),
|
|
82
85
|
children: [
|
|
83
86
|
/* @__PURE__ */ jsx("span", {
|
|
87
|
+
"data-slot": "stepper-label",
|
|
84
88
|
className: "block",
|
|
85
89
|
children: step.label
|
|
86
90
|
}),
|
|
87
91
|
step.description ? /* @__PURE__ */ jsx("span", {
|
|
92
|
+
"data-slot": "stepper-description",
|
|
88
93
|
className: "text-muted-foreground block text-xs font-normal",
|
|
89
94
|
children: step.description
|
|
90
95
|
}) : null,
|
|
@@ -105,9 +110,11 @@ var Stepper = ({
|
|
|
105
110
|
});
|
|
106
111
|
const itemClassName = cn("text-muted-foreground flex min-h-11 w-full min-w-0 items-center rounded-md text-sm", variant === "labelled" && orientation === "horizontal" ? "flex-col gap-2 text-center sm:flex-row sm:gap-3 sm:text-left" : "gap-3 text-left", variant === "labelled" && "px-2 py-2", orientation === "responsive" && "justify-center lg:justify-start", variant === "underline" && "w-auto justify-start rounded-none border-b-2 border-transparent py-3 text-left motion-safe:transition-colors motion-safe:duration-150", variant === "underline" && active && "border-foreground", active && "text-foreground font-medium", state === "error" && "text-destructive");
|
|
107
112
|
return /* @__PURE__ */ jsx("li", {
|
|
113
|
+
"data-slot": "stepper-item",
|
|
108
114
|
"data-state": state,
|
|
109
115
|
className: cn("min-w-0", variant !== "underline" && "flex-1"),
|
|
110
116
|
children: onStepSelect ? /* @__PURE__ */ jsx("button", {
|
|
117
|
+
"data-slot": "stepper-trigger",
|
|
111
118
|
type: "button",
|
|
112
119
|
"aria-current": active ? "step" : undefined,
|
|
113
120
|
"aria-disabled": step.disabled || undefined,
|
|
@@ -119,6 +126,7 @@ var Stepper = ({
|
|
|
119
126
|
},
|
|
120
127
|
children: content
|
|
121
128
|
}) : /* @__PURE__ */ jsx("div", {
|
|
129
|
+
"data-slot": "stepper-trigger",
|
|
122
130
|
"aria-current": active ? "step" : undefined,
|
|
123
131
|
className: itemClassName,
|
|
124
132
|
children: content
|
|
@@ -39,6 +39,7 @@ export type TimezoneSelectProps = {
|
|
|
39
39
|
name?: string;
|
|
40
40
|
disabled?: boolean;
|
|
41
41
|
className?: string;
|
|
42
|
+
contentClassName?: string;
|
|
42
43
|
locale?: string;
|
|
43
44
|
messages?: Partial<Record<string, Partial<TimezoneSelectMessages>>>;
|
|
44
45
|
};
|
|
@@ -53,4 +54,4 @@ export declare const getTimeZoneDetails: ({ timeZone, at, locale, }: {
|
|
|
53
54
|
locale?: string;
|
|
54
55
|
}) => TimeZoneDetails | undefined;
|
|
55
56
|
/** Adds time-zone semantics to the existing combobox; owns no generic picker behavior. */
|
|
56
|
-
export declare const TimezoneSelect: ({ value, onValueChange, label, continent, comparisonTimeZone, referenceTime, name, disabled, className, locale: override, messages, }: TimezoneSelectProps) => import("react").JSX.Element;
|
|
57
|
+
export declare const TimezoneSelect: ({ value, onValueChange, label, continent, comparisonTimeZone, referenceTime, name, disabled, className, contentClassName, locale: override, messages, }: TimezoneSelectProps) => import("react").JSX.Element;
|
|
@@ -705,6 +705,7 @@ var TimezoneSelect = ({
|
|
|
705
705
|
name,
|
|
706
706
|
disabled,
|
|
707
707
|
className,
|
|
708
|
+
contentClassName,
|
|
708
709
|
locale: override,
|
|
709
710
|
messages
|
|
710
711
|
}) => {
|
|
@@ -759,6 +760,7 @@ var TimezoneSelect = ({
|
|
|
759
760
|
return minutes > 0 ? copy.ahead(duration) : copy.behind(duration);
|
|
760
761
|
};
|
|
761
762
|
return /* @__PURE__ */ jsx5("div", {
|
|
763
|
+
"data-slot": "timezone-select",
|
|
762
764
|
className,
|
|
763
765
|
children: /* @__PURE__ */ jsxs2("div", {
|
|
764
766
|
className: "grid min-w-0 grid-cols-1 gap-3",
|
|
@@ -772,7 +774,7 @@ var TimezoneSelect = ({
|
|
|
772
774
|
ariaLabel: label ?? copy.label,
|
|
773
775
|
ariaInvalid: invalid,
|
|
774
776
|
triggerId: id,
|
|
775
|
-
contentClassName: "[&_[role=option]]:h-auto!",
|
|
777
|
+
contentClassName: cn("[&_[role=option]]:h-auto!", contentClassName),
|
|
776
778
|
disabled,
|
|
777
779
|
locale,
|
|
778
780
|
value: selected,
|
|
@@ -831,6 +833,7 @@ var TimezoneSelect = ({
|
|
|
831
833
|
children: copy.invalidReference
|
|
832
834
|
}),
|
|
833
835
|
selected?.data && /* @__PURE__ */ jsxs2("dl", {
|
|
836
|
+
"data-slot": "timezone-details",
|
|
834
837
|
className: "grid gap-1 rounded-lg border p-3 text-sm",
|
|
835
838
|
children: [
|
|
836
839
|
/* @__PURE__ */ jsx5("dt", {
|
|
@@ -852,6 +855,7 @@ var TimezoneSelect = ({
|
|
|
852
855
|
]
|
|
853
856
|
}),
|
|
854
857
|
comparisonTimeZone !== null && /* @__PURE__ */ jsx5("div", {
|
|
858
|
+
"data-slot": "timezone-comparison",
|
|
855
859
|
className: "grid gap-2 text-sm",
|
|
856
860
|
children: baseline ? /* @__PURE__ */ jsxs2("p", {
|
|
857
861
|
className: "text-muted-foreground wrap-anywhere",
|