@pontive/pontkit-core 1.26.0 → 1.27.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.
Files changed (62) hide show
  1. package/catalog.json +1 -1
  2. package/custom-elements.json +1 -1
  3. package/dist/pont2/core/attrs.d.ts +22 -0
  4. package/dist/pont2/core/controllers/roving-focus.d.ts +38 -0
  5. package/dist/pont2/core/events.d.ts +28 -0
  6. package/dist/pont2/core/form-control.d.ts +70 -0
  7. package/dist/pont2/core/host-element.d.ts +129 -0
  8. package/dist/pont2/core/icons.d.ts +20 -0
  9. package/dist/pont2/core/ids.d.ts +6 -0
  10. package/dist/pont2/core/index.d.ts +8 -0
  11. package/dist/pont2/core/names.d.ts +78 -0
  12. package/dist/pont2/core/popup/anchored.d.ts +48 -0
  13. package/dist/pont2/core/popup/index.d.ts +5 -0
  14. package/dist/pont2/core/popup/list.d.ts +38 -0
  15. package/dist/pont2/core/popup/popup-content.d.ts +68 -0
  16. package/dist/pont2/core/popup/popup-root.d.ts +94 -0
  17. package/dist/pont2/core/popup/position.d.ts +73 -0
  18. package/dist/pont2/globals.css +109 -0
  19. package/dist/pont2/index.d.ts +44 -0
  20. package/dist/pont2/index.mjs +3805 -0
  21. package/dist/pont2/index.mjs.map +1 -0
  22. package/dist/pont2/kit/alert/alert.d.ts +62 -0
  23. package/dist/pont2/kit/aliases.d.ts +33 -0
  24. package/dist/pont2/kit/avatar/avatar.d.ts +52 -0
  25. package/dist/pont2/kit/index.d.ts +3 -0
  26. package/dist/pont2/kit/input-otp/input-otp.d.ts +52 -0
  27. package/dist/pont2/primitives/alert/alert.d.ts +49 -0
  28. package/dist/pont2/primitives/avatar/avatar.d.ts +89 -0
  29. package/dist/pont2/primitives/badge/badge.d.ts +30 -0
  30. package/dist/pont2/primitives/button/button.d.ts +113 -0
  31. package/dist/pont2/primitives/button-group/button-group.d.ts +55 -0
  32. package/dist/pont2/primitives/card/card.d.ts +63 -0
  33. package/dist/pont2/primitives/checkbox/checkbox.d.ts +54 -0
  34. package/dist/pont2/primitives/combobox/combobox.d.ts +213 -0
  35. package/dist/pont2/primitives/dropdown-menu/dropdown-menu.d.ts +267 -0
  36. package/dist/pont2/primitives/empty/empty.d.ts +60 -0
  37. package/dist/pont2/primitives/field/field.d.ts +146 -0
  38. package/dist/pont2/primitives/input/input.d.ts +47 -0
  39. package/dist/pont2/primitives/input-group/input-group.d.ts +97 -0
  40. package/dist/pont2/primitives/input-otp/input-otp.d.ts +121 -0
  41. package/dist/pont2/primitives/input-otp/otp.d.ts +22 -0
  42. package/dist/pont2/primitives/item/item.d.ts +100 -0
  43. package/dist/pont2/primitives/kbd/kbd.d.ts +29 -0
  44. package/dist/pont2/primitives/label/label.d.ts +37 -0
  45. package/dist/pont2/primitives/native-select/native-select.d.ts +59 -0
  46. package/dist/pont2/primitives/popover/popover.d.ts +85 -0
  47. package/dist/pont2/primitives/progress/progress.d.ts +80 -0
  48. package/dist/pont2/primitives/radio-group/radio-group.d.ts +93 -0
  49. package/dist/pont2/primitives/select/select.d.ts +184 -0
  50. package/dist/pont2/primitives/separator/separator.d.ts +34 -0
  51. package/dist/pont2/primitives/skeleton/skeleton.d.ts +18 -0
  52. package/dist/pont2/primitives/slider/slider-math.d.ts +42 -0
  53. package/dist/pont2/primitives/slider/slider.d.ts +85 -0
  54. package/dist/pont2/primitives/spinner/spinner.d.ts +29 -0
  55. package/dist/pont2/primitives/switch/switch.d.ts +55 -0
  56. package/dist/pont2/primitives/table/table.d.ts +55 -0
  57. package/dist/pont2/primitives/tabs/tabs.d.ts +126 -0
  58. package/dist/pont2/primitives/textarea/textarea.d.ts +41 -0
  59. package/dist/pont2/primitives/tooltip/tooltip.d.ts +69 -0
  60. package/dist/pont2/styles.css +4137 -0
  61. package/dist/pont2/with-legacy.css +10 -0
  62. package/package.json +16 -4
@@ -0,0 +1,94 @@
1
+ import { PropertyDeclarations, PropertyValues } from 'lit';
2
+ import { OpenChangeReason } from '../events';
3
+ import { HostElement, NativeEnhancer } from '../host-element';
4
+ import { PopupContent } from './popup-content';
5
+ /**
6
+ * Finds the first element matching `selector` under `root` that belongs to
7
+ * `root` itself, i.e. whose closest `rootSelector` ancestor is `root` (so a
8
+ * DropdownMenu never picks up its submenu's trigger or content).
9
+ */
10
+ export declare function ownQuery<T extends Element>(root: Element, selector: string, rootSelector: string): T | null;
11
+ /** All matches that belong to `root` (see ownQuery). */
12
+ export declare function ownQueryAll<T extends Element>(root: Element, selector: string, rootSelector: string): T[];
13
+ /**
14
+ * # PopupRoot: the coordinator of a popup family
15
+ *
16
+ * Base UI's `<Menu.Root>`, `<Popover.Root>`, `<Select.Root>` render **no
17
+ * element**; they are React context providers. A custom element cannot
18
+ * render nothing, so pont2's roots are *coordinators*: they exist in the
19
+ * DOM (authors need a tag to group trigger and content) but have no box and
20
+ * no role:
21
+ *
22
+ * `[data-pont2-popup-root] { display: contents }` (core/popup/popup.css)
23
+ *
24
+ * That is the same reasoning as a Tier 3 shell, applied to an element whose
25
+ * shadcn counterpart has no DOM at all. Instead of context, the root finds
26
+ * its parts by DOM lookup (`ownQuery`), wires their ARIA, and owns the one
27
+ * piece of state: `open`.
28
+ *
29
+ * `open` changes requested by the user (trigger press, Escape, outside press,
30
+ * item press…) go through `setOpen(open, reason)`, which fires a cancelable
31
+ * `pont2-open-change` ({ open, reason }) first: Base UI's
32
+ * `onOpenChange(open, eventDetails)` + `eventDetails.cancel()`. Writing the
33
+ * `open` property directly is the controlled form and fires nothing.
34
+ */
35
+ export declare abstract class PopupRoot extends HostElement {
36
+ static identity: string;
37
+ static properties: PropertyDeclarations;
38
+ open: boolean;
39
+ disabled: boolean;
40
+ /** Why the popup last opened/closed (drives focus management). */
41
+ protected lastReason: OpenChangeReason;
42
+ /** Whether the last open was keyboard-initiated (focus the first item, not the popup). */
43
+ protected openedByKeyboard: boolean;
44
+ constructor();
45
+ /** The element the popup anchors to and returns focus to (a native button / input). */
46
+ abstract get triggerElement(): HTMLElement | null;
47
+ abstract get contentElement(): PopupContent | null;
48
+ /** `aria-haspopup` value for the trigger. */
49
+ protected abstract get popupKind(): "menu" | "listbox" | "dialog" | "true";
50
+ /**
51
+ * Request an open-state change, as the user did. Returns false if a
52
+ * `pont2-open-change` listener cancelled it.
53
+ */
54
+ setOpen(open: boolean, reason: OpenChangeReason, opts?: {
55
+ keyboard?: boolean;
56
+ }): boolean;
57
+ toggle(reason?: OpenChangeReason, opts?: {
58
+ keyboard?: boolean;
59
+ }): void;
60
+ connectedCallback(): void;
61
+ /** Connect trigger and content (idempotent). Call when parts change. */
62
+ wire(): void;
63
+ /** What the content positions against. Defaults to the trigger. */
64
+ protected anchorElement(): Element | null;
65
+ /** Further elements whose presses are not "outside" (e.g. a combobox input group). */
66
+ protected extraInsideElements(): (Element | null)[];
67
+ protected updated(changed: PropertyValues): void;
68
+ /** Focus management after opening. Default: focus the popup itself. */
69
+ protected afterOpen(): void;
70
+ /** Focus management after closing. Default: return focus to the trigger if it was inside. */
71
+ protected afterClose(focusWasInside: boolean): void;
72
+ }
73
+ /**
74
+ * Trigger enhancer: `<pont2-x-trigger><button>…</button></pont2-x-trigger>`.
75
+ * The native button is the trigger (Tier 3). It gets `data-slot`, and its
76
+ * root sets `aria-haspopup` / `aria-expanded` / `aria-controls` /
77
+ * `data-popup-open` on it. Pressing it toggles the root.
78
+ */
79
+ export declare abstract class PopupTrigger extends NativeEnhancer<HTMLButtonElement> {
80
+ static nativeSelector: string;
81
+ /** Tag of the root this trigger belongs to. */
82
+ static rootTag: string;
83
+ /**
84
+ * `data-slot` written on the *native button* (e.g. "dropdown-menu-trigger").
85
+ * Deliberately not `slotName`: that would stamp the shell, and a shell is
86
+ * never styled or selected.
87
+ */
88
+ static controlSlot: string;
89
+ get root(): PopupRoot | null;
90
+ constructor();
91
+ protected apply(control: HTMLButtonElement): void;
92
+ protected onClick(e: MouseEvent): void;
93
+ protected onKeyDown(_e: KeyboardEvent): void;
94
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Pure anchored-positioning maths (no DOM). The same model as Floating UI /
3
+ * Base UI's `<Positioner>`: place the floating box on a `side` of the anchor,
4
+ * `align` it along that side, then `flip` to the opposite side and `shift`
5
+ * along the cross axis to stay inside the viewport minus `collisionPadding`.
6
+ *
7
+ * Unit-tested in node: position.test.ts.
8
+ */
9
+ export type PhysicalSide = "top" | "bottom" | "left" | "right";
10
+ /** Base UI sides: physical, or logical (`inline-start`/`inline-end` follow `dir`). */
11
+ export type Side = PhysicalSide | "inline-start" | "inline-end";
12
+ export type Align = "start" | "center" | "end";
13
+ export interface Rect {
14
+ x: number;
15
+ y: number;
16
+ width: number;
17
+ height: number;
18
+ }
19
+ export interface Size {
20
+ width: number;
21
+ height: number;
22
+ }
23
+ export interface PositionInput {
24
+ anchor: Rect;
25
+ floating: Size;
26
+ viewport: Rect;
27
+ side?: Side;
28
+ align?: Align;
29
+ /** Gap between anchor and floating box, on the main axis (px). */
30
+ sideOffset?: number;
31
+ /** Offset along the cross axis (px). Positive moves towards `end` for start/center, towards `start` for end. */
32
+ alignOffset?: number;
33
+ /** Minimum distance kept from the viewport edges (px). Base UI default: 5. */
34
+ collisionPadding?: number;
35
+ flip?: boolean;
36
+ shift?: boolean;
37
+ dir?: "ltr" | "rtl";
38
+ }
39
+ export interface PositionResult {
40
+ x: number;
41
+ y: number;
42
+ /** The side actually used, in the vocabulary it was requested in (logical stays logical). */
43
+ side: Side;
44
+ physicalSide: PhysicalSide;
45
+ align: Align;
46
+ /** Space between the floating box's anchored edge and the viewport edge (Base UI `--available-*`). */
47
+ availableWidth: number;
48
+ availableHeight: number;
49
+ /** `--transform-origin`: the point of the anchor the box grows from. */
50
+ transformOrigin: string;
51
+ }
52
+ export declare function toPhysical(side: Side, dir: "ltr" | "rtl"): PhysicalSide;
53
+ /** Free space between the anchor (plus offset) and the padded viewport edge on `side`. */
54
+ export declare function spaceOn(side: PhysicalSide, anchor: Rect, viewport: Rect, offset: number, pad: number): number;
55
+ export declare function computePosition(input: PositionInput): PositionResult;
56
+ /**
57
+ * Base UI Select's `alignItemWithTrigger`: place the popup so the selected
58
+ * item sits exactly over the trigger (macOS-style). Returns `null` when that
59
+ * is impossible inside the padded viewport, so the caller falls back to
60
+ * normal side positioning (Base UI does the same).
61
+ */
62
+ export declare function alignItemWithAnchor(input: {
63
+ anchor: Rect;
64
+ floating: Size;
65
+ viewport: Rect;
66
+ /** Offset of the item's top edge from the floating box's top edge (scroll already subtracted). */
67
+ itemTop: number;
68
+ itemHeight: number;
69
+ collisionPadding?: number;
70
+ }): {
71
+ x: number;
72
+ y: number;
73
+ } | null;
@@ -0,0 +1,109 @@
1
+ /* @pontive/pontkit-core pont2 — generated by pont2/scripts/build-css.mjs */
2
+ /*
3
+ * OPTIONAL page-level stylesheet: `@pontive/pontkit-core/pont2/globals.css`.
4
+ *
5
+ * What a shadcn app gets from Tailwind preflight plus shadcn's
6
+ * @layer base { * { @apply border-border outline-ring/50 } body { @apply bg-background text-foreground } }
7
+ * in one file, in the lowest pont2 layer (`pont2.reset`), so it never beats
8
+ * a component recipe, and any unlayered app CSS beats it.
9
+ *
10
+ * pont2 components do NOT need this file. Load it only if you want the page
11
+ * itself to look like a shadcn app. It is global by nature (it styles
12
+ * `body` and `*`), which is why it is not part of styles.css.
13
+ */
14
+ @layer pont2.reset, pont2.tokens, pont2.base, pont2.primitives, pont2.kit;
15
+
16
+ @layer pont2.reset {
17
+ *,
18
+ ::before,
19
+ ::after,
20
+ ::backdrop,
21
+ ::file-selector-button {
22
+ box-sizing: border-box;
23
+ margin: 0;
24
+ padding: 0;
25
+ border: 0 solid var(--pont2-border);
26
+ }
27
+
28
+ html,
29
+ :host {
30
+ line-height: 1.5;
31
+ -webkit-text-size-adjust: 100%;
32
+ tab-size: 4;
33
+ font-family: var(--pont2-font-sans);
34
+ -webkit-tap-highlight-color: transparent;
35
+ }
36
+
37
+ * {
38
+ outline-color: color-mix(in oklab, var(--pont2-ring) 50%, transparent);
39
+ }
40
+
41
+ body {
42
+ line-height: inherit;
43
+ background-color: var(--pont2-background);
44
+ color: var(--pont2-foreground);
45
+ }
46
+
47
+ h1, h2, h3, h4, h5, h6 {
48
+ font-size: inherit;
49
+ font-weight: inherit;
50
+ }
51
+
52
+ a {
53
+ color: inherit;
54
+ text-decoration: inherit;
55
+ }
56
+
57
+ b, strong {
58
+ font-weight: bolder;
59
+ }
60
+
61
+ code, kbd, samp, pre {
62
+ font-family: var(--pont2-font-mono);
63
+ font-size: 1em;
64
+ }
65
+
66
+ table {
67
+ text-indent: 0;
68
+ border-color: inherit;
69
+ border-collapse: collapse;
70
+ }
71
+
72
+ ol, ul, menu {
73
+ list-style: none;
74
+ }
75
+
76
+ img, svg, video, canvas, audio, iframe, embed, object {
77
+ display: block;
78
+ vertical-align: middle;
79
+ }
80
+
81
+ img, video {
82
+ max-width: 100%;
83
+ height: auto;
84
+ }
85
+
86
+ button, input, select, optgroup, textarea, ::file-selector-button {
87
+ font: inherit;
88
+ font-feature-settings: inherit;
89
+ font-variation-settings: inherit;
90
+ letter-spacing: inherit;
91
+ color: inherit;
92
+ border-radius: 0;
93
+ background-color: transparent;
94
+ opacity: 1;
95
+ }
96
+
97
+ ::placeholder {
98
+ opacity: 1;
99
+ color: color-mix(in oklab, currentcolor 50%, transparent);
100
+ }
101
+
102
+ textarea {
103
+ resize: vertical;
104
+ }
105
+
106
+ [hidden]:where(:not([hidden="until-found"])) {
107
+ display: none !important;
108
+ }
109
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * pont2: shadcn/ui (Base UI flavour) as light-DOM web components, built on
3
+ * the host-as-root architecture (pont2/docs).
4
+ *
5
+ * Importing this module registers every `pont2-*` element. Import a single
6
+ * component module (`@pontive/pontkit-core/pont2` re-exports them all) if you
7
+ * only need some; each module registers only its own tags.
8
+ *
9
+ * Styles are separate: `@pontive/pontkit-core/pont2/styles.css`.
10
+ */
11
+ export * from './core';
12
+ export * from './primitives/badge/badge';
13
+ export * from './primitives/button/button';
14
+ export * from './primitives/checkbox/checkbox';
15
+ export * from './primitives/input/input';
16
+ export * from './primitives/kbd/kbd';
17
+ export * from './primitives/label/label';
18
+ export * from './primitives/separator/separator';
19
+ export * from './primitives/skeleton/skeleton';
20
+ export * from './primitives/spinner/spinner';
21
+ export * from './primitives/textarea/textarea';
22
+ export * from './primitives/alert/alert';
23
+ export * from './primitives/avatar/avatar';
24
+ export * from './primitives/button-group/button-group';
25
+ export * from './primitives/card/card';
26
+ export * from './primitives/empty/empty';
27
+ export * from './primitives/field/field';
28
+ export * from './primitives/input-group/input-group';
29
+ export * from './primitives/item/item';
30
+ export * from './primitives/native-select/native-select';
31
+ export * from './primitives/table/table';
32
+ export * from './primitives/input-otp/input-otp';
33
+ export * from './primitives/progress/progress';
34
+ export * from './primitives/radio-group/radio-group';
35
+ export * from './primitives/slider/slider';
36
+ export * from './primitives/switch/switch';
37
+ export * from './primitives/tabs/tabs';
38
+ export * from './core/popup';
39
+ export * from './primitives/popover/popover';
40
+ export * from './primitives/dropdown-menu/dropdown-menu';
41
+ export * from './primitives/select/select';
42
+ export * from './primitives/combobox/combobox';
43
+ export * from './primitives/tooltip/tooltip';
44
+ export * from './kit';