@kapiuara/ui 0.16.0 → 0.17.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/README.md +171 -11
- package/dist/components/chat/KapiChatThread.js +4 -4
- package/dist/components/chat/KapiComposer.js +8 -8
- package/dist/components/data/KapiDataTable.js +4 -4
- package/dist/components/data/KapiSparkline.d.ts +2 -1
- package/dist/components/data/KapiSparkline.js +29 -26
- package/dist/components/data/KapiTableFilter.js +6 -6
- package/dist/components/data/tableCells.d.ts +12 -1
- package/dist/components/data/tableCells.js +49 -51
- package/dist/components/data/useTableSelection.js +3 -3
- package/dist/components/display/KapiAnnotation.js +68 -63
- package/dist/components/display/KapiAvatar.d.ts +6 -4
- package/dist/components/display/KapiAvatar.js +33 -28
- package/dist/components/display/KapiCodeBlock.d.ts +48 -0
- package/dist/components/display/KapiCodeBlock.js +44 -0
- package/dist/components/display/KapiCommentComposer.js +6 -6
- package/dist/components/display/KapiDiff.d.ts +62 -0
- package/dist/components/display/KapiDiff.js +118 -0
- package/dist/components/display/KapiHighlight.d.ts +27 -0
- package/dist/components/display/KapiHighlight.js +21 -0
- package/dist/components/display/KapiIconTile.d.ts +2 -1
- package/dist/components/display/KapiIconTile.js +23 -21
- package/dist/components/display/KapiStat.d.ts +3 -2
- package/dist/components/display/KapiStat.js +32 -26
- package/dist/components/display/KapiTag.d.ts +4 -3
- package/dist/components/display/KapiTag.js +29 -24
- package/dist/components/display/KapiTimeline.d.ts +5 -2
- package/dist/components/display/KapiTimeline.js +31 -23
- package/dist/components/display/annotationLogic.d.ts +2 -1
- package/dist/components/display/annotationLogic.js +7 -6
- package/dist/components/display/codeBlockSlots.d.ts +10 -0
- package/dist/components/display/codeBlockSlots.js +13 -0
- package/dist/components/display/diffLogic.d.ts +58 -0
- package/dist/components/display/diffLogic.js +96 -0
- package/dist/components/display/diffSlots.d.ts +14 -0
- package/dist/components/display/diffSlots.js +17 -0
- package/dist/components/display/highlightLogic.d.ts +18 -0
- package/dist/components/display/highlightLogic.js +26 -0
- package/dist/components/display/highlightSlots.d.ts +5 -0
- package/dist/components/display/highlightSlots.js +8 -0
- package/dist/components/display/iconTileLogic.d.ts +2 -2
- package/dist/components/display/iconTileLogic.js +7 -6
- package/dist/components/display/index.d.ts +8 -0
- package/dist/components/display/statLogic.d.ts +2 -1
- package/dist/components/display/statLogic.js +7 -6
- package/dist/components/display/tagLogic.d.ts +2 -1
- package/dist/components/display/tagLogic.js +7 -6
- package/dist/components/display/timelineLogic.d.ts +20 -2
- package/dist/components/display/timelineLogic.js +10 -2
- package/dist/components/feedback/KapiFab.js +108 -108
- package/dist/components/feedback/KapiProgress.js +63 -54
- package/dist/components/feedback/KapiToastContainer.js +9 -9
- package/dist/components/feedback/KapiTour.js +12 -12
- package/dist/components/feedback/progressLogic.d.ts +2 -1
- package/dist/components/feedback/progressLogic.js +9 -8
- package/dist/components/inputs/KapiAutocomplete.d.ts +6 -0
- package/dist/components/inputs/KapiAutocomplete.js +86 -85
- package/dist/components/inputs/KapiChecklist.d.ts +7 -1
- package/dist/components/inputs/KapiChecklist.js +53 -52
- package/dist/components/inputs/KapiCopyButton.d.ts +40 -0
- package/dist/components/inputs/KapiCopyButton.js +35 -0
- package/dist/components/inputs/KapiDatePicker.d.ts +7 -1
- package/dist/components/inputs/KapiDatePicker.js +118 -116
- package/dist/components/inputs/KapiDateRangePicker.d.ts +7 -1
- package/dist/components/inputs/KapiDateRangePicker.js +136 -135
- package/dist/components/inputs/KapiFacetedSearch.js +5 -5
- package/dist/components/inputs/KapiField.d.ts +9 -1
- package/dist/components/inputs/KapiField.js +43 -42
- package/dist/components/inputs/KapiFileUpload.js +6 -6
- package/dist/components/inputs/KapiInput.d.ts +29 -1
- package/dist/components/inputs/KapiInput.js +74 -51
- package/dist/components/inputs/KapiMaskedInput.js +26 -26
- package/dist/components/inputs/KapiNumberStepper.d.ts +7 -1
- package/dist/components/inputs/KapiNumberStepper.js +24 -23
- package/dist/components/inputs/KapiPinInput.d.ts +72 -0
- package/dist/components/inputs/KapiPinInput.js +75 -0
- package/dist/components/inputs/KapiPropsForm.d.ts +34 -0
- package/dist/components/inputs/KapiPropsForm.js +78 -0
- package/dist/components/inputs/KapiRating.d.ts +7 -1
- package/dist/components/inputs/KapiRating.js +39 -38
- package/dist/components/inputs/KapiSearchChip.js +5 -5
- package/dist/components/inputs/KapiSegmented.d.ts +13 -5
- package/dist/components/inputs/KapiSegmented.js +81 -77
- package/dist/components/inputs/KapiSelect.d.ts +9 -1
- package/dist/components/inputs/KapiSelect.js +236 -233
- package/dist/components/inputs/KapiSlider.d.ts +10 -3
- package/dist/components/inputs/KapiSlider.js +67 -63
- package/dist/components/inputs/KapiTagInput.d.ts +7 -1
- package/dist/components/inputs/KapiTagInput.js +70 -69
- package/dist/components/inputs/KapiTextarea.d.ts +7 -1
- package/dist/components/inputs/KapiTextarea.js +51 -50
- package/dist/components/inputs/copyLogic.d.ts +1 -0
- package/dist/components/inputs/copyLogic.js +12 -0
- package/dist/components/inputs/fieldLogic.d.ts +23 -3
- package/dist/components/inputs/fieldLogic.js +18 -11
- package/dist/components/inputs/index.d.ts +8 -0
- package/dist/components/inputs/inputLogic.d.ts +16 -1
- package/dist/components/inputs/inputLogic.js +3 -3
- package/dist/components/inputs/ownField.d.ts +3 -1
- package/dist/components/inputs/ownField.js +28 -27
- package/dist/components/inputs/pinInputLogic.d.ts +34 -0
- package/dist/components/inputs/pinInputLogic.js +37 -0
- package/dist/components/inputs/propsFormLogic.d.ts +53 -0
- package/dist/components/inputs/propsFormLogic.js +11 -0
- package/dist/components/inputs/segmentedLogic.d.ts +7 -0
- package/dist/components/inputs/segmentedLogic.js +2 -2
- package/dist/components/layout/KapiAccessCard.d.ts +5 -1
- package/dist/components/layout/KapiAccessCard.js +43 -39
- package/dist/components/layout/KapiAccountMenu.js +7 -7
- package/dist/components/layout/KapiCollapse.d.ts +39 -0
- package/dist/components/layout/KapiCollapse.js +20 -0
- package/dist/components/layout/KapiContextSlot.js +4 -4
- package/dist/components/layout/KapiDivider.d.ts +11 -2
- package/dist/components/layout/KapiDivider.js +30 -24
- package/dist/components/layout/KapiGrid.js +2 -2
- package/dist/components/layout/KapiNotificationBell.js +10 -10
- package/dist/components/layout/KapiPageHeader.js +22 -22
- package/dist/components/layout/KapiRail.js +4 -4
- package/dist/components/layout/KapiRoot.d.ts +22 -2
- package/dist/components/layout/KapiRoot.js +33 -29
- package/dist/components/layout/KapiShell.d.ts +9 -1
- package/dist/components/layout/KapiShell.js +28 -27
- package/dist/components/layout/accessCardLogic.d.ts +8 -1
- package/dist/components/layout/accessCardLogic.js +11 -7
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/locale/labelRegistry.d.ts +10 -0
- package/dist/components/navigation/KapiAccordion.js +9 -9
- package/dist/components/navigation/KapiContextPanel.js +12 -12
- package/dist/components/navigation/KapiNavBadge.d.ts +6 -3
- package/dist/components/navigation/KapiNavBadge.js +26 -22
- package/dist/components/navigation/KapiTabs.js +9 -9
- package/dist/components/navigation/KapiToc.d.ts +48 -0
- package/dist/components/navigation/KapiToc.js +66 -0
- package/dist/components/navigation/KapiTree.js +10 -10
- package/dist/components/navigation/index.d.ts +3 -0
- package/dist/components/navigation/tocLogic.d.ts +35 -0
- package/dist/components/navigation/tocLogic.js +11 -0
- package/dist/components/navigation/tocSlots.d.ts +8 -0
- package/dist/components/navigation/tocSlots.js +11 -0
- package/dist/components/overlays/KapiCommandPalette.js +6 -6
- package/dist/components/overlays/KapiContextMenu.js +5 -5
- package/dist/components/overlays/KapiMenuButton.js +7 -7
- package/dist/components/overlays/KapiModal.js +3 -3
- package/dist/components/overlays/KapiOffcanvas.js +24 -24
- package/dist/components/overlays/KapiPhotoView.js +10 -10
- package/dist/components/overlays/KapiPopover.js +6 -6
- package/dist/components/overlays/KapiShapeSheet.js +4 -4
- package/dist/components/overlays/KapiTooltip.js +18 -18
- package/dist/components/overlays/menuList.js +22 -22
- package/dist/components/slotCatalog.d.ts +33 -0
- package/dist/components/slotCatalog.js +18 -10
- package/dist/css/base.css +1 -1
- package/dist/css/components/display/KapiAnnotation.css +1 -1
- package/dist/css/components/display/KapiCodeBlock.css +1 -0
- package/dist/css/components/display/KapiDiff.css +1 -0
- package/dist/css/components/display/display.css +1 -1
- package/dist/css/components/feedback/feedback.css +1 -1
- package/dist/css/components/inputs/KapiPinInput.css +1 -0
- package/dist/css/components/inputs/KapiSelect.css +1 -1
- package/dist/css/components/inputs/inputsExtra.css +1 -1
- package/dist/css/components/layout/KapiAccessCard.css +1 -1
- package/dist/css/components/layout/KapiCollapse.css +1 -0
- package/dist/css/components/layout/KapiDivider.css +1 -1
- package/dist/css/components/navigation/KapiToc.css +1 -0
- package/dist/hooks/asyncResourceLogic.d.ts +11 -0
- package/dist/hooks/asyncResourceLogic.js +4 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/toneFamilyLogic.d.ts +26 -2
- package/dist/hooks/toneFamilyLogic.js +19 -6
- package/dist/hooks/useAsyncResource.d.ts +45 -0
- package/dist/hooks/useAsyncResource.js +24 -0
- package/dist/hooks/useKapiTheme.d.ts +8 -1
- package/dist/hooks/useKapiTheme.js +57 -57
- package/dist/hooks/useToneFamilies.d.ts +14 -4
- package/dist/hooks/useToneFamilies.js +27 -23
- package/dist/index.js +221 -207
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/dist/logic.d.ts +41 -0
- package/dist/logic.js +42 -0
- package/package.json +13 -2
|
@@ -30,8 +30,11 @@ export type KapiToneFamilies = Readonly<Record<string, KapiToneFamily>>;
|
|
|
30
30
|
*/
|
|
31
31
|
export declare const defineToneFamilies: <const F extends KapiToneFamilies>(families: F) => F;
|
|
32
32
|
/**
|
|
33
|
-
* Names a family cannot take: the six tones, the deprecated alias `error`,
|
|
34
|
-
*
|
|
33
|
+
* Names a family cannot take: the six tones, the deprecated alias `error`, the appearance words
|
|
34
|
+
* (`tone="solid"` is a SHAPE in `KapiBadge`) and `auto` (`tone="auto"` is `KapiAvatar`'s colour
|
|
35
|
+
* picked from the name). A family with one of these names could never be read where the word
|
|
36
|
+
* already means something else, so the word wins over the registry and the family is rejected at
|
|
37
|
+
* registration with a reason, instead of half working.
|
|
35
38
|
*/
|
|
36
39
|
export declare const RESERVED_TONE_NAMES: ReadonlySet<string>;
|
|
37
40
|
/**
|
|
@@ -75,6 +78,27 @@ export declare const resolveToneFamilies: (families: KapiToneFamilies | undefine
|
|
|
75
78
|
* every family, and a family name never has to appear in a stylesheet.
|
|
76
79
|
*/
|
|
77
80
|
export declare const toneFamilyStyle: (name: string) => Record<string, string>;
|
|
81
|
+
/** What a `tone` draws: the value a component should use, and the inline slots a family needs. */
|
|
82
|
+
export type KapiToneLook<T extends string> = {
|
|
83
|
+
/** The tone the component draws with: the given one, or `undefined` for an unregistered family. */
|
|
84
|
+
tone: T | undefined;
|
|
85
|
+
/** The four local slots, set inline, when the tone is a registered family. */
|
|
86
|
+
style: Record<string, string> | undefined;
|
|
87
|
+
/** The name of a family that is NOT registered, so the caller can warn once. */
|
|
88
|
+
unregistered: string | null;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* What a `tone` draws, given the family names a root has registered. Pure on purpose: `useToneLook`
|
|
92
|
+
* resolves ONE tone and is a hook, so it cannot be called inside the `map` of a component whose
|
|
93
|
+
* tone is PER ITEM (a timeline's dots, a segmented control's options). Those components read the
|
|
94
|
+
* names once, at the top, and call this for each item.
|
|
95
|
+
*
|
|
96
|
+
* A built-in tone (or an appearance word like `solid`) passes through and carries no style. A
|
|
97
|
+
* registered family comes back with its four slots. One that is NOT registered comes back as
|
|
98
|
+
* `undefined` — the component's default — and names itself in `unregistered`, because
|
|
99
|
+
* `var(--kapi-family-x)` would resolve to nothing and leave the element with no colour at all.
|
|
100
|
+
*/
|
|
101
|
+
export declare const resolveToneLook: <T extends string>(names: ReadonlySet<string>, tone: T | undefined) => KapiToneLook<T>;
|
|
78
102
|
/** One text-on-background pair of a family that falls below the threshold. */
|
|
79
103
|
export type KapiToneFamilyContrastFailure = {
|
|
80
104
|
/** The family's name. */
|
|
@@ -14,7 +14,8 @@ var s = (e) => e, c = /* @__PURE__ */ new Set([
|
|
|
14
14
|
"solid",
|
|
15
15
|
"outline",
|
|
16
16
|
"tonal",
|
|
17
|
-
"ghost"
|
|
17
|
+
"ghost",
|
|
18
|
+
"auto"
|
|
18
19
|
]), l = /^[a-zA-Z][a-zA-Z0-9]*$/, u = {
|
|
19
20
|
r: 255,
|
|
20
21
|
g: 255,
|
|
@@ -109,15 +110,27 @@ var s = (e) => e, c = /* @__PURE__ */ new Set([
|
|
|
109
110
|
"--kapi-tone-bg": `var(${m}${e}-bg)`,
|
|
110
111
|
"--kapi-tone-fg": `var(${m}${e}-fg)`,
|
|
111
112
|
"--kapi-tone-border": `var(${m}${e}-border)`
|
|
112
|
-
}), C = {
|
|
113
|
+
}), C = (e, t) => t === void 0 || c.has(t) ? {
|
|
114
|
+
tone: t,
|
|
115
|
+
style: void 0,
|
|
116
|
+
unregistered: null
|
|
117
|
+
} : e.has(t) ? {
|
|
118
|
+
tone: t,
|
|
119
|
+
style: S(t),
|
|
120
|
+
unregistered: null
|
|
121
|
+
} : {
|
|
122
|
+
tone: void 0,
|
|
123
|
+
style: void 0,
|
|
124
|
+
unregistered: t
|
|
125
|
+
}, w = {
|
|
113
126
|
"--kapi-danger": "color",
|
|
114
127
|
"--kapi-danger-fg": "fg"
|
|
115
|
-
},
|
|
128
|
+
}, T = {
|
|
116
129
|
"--kapi-card": "card",
|
|
117
130
|
"--kapi-bg": "page",
|
|
118
131
|
"--kapi-danger-bg": "bg",
|
|
119
132
|
"--kapi-danger": "color"
|
|
120
|
-
},
|
|
133
|
+
}, E = (e, n = {}) => {
|
|
121
134
|
let o = n.scheme ? [n.scheme] : ["light", "dark"], s = [];
|
|
122
135
|
for (let c of o) {
|
|
123
136
|
let o = a(c), l = n.surfaces?.[c], u = r(l?.card ?? "") ?? r(o.card), d = r(l?.bg ?? "") ?? r(o.bg);
|
|
@@ -133,7 +146,7 @@ var s = (e) => e, c = /* @__PURE__ */ new Set([
|
|
|
133
146
|
"--kapi-danger-fg": a.fg
|
|
134
147
|
}, { threshold: n.threshold });
|
|
135
148
|
for (let e of o) {
|
|
136
|
-
let t =
|
|
149
|
+
let t = w[e.foreground], n = T[e.background];
|
|
137
150
|
t && n && s.push({
|
|
138
151
|
family: r,
|
|
139
152
|
scheme: c,
|
|
@@ -148,4 +161,4 @@ var s = (e) => e, c = /* @__PURE__ */ new Set([
|
|
|
148
161
|
return s.sort((e, t) => e.ratio - t.ratio);
|
|
149
162
|
};
|
|
150
163
|
//#endregion
|
|
151
|
-
export { c as RESERVED_TONE_NAMES, l as TONE_FAMILY_NAME_PATTERN, m as TONE_FAMILY_PREFIX,
|
|
164
|
+
export { c as RESERVED_TONE_NAMES, l as TONE_FAMILY_NAME_PATTERN, m as TONE_FAMILY_PREFIX, E as checkToneFamilyContrast, s as defineToneFamilies, x as resolveToneFamilies, C as resolveToneLook, S as toneFamilyStyle };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type AsyncLoaderContext } from "./useAsyncLoader.js";
|
|
2
|
+
export type { AsyncLoaderContext as KapiAsyncResourceContext } from "./useAsyncLoader.js";
|
|
3
|
+
export type UseAsyncResourceOptions = {
|
|
4
|
+
/** Sólo pide mientras es `true`; al pasar a `false` aborta lo que esté en vuelo. @default true */
|
|
5
|
+
enabled?: boolean | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Al cambiar las dependencias, sigue mostrando lo anterior mientras llega lo nuevo, en vez de
|
|
8
|
+
* vaciar. Es lo que evita el parpadeo a blanco al pasar de página. @default false
|
|
9
|
+
*/
|
|
10
|
+
keepPreviousData?: boolean | undefined;
|
|
11
|
+
};
|
|
12
|
+
export type UseAsyncResourceResult<T> = {
|
|
13
|
+
/** Lo último que llegó bien, o `undefined` si todavía no llegó nada (o hubo error). */
|
|
14
|
+
data: T | undefined;
|
|
15
|
+
/** `true` si el pedido vigente falló. */
|
|
16
|
+
error: boolean;
|
|
17
|
+
/** `true` mientras se espera el pedido de las dependencias actuales. */
|
|
18
|
+
loading: boolean;
|
|
19
|
+
/** Aborta lo que esté en vuelo y vuelve a pedir, aunque las dependencias no hayan cambiado. */
|
|
20
|
+
reload: () => void;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Carga un dato cuando cambian sus dependencias, con `AbortSignal` y sin carreras.
|
|
24
|
+
*
|
|
25
|
+
* **Sólo el pedido vigente escribe.** Es lo único que importa de verdad acá y lo que casi nadie
|
|
26
|
+
* implementa bien a mano: si cambiás de id y la respuesta del id viejo llega DESPUÉS que la del
|
|
27
|
+
* nuevo, el estado se queda con el dato equivocado. Acá la respuesta vieja se descarta y su señal
|
|
28
|
+
* ya fue abortada, al cambiar las dependencias, al deshabilitar y al desmontar.
|
|
29
|
+
*
|
|
30
|
+
* **No es un motor nuevo**: por debajo es el mismo `useAsyncLoader` que usan `KapiSelect`,
|
|
31
|
+
* `KapiAutocomplete` y `KapiFacetedSearch`. Dos implementaciones de la misma carrera serían dos
|
|
32
|
+
* lugares donde arreglar el mismo bug.
|
|
33
|
+
*
|
|
34
|
+
* ```tsx
|
|
35
|
+
* const { data, loading, error, reload } = useAsyncResource(
|
|
36
|
+
* ({ signal }) => fetch(`/api/tramites/${id}`, { signal }).then((r) => r.json()),
|
|
37
|
+
* [id]
|
|
38
|
+
* );
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* Las dependencias se comparan por identidad (`Object.is`), igual que en `useEffect`: una función
|
|
42
|
+
* o un objeto inline cambian en cada render y re-dispararían la carga. `fetcher`, en cambio, se lee
|
|
43
|
+
* siempre el último y NO participa, así que puede ir inline sin envolverlo en `useCallback`.
|
|
44
|
+
*/
|
|
45
|
+
export declare const useAsyncResource: <T>(fetcher: ((context: AsyncLoaderContext) => Promise<T>) | undefined, deps: readonly unknown[], { enabled, keepPreviousData }?: UseAsyncResourceOptions) => UseAsyncResourceResult<T>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useAsyncLoader as e } from "./useAsyncLoader.js";
|
|
3
|
+
import { depsChanged as t } from "./asyncResourceLogic.js";
|
|
4
|
+
import { useRef as n } from "react";
|
|
5
|
+
//#region src/hooks/useAsyncResource.ts
|
|
6
|
+
var r = (r, i, { enabled: a = !0, keepPreviousData: o = !1 } = {}) => {
|
|
7
|
+
let s = n(0), c = n(null);
|
|
8
|
+
t(c.current, i) && (c.current = i, s.current += 1);
|
|
9
|
+
let { result: l, last: u, loading: d, reload: f } = e({
|
|
10
|
+
query: String(s.current),
|
|
11
|
+
enabled: a,
|
|
12
|
+
load: r === void 0 ? void 0 : (e, t) => r(t),
|
|
13
|
+
delay: 0,
|
|
14
|
+
revalidate: o
|
|
15
|
+
}), p = o ? l ?? u : l;
|
|
16
|
+
return {
|
|
17
|
+
data: p?.error === !0 ? void 0 : p?.data,
|
|
18
|
+
error: l?.error === !0,
|
|
19
|
+
loading: d,
|
|
20
|
+
reload: f
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { r as useAsyncResource };
|
|
@@ -100,8 +100,15 @@ export type KapiThemeStateOptions = {
|
|
|
100
100
|
* Dos apps del design system en el mismo origen pasan uno distinto para no pisarse las preferencias.
|
|
101
101
|
*/
|
|
102
102
|
namespace?: string | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Tema impuesto por la APP. Gana sobre lo guardado y sobre el sistema, y NO se guarda.
|
|
105
|
+
*
|
|
106
|
+
* Es para una app host que ya tiene su propio modo oscuro: sin esto la raíz `.kapi` decide sola
|
|
107
|
+
* y las dos quedan desincronizadas. Ver `KapiRootProps.theme`.
|
|
108
|
+
*/
|
|
109
|
+
theme?: KapiTheme | undefined;
|
|
103
110
|
};
|
|
104
111
|
/** Crea el estado del tema (lo usa KapiShell; usalo directo si armás tu propia raíz). */
|
|
105
|
-
export declare const useKapiThemeState: ({ namespace }?: KapiThemeStateOptions) => KapiThemeState;
|
|
112
|
+
export declare const useKapiThemeState: ({ namespace, theme: impuesto }?: KapiThemeStateOptions) => KapiThemeState;
|
|
106
113
|
/** Consume el tema desde cualquier componente dentro de <KapiShell>. */
|
|
107
114
|
export declare const useKapiTheme: () => KapiThemeState;
|
|
@@ -97,88 +97,88 @@ var k = {
|
|
|
97
97
|
fontChosen: L(t),
|
|
98
98
|
motion: R(n) ? n : "auto"
|
|
99
99
|
};
|
|
100
|
-
}, G = ({ namespace: e } = {}) => {
|
|
101
|
-
let
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
let e = W(
|
|
105
|
-
|
|
100
|
+
}, G = ({ namespace: e, theme: t } = {}) => {
|
|
101
|
+
let n = w(() => D(e), [e]), r = s(), i = r ? e : H, [a] = T(() => W(i)), [o, l] = T(a.preference), u = c(E), d = t ?? P(o, u), [f, h] = T(a.accent), [g, _] = T(a.customTheme), [b, S] = T(a.radii), [O, k] = T(a.fontChosen), [A, M] = T(a.font), [N, F] = T(a.motion), [L, R] = T(i);
|
|
102
|
+
if (L !== i) {
|
|
103
|
+
R(i);
|
|
104
|
+
let e = W(i);
|
|
105
|
+
l(e.preference), h(e.accent), _(e.customTheme), S(e.radii), M(e.font), k(e.fontChosen), F(e.motion);
|
|
106
106
|
}
|
|
107
107
|
C(() => {
|
|
108
|
-
|
|
108
|
+
r && j(n.theme, o);
|
|
109
109
|
}, [
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
n,
|
|
111
|
+
o,
|
|
112
|
+
r
|
|
113
113
|
]), C(() => {
|
|
114
|
-
|
|
114
|
+
r && j(n.accent, f);
|
|
115
115
|
}, [
|
|
116
|
-
|
|
117
|
-
u,
|
|
118
|
-
n
|
|
119
|
-
]), C(() => {
|
|
120
|
-
n && j(t.customTheme, m(f));
|
|
121
|
-
}, [
|
|
122
|
-
t,
|
|
116
|
+
n,
|
|
123
117
|
f,
|
|
124
|
-
|
|
118
|
+
r
|
|
125
119
|
]), C(() => {
|
|
126
|
-
|
|
120
|
+
r && j(n.customTheme, m(g));
|
|
127
121
|
}, [
|
|
128
|
-
|
|
122
|
+
n,
|
|
129
123
|
g,
|
|
130
|
-
|
|
124
|
+
r
|
|
131
125
|
]), C(() => {
|
|
132
|
-
|
|
126
|
+
r && j(n.radii, y(b));
|
|
133
127
|
}, [
|
|
134
|
-
|
|
135
|
-
O,
|
|
128
|
+
n,
|
|
136
129
|
b,
|
|
137
|
-
|
|
130
|
+
r
|
|
138
131
|
]), C(() => {
|
|
139
|
-
|
|
132
|
+
r && O && j(n.font, A);
|
|
140
133
|
}, [
|
|
141
|
-
|
|
134
|
+
n,
|
|
142
135
|
A,
|
|
143
|
-
|
|
136
|
+
O,
|
|
137
|
+
r
|
|
138
|
+
]), C(() => {
|
|
139
|
+
r && j(n.motion, N);
|
|
140
|
+
}, [
|
|
141
|
+
n,
|
|
142
|
+
N,
|
|
143
|
+
r
|
|
144
144
|
]);
|
|
145
|
-
let
|
|
146
|
-
|
|
147
|
-
}, []),
|
|
145
|
+
let z = x(() => l(I(d)), [d]), B = x((e) => l(e), []), V = x((e) => h(e || ""), []), U = x((e) => _(p(e)), []), G = x((e) => S(v(e)), []), K = x((e) => {
|
|
146
|
+
M(e), k(!0);
|
|
147
|
+
}, []), q = x(() => F((e) => e === "reduced" ? "auto" : "reduced"), []);
|
|
148
148
|
return w(() => ({
|
|
149
|
-
theme:
|
|
150
|
-
preference:
|
|
151
|
-
accent:
|
|
152
|
-
customTheme:
|
|
153
|
-
radii:
|
|
154
|
-
font:
|
|
155
|
-
fontChosen:
|
|
156
|
-
motion:
|
|
157
|
-
setTheme:
|
|
158
|
-
setPreference:
|
|
159
|
-
toggle:
|
|
160
|
-
setAccent:
|
|
161
|
-
setCustomTheme:
|
|
162
|
-
setRadii:
|
|
163
|
-
setFont:
|
|
164
|
-
setMotion:
|
|
165
|
-
toggleMotion:
|
|
149
|
+
theme: d,
|
|
150
|
+
preference: o,
|
|
151
|
+
accent: f,
|
|
152
|
+
customTheme: g,
|
|
153
|
+
radii: b,
|
|
154
|
+
font: A,
|
|
155
|
+
fontChosen: O,
|
|
156
|
+
motion: N,
|
|
157
|
+
setTheme: B,
|
|
158
|
+
setPreference: l,
|
|
159
|
+
toggle: z,
|
|
160
|
+
setAccent: V,
|
|
161
|
+
setCustomTheme: U,
|
|
162
|
+
setRadii: G,
|
|
163
|
+
setFont: K,
|
|
164
|
+
setMotion: F,
|
|
165
|
+
toggleMotion: q
|
|
166
166
|
}), [
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
u,
|
|
167
|
+
d,
|
|
168
|
+
o,
|
|
170
169
|
f,
|
|
171
170
|
g,
|
|
172
|
-
O,
|
|
173
171
|
b,
|
|
174
172
|
A,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
z,
|
|
173
|
+
O,
|
|
174
|
+
N,
|
|
178
175
|
B,
|
|
176
|
+
z,
|
|
179
177
|
V,
|
|
180
178
|
U,
|
|
181
|
-
G
|
|
179
|
+
G,
|
|
180
|
+
K,
|
|
181
|
+
q
|
|
182
182
|
]);
|
|
183
183
|
}, K = () => S(V);
|
|
184
184
|
//#endregion
|
|
@@ -17,6 +17,19 @@ export declare const useToneFamilyRegistry: (families: KapiToneFamilies | undefi
|
|
|
17
17
|
* ella quedaría sin color. Una vez por familia y por raíz. En producción no hace nada. Interno.
|
|
18
18
|
*/
|
|
19
19
|
export declare const useToneFamilyProblemWarning: (problems: readonly KapiToneFamilyProblem[]) => void;
|
|
20
|
+
/** Lo que devuelve el resolver: el tono a dibujar y, si es una familia, sus slots locales. */
|
|
21
|
+
export type KapiToneLookResult<T extends string> = {
|
|
22
|
+
tone: T | undefined;
|
|
23
|
+
style: CSSProperties | undefined;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Resolver de tonos para un componente cuyo tono es **por ítem** (los puntos de `KapiTimeline`, las
|
|
27
|
+
* opciones de `KapiSegmented`, los avatares de `KapiAvatarGroup`). `useToneLook` resuelve uno solo
|
|
28
|
+
* y es un hook, así que no se puede llamar dentro de un `map`: esto se llama una vez arriba y
|
|
29
|
+
* devuelve una función pura que se usa por ítem. Mismas reglas que `useToneLook`, mismo aviso de
|
|
30
|
+
* desarrollo (una vez por nombre). Interno.
|
|
31
|
+
*/
|
|
32
|
+
export declare const useToneLookResolver: <T extends string>(component: string) => ((tone: T | undefined) => KapiToneLookResult<T>);
|
|
20
33
|
/**
|
|
21
34
|
* Resuelve el `tone` de un componente. Un valor de la librería (o una forma como `solid`) pasa tal
|
|
22
35
|
* cual y no lleva estilo. Una familia registrada vuelve con los cuatro slots locales en `style`.
|
|
@@ -24,7 +37,4 @@ export declare const useToneFamilyProblemWarning: (problems: readonly KapiToneFa
|
|
|
24
37
|
* el default del componente, y avisa en desarrollo: sin esto, `var(--kapi-family-x)` no existe y
|
|
25
38
|
* el color se resuelve a nada, que es el fallo silencioso que esta librería no acepta. Interno.
|
|
26
39
|
*/
|
|
27
|
-
export declare const useToneLook: <T extends string>(component: string, tone: T | undefined) =>
|
|
28
|
-
tone: T | undefined;
|
|
29
|
-
style: CSSProperties | undefined;
|
|
30
|
-
};
|
|
40
|
+
export declare const useToneLook: <T extends string>(component: string, tone: T | undefined) => KapiToneLookResult<T>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { createContext as r, useContext as i, useEffect as a, useMemo as o, useRef as s } from "react";
|
|
4
|
-
var c =
|
|
2
|
+
import { resolveToneFamilies as e, resolveToneLook as t } from "./toneFamilyLogic.js";
|
|
3
|
+
import { createContext as n, useCallback as r, useContext as i, useEffect as a, useMemo as o, useRef as s } from "react";
|
|
4
|
+
var c = n(/* @__PURE__ */ new Set()), l = (t) => {
|
|
5
5
|
let n = i(c);
|
|
6
6
|
return o(() => {
|
|
7
|
-
if (!
|
|
7
|
+
if (!t) return {
|
|
8
8
|
names: n,
|
|
9
9
|
problems: []
|
|
10
10
|
};
|
|
11
|
-
let r = t
|
|
11
|
+
let r = e(t, "light", {
|
|
12
12
|
r: 255,
|
|
13
13
|
g: 255,
|
|
14
14
|
b: 255,
|
|
@@ -18,29 +18,33 @@ var c = r(/* @__PURE__ */ new Set()), l = (e) => {
|
|
|
18
18
|
names: /* @__PURE__ */ new Set([...n, ...r.names]),
|
|
19
19
|
problems: r.problems
|
|
20
20
|
};
|
|
21
|
-
}, [
|
|
21
|
+
}, [t, n]);
|
|
22
22
|
}, u = (e) => {
|
|
23
23
|
let t = s(/* @__PURE__ */ new Set());
|
|
24
24
|
a(() => {
|
|
25
25
|
if (process.env.NODE_ENV !== "production") for (let n of e) t.current.has(n.name) || (t.current.add(n.name), console.warn(`KapiRoot toneFamilies: la familia "${n.name}" no se registró (${n.reason}). ${n.detail}`));
|
|
26
26
|
}, [e]);
|
|
27
|
-
}, d = (
|
|
28
|
-
let
|
|
27
|
+
}, d = (e) => {
|
|
28
|
+
let t = s(/* @__PURE__ */ new Set()), n = s([]);
|
|
29
29
|
return a(() => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
t,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
r,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
if (n.current.length === 0) return;
|
|
31
|
+
let r = n.current;
|
|
32
|
+
if (n.current = [], process.env.NODE_ENV !== "production") for (let n of r) t.current.has(n) || (t.current.add(n), console.warn(`${e}: tone="${n}" no es un tono de la librería ni una familia registrada (\`toneFamilies\` en KapiRoot / KapiShell). Se dibuja con el color por defecto del componente.`));
|
|
33
|
+
}), r((e) => {
|
|
34
|
+
e !== null && n.current.push(e);
|
|
35
|
+
}, []);
|
|
36
|
+
}, f = (e) => {
|
|
37
|
+
let n = i(c), a = d(e);
|
|
38
|
+
return r((e) => {
|
|
39
|
+
let r = t(n, e);
|
|
40
|
+
return a(r.unregistered), {
|
|
41
|
+
tone: r.tone,
|
|
42
|
+
style: r.style
|
|
43
|
+
};
|
|
44
|
+
}, [n, a]);
|
|
45
|
+
}, p = (e, t) => {
|
|
46
|
+
let n = f(e);
|
|
47
|
+
return o(() => n(t), [n, t]);
|
|
44
48
|
};
|
|
45
49
|
//#endregion
|
|
46
|
-
export { c as ToneFamilyNamesContext, u as useToneFamilyProblemWarning, l as useToneFamilyRegistry,
|
|
50
|
+
export { c as ToneFamilyNamesContext, u as useToneFamilyProblemWarning, l as useToneFamilyRegistry, p as useToneLook, f as useToneLookResolver };
|