@42-central/ui-react 0.18.1 → 0.18.2
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/dist/components/data-table/data-table-stack.d.ts +2 -2
- package/dist/components/data-table/data-table-stack.d.ts.map +1 -1
- package/dist/components/data-table/data-table.d.ts.map +1 -1
- package/dist/components/data-table/index.js +44 -5
- package/dist/components/data-table/index.js.map +1 -1
- package/dist/components/kbd/index.js +29 -14
- package/dist/components/kbd/index.js.map +1 -1
- package/dist/components/kbd/kbd.d.ts.map +1 -1
- package/dist/components/schedule/index.js +2 -1
- package/dist/components/schedule/index.js.map +1 -1
- package/dist/components/schedule/now-cursor-line.d.ts.map +1 -1
- package/dist/components/switch/index.js +1 -1
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/switch/switch.d.ts +2 -0
- package/dist/components/switch/switch.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/data-table/data-table-stack.tsx +5 -3
- package/src/components/data-table/data-table.test.tsx +91 -0
- package/src/components/data-table/data-table.tsx +55 -6
- package/src/components/kbd/kbd.test.tsx +31 -0
- package/src/components/kbd/kbd.tsx +29 -14
- package/src/components/schedule/now-cursor-line.test.tsx +19 -0
- package/src/components/schedule/now-cursor-line.tsx +10 -1
- package/src/components/switch/switch.test.tsx +12 -0
- package/src/components/switch/switch.tsx +3 -1
|
@@ -9,9 +9,17 @@ var kbdVariants = cva(
|
|
|
9
9
|
[
|
|
10
10
|
"inline-flex items-center justify-center gap-1",
|
|
11
11
|
"whitespace-nowrap select-none",
|
|
12
|
-
|
|
12
|
+
// Regular weight, not medium: the mono face (Kode Mono) has no ⌘ ⇧ ⌥ ↵
|
|
13
|
+
// glyphs, so they fall back to a system font — and a 500 weight makes that
|
|
14
|
+
// fallback resolve to its *bold* face (Menlo Bold), a heavy blot next to
|
|
15
|
+
// the regular letters around it.
|
|
16
|
+
"font-mono font-normal leading-none",
|
|
13
17
|
"rounded-md border border-transparent",
|
|
14
18
|
"[&_svg]:shrink-0 [&_svg]:pointer-events-none",
|
|
19
|
+
// A 1.5px stroke at every size: the icon is sized by CSS, so a stroke in
|
|
20
|
+
// viewBox units would thin out at `size-3`. `non-scaling-stroke` keeps it in
|
|
21
|
+
// screen pixels (lucide's `absoluteStrokeWidth` ignores CSS sizing).
|
|
22
|
+
"[&_svg]:stroke-[1.5] [&_svg_*]:[vector-effect:non-scaling-stroke]",
|
|
15
23
|
// Inert on the default non-focusable <kbd>; applies once `asChild`
|
|
16
24
|
// renders Kbd onto a real <button>/<a>. See `focusStyles`.
|
|
17
25
|
focusStyles()
|
|
@@ -23,23 +31,30 @@ var kbdVariants = cva(
|
|
|
23
31
|
light: "bg-(--c-soft) text-(--c-text)",
|
|
24
32
|
outline: "bg-transparent text-(--c-text) border-(--c-solid)",
|
|
25
33
|
subtle: "bg-transparent text-(--c-text)",
|
|
26
|
-
// The key cap sits on the kit's translucent surface recipe —
|
|
27
|
-
// plus the hairline `border-brand-900/20 dark:border-white/15`,
|
|
28
|
-
// pair `Input`'s default shell, `Card`, `Tabs
|
|
29
|
-
// `ChoiceCardGroup` use. An opaque gray step can only ever be right on
|
|
30
|
-
// one background it was picked against, and a `Kbd` is most often
|
|
31
|
-
// into a Button, a Menu row or a tinted panel
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
+
// The key cap sits on the kit's translucent surface recipe — a 3%/4%
|
|
35
|
+
// overlay plus the hairline `border-brand-900/20 dark:border-white/15`,
|
|
36
|
+
// the same pair `Input`'s default shell, `Card`, `Tabs` and
|
|
37
|
+
// `ChoiceCardGroup` use. An opaque gray step can only ever be right on
|
|
38
|
+
// the one background it was picked against, and a `Kbd` is most often
|
|
39
|
+
// inlined into a Button, a Menu row or a tinted panel. Light mode
|
|
40
|
+
// darkens (`bg-black/3`) because `bg-white/4` on a near-white page is
|
|
41
|
+
// invisible; dark mode lightens. A 1px inset shade along the bottom
|
|
42
|
+
// edge is the key-cap depth cue — the lip of a physical key — without
|
|
43
|
+
// adding height. The label is the kit's secondary text, not full
|
|
44
|
+
// contrast: a shortcut hint annotates the action, it is not the action.
|
|
34
45
|
default: [
|
|
35
|
-
"bg-
|
|
36
|
-
"
|
|
46
|
+
"bg-black/3 text-gray-light-700 border-brand-900/20",
|
|
47
|
+
"shadow-[inset_0_-1px_0_0_rgb(0_0_0/0.08)]",
|
|
48
|
+
"dark:bg-white/4 dark:text-gray-dark-300 dark:border-white/15",
|
|
49
|
+
"dark:shadow-[inset_0_-1px_0_0_rgb(0_0_0/0.35)]"
|
|
37
50
|
]
|
|
38
51
|
},
|
|
52
|
+
// Type is one Tailwind step per size (12 / 14 / 16px), the scale of
|
|
53
|
+
// the text a key sits beside — a 10px label left ⌘ and ↵ unreadable.
|
|
39
54
|
size: {
|
|
40
|
-
sm: "h-5 min-w-5 px-1.5 text-
|
|
41
|
-
md: "h-6 min-w-6 px-1.5 text-
|
|
42
|
-
lg: "h-7 min-w-7 px-2 text-
|
|
55
|
+
sm: "h-5 min-w-5 px-1.5 text-xs [&_svg]:size-3",
|
|
56
|
+
md: "h-6 min-w-6 px-1.5 text-sm [&_svg]:size-3.5",
|
|
57
|
+
lg: "h-7 min-w-7 px-2 text-base [&_svg]:size-4"
|
|
43
58
|
}
|
|
44
59
|
},
|
|
45
60
|
defaultVariants: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/kbd/kbd.tsx"],"names":[],"mappings":";;;;;;;AAkCA,IAAM,WAAA,GAAc,GAAA;AAAA,EAClB;AAAA,IACE,+CAAA;AAAA,IACA,+BAAA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/components/kbd/kbd.tsx"],"names":[],"mappings":";;;;;;;AAkCA,IAAM,WAAA,GAAc,GAAA;AAAA,EAClB;AAAA,IACE,+CAAA;AAAA,IACA,+BAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,oCAAA;AAAA,IACA,sCAAA;AAAA,IACA,8CAAA;AAAA;AAAA;AAAA;AAAA,IAIA,mEAAA;AAAA;AAAA;AAAA,IAGA,WAAA;AAAY,GACd;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA,QACP,MAAA,EAAQ,oCAAA;AAAA,QACR,KAAA,EAAO,+BAAA;AAAA,QACP,OAAA,EAAS,mDAAA;AAAA,QACT,MAAA,EAAQ,gCAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAYR,OAAA,EAAS;AAAA,UACP,oDAAA;AAAA,UACA,2CAAA;AAAA,UACA,8DAAA;AAAA,UACA;AAAA;AACF,OACF;AAAA;AAAA;AAAA,MAGA,IAAA,EAAM;AAAA,QACJ,EAAA,EAAI,2CAAA;AAAA,QACJ,EAAA,EAAI,6CAAA;AAAA,QACJ,EAAA,EAAI;AAAA;AACN,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,OAAA,EAAS,SAAA;AAAA,MACT,IAAA,EAAM;AAAA;AACR;AAEJ,CAAA;AAYO,IAAM,GAAA,GAAM,CAAC,EAAE,SAAA,EAAW,OAAA,EAAS,MAAM,KAAA,EAAO,MAAA,EAAQ,GAAG,IAAA,EAAK,KAAgB;AACrF,EAAA,uBACE,GAAA;AAAA,IAAC,GAAA,CAAI,GAAA;AAAA,IAAJ;AAAA,MACC,YAAA,EAAY,KAAA;AAAA,MACX,GAAG,KAAA,CAAM,EAAE,aAAA,EAAe,QAAQ,CAAA;AAAA,MAClC,GAAG,IAAA;AAAA,MACJ,SAAA,EAAW,GAAG,WAAA,CAAY,EAAE,SAAS,IAAA,EAAM,GAAG,SAAS;AAAA;AAAA,GACzD;AAEJ","file":"index.js","sourcesContent":["import { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\n\n/**\n * Kbd — a keyboard-key / shortcut indicator (`<kbd>`).\n *\n * Pure React Server Component. It borrows Button's (variant × color) system so\n * a shortcut hint speaks the same accent language as the action it labels — but\n * unlike Button it is non-interactive: no hover treatment, no click handling,\n * just a key cap.\n *\n * The shape axis is the exact set Button exposes (filled / light / outline /\n * subtle / default), wired through the same `--c-*` slot vars — `color` routes\n * via a `data-color` attribute resolved in `colors.css`, so the cva matrix\n * enumerates variants only, never (variant × color) pairs. The default\n * treatment is the `default` variant: a neutral, bordered key-cap surface that\n * reads as a physical key regardless of `color` (pairing `default` with a color\n * is a no-op, mirroring Button/Badge).\n *\n * Sizing keeps single-character keys square via a per-size `min-w` equal to the\n * height, while wider labels (`Enter`, `Esc`, `⌘N`) grow horizontally. Padding\n * is symmetric, so a key reads the same in RTL.\n *\n * `asChild` (from `HTMLArkProps`) renders the single child as the root with\n * Kbd's styling merged in — e.g. `<Kbd asChild><a href=\"…\">⌘K</a></Kbd>`. The\n * kit's focus ring (`focusStyles`) comes along with it, so a Kbd composed onto\n * a real control is keyboard-visible without the caller restyling anything; on\n * a plain `<kbd>` those classes never match.\n */\nconst kbdVariants = cva(\n [\n \"inline-flex items-center justify-center gap-1\",\n \"whitespace-nowrap select-none\",\n // Regular weight, not medium: the mono face (Kode Mono) has no ⌘ ⇧ ⌥ ↵\n // glyphs, so they fall back to a system font — and a 500 weight makes that\n // fallback resolve to its *bold* face (Menlo Bold), a heavy blot next to\n // the regular letters around it.\n \"font-mono font-normal leading-none\",\n \"rounded-md border border-transparent\",\n \"[&_svg]:shrink-0 [&_svg]:pointer-events-none\",\n // A 1.5px stroke at every size: the icon is sized by CSS, so a stroke in\n // viewBox units would thin out at `size-3`. `non-scaling-stroke` keeps it in\n // screen pixels (lucide's `absoluteStrokeWidth` ignores CSS sizing).\n \"[&_svg]:stroke-[1.5] [&_svg_*]:[vector-effect:non-scaling-stroke]\",\n // Inert on the default non-focusable <kbd>; applies once `asChild`\n // renders Kbd onto a real <button>/<a>. See `focusStyles`.\n focusStyles(),\n ],\n {\n variants: {\n variant: {\n filled: \"bg-(--c-solid) text-(--c-on-solid)\",\n light: \"bg-(--c-soft) text-(--c-text)\",\n outline: \"bg-transparent text-(--c-text) border-(--c-solid)\",\n subtle: \"bg-transparent text-(--c-text)\",\n // The key cap sits on the kit's translucent surface recipe — a 3%/4%\n // overlay plus the hairline `border-brand-900/20 dark:border-white/15`,\n // the same pair `Input`'s default shell, `Card`, `Tabs` and\n // `ChoiceCardGroup` use. An opaque gray step can only ever be right on\n // the one background it was picked against, and a `Kbd` is most often\n // inlined into a Button, a Menu row or a tinted panel. Light mode\n // darkens (`bg-black/3`) because `bg-white/4` on a near-white page is\n // invisible; dark mode lightens. A 1px inset shade along the bottom\n // edge is the key-cap depth cue — the lip of a physical key — without\n // adding height. The label is the kit's secondary text, not full\n // contrast: a shortcut hint annotates the action, it is not the action.\n default: [\n \"bg-black/3 text-gray-light-700 border-brand-900/20\",\n \"shadow-[inset_0_-1px_0_0_rgb(0_0_0/0.08)]\",\n \"dark:bg-white/4 dark:text-gray-dark-300 dark:border-white/15\",\n \"dark:shadow-[inset_0_-1px_0_0_rgb(0_0_0/0.35)]\",\n ],\n },\n // Type is one Tailwind step per size (12 / 14 / 16px), the scale of\n // the text a key sits beside — a 10px label left ⌘ and ↵ unreadable.\n size: {\n sm: \"h-5 min-w-5 px-1.5 text-xs [&_svg]:size-3\",\n md: \"h-6 min-w-6 px-1.5 text-sm [&_svg]:size-3.5\",\n lg: \"h-7 min-w-7 px-2 text-base [&_svg]:size-4\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"md\",\n },\n },\n)\n\nexport type KbdVariant = NonNullable<VariantProps<typeof kbdVariants>[\"variant\"]>\nexport type KbdSize = NonNullable<VariantProps<typeof kbdVariants>[\"size\"]>\n\nexport type KbdProps = HTMLArkProps<\"kbd\"> &\n VariantProps<typeof kbdVariants> &\n WithTestId & {\n /** Accent palette. Re-exported as `Color` from `@42/ui-react`. */\n color?: Color\n }\n\nexport const Kbd = ({ className, variant, size, color, testId, ...rest }: KbdProps) => {\n return (\n <ark.kbd\n data-color={color}\n {...props({ \"data-testid\": testId })}\n {...rest}\n className={cn(kbdVariants({ variant, size }), className)}\n />\n )\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kbd.d.ts","sourceRoot":"","sources":["../../../src/components/kbd/kbd.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAG7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,QAAA,MAAM,WAAW;;;
|
|
1
|
+
{"version":3,"file":"kbd.d.ts","sourceRoot":"","sources":["../../../src/components/kbd/kbd.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAG7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,QAAA,MAAM,WAAW;;;8EAyDhB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC,YAAY,CAAC,OAAO,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;AACjF,MAAM,MAAM,OAAO,GAAG,WAAW,CAAC,YAAY,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAE3E,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,GACxC,YAAY,CAAC,OAAO,WAAW,CAAC,GAChC,UAAU,GAAG;IACX,kEAAkE;IAClE,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAEH,eAAO,MAAM,GAAG,yDAA0D,QAAQ,gCASjF,CAAA"}
|
|
@@ -1282,6 +1282,7 @@ function NowCursorLine({
|
|
|
1282
1282
|
}
|
|
1283
1283
|
);
|
|
1284
1284
|
}
|
|
1285
|
+
var HALF_LABEL = "calc((1em + 0.25rem) / 2)";
|
|
1285
1286
|
function NowCursorLabel({
|
|
1286
1287
|
now,
|
|
1287
1288
|
startHour,
|
|
@@ -1320,7 +1321,7 @@ function NowCursorLabel({
|
|
|
1320
1321
|
"[--sch-now-line-color:var(--color-red-500)]",
|
|
1321
1322
|
className
|
|
1322
1323
|
),
|
|
1323
|
-
style: { top:
|
|
1324
|
+
style: { top: `clamp(${HALF_LABEL}, ${top}%, calc(100% - ${HALF_LABEL}))` },
|
|
1324
1325
|
children: clockTimeLabel(current, locale)
|
|
1325
1326
|
}
|
|
1326
1327
|
);
|