@publier/primitives 0.3.34

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 ADDED
@@ -0,0 +1 @@
1
+ # @publier/primitives
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@publier/primitives",
3
+ "version": "0.3.34",
4
+ "license": "UNLICENSED",
5
+ "description": "MDX-facing interactive primitives for Publier (Accordion, Tooltip, Tabs, CopyButton, ImageZoom, ColorSwatch, ViewAnimation). Zero-Qwik Astro components built on daisyUI + HTML natives + lazy-upgraded web components.",
6
+ "_filesRationale": "source-shipped Astro/Qwik: globs + negation; consumer's Astro+Vite compiles JSX/.astro AST",
7
+ "type": "module",
8
+ "files": [
9
+ "src/**/*.ts",
10
+ "src/**/*.astro",
11
+ "src/**/*.css",
12
+ "!src/**/__tests__/**",
13
+ "!src/**/*.test.ts",
14
+ "!__tests__/**"
15
+ ],
16
+ "exports": {
17
+ ".": {
18
+ "types": "./src/index.ts",
19
+ "astro": "./src/index.ts",
20
+ "default": "./src/index.ts"
21
+ },
22
+ "./styles/tailwind-sources.css": "./src/styles/tailwind-sources.css"
23
+ },
24
+ "dependencies": {
25
+ "@github/clipboard-copy-element": "^1.3.0",
26
+ "@github/tab-container-element": "^4.8.2",
27
+ "medium-zoom": "^1.1.0",
28
+ "@publier/native": "0.10.1"
29
+ },
30
+ "peerDependencies": {
31
+ "astro": "^6.0.0 || >=7.0.0-alpha.0",
32
+ "tailwindcss": ">=4.0.0-beta.1"
33
+ },
34
+ "devDependencies": {
35
+ "@playwright/test": "^1.60.0",
36
+ "@types/node": "^22",
37
+ "astro": "7.0.0-beta.3",
38
+ "tailwindcss": "^4",
39
+ "tsx": "^4.21.0",
40
+ "typescript": "^6.0.3"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "https://github.com/Publier/releases.git",
48
+ "directory": "packages/primitives"
49
+ },
50
+ "scripts": {
51
+ "check-types": "tsc --noEmit",
52
+ "test": "echo \"@publier/primitives: covered by root vitest workspace\" && exit 0",
53
+ "test:browser": "playwright test",
54
+ "test:browser:install": "playwright install chromium"
55
+ }
56
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Ambient type for `.astro` component imports.
3
+ *
4
+ * `@publier/primitives` type-checks its own source via `tsc --noEmit` outside
5
+ * Astro's build pipeline. This declaration lets `index.ts` re-export sibling
6
+ * `.astro` default exports without TypeScript erroring. At runtime, the
7
+ * consumer's Astro build provides the real `ComponentFactory`.
8
+ *
9
+ * Mirrors `packages/ui/src/astro-modules.d.ts`.
10
+ */
11
+ declare module '*.astro' {
12
+ // biome-ignore lint/suspicious/noExplicitAny: library-boundary escape hatch.
13
+ const Component: (_props: any) => any;
14
+ export default Component;
15
+ }
@@ -0,0 +1,15 @@
1
+ ---
2
+ import { primitivesRenderAccordionItem } from '@publier/native';
3
+
4
+ interface Props {
5
+ title: string;
6
+ open?: boolean;
7
+ name?: string;
8
+ }
9
+
10
+ const { title, open = false, name } = Astro.props;
11
+ const slotHtml = await Astro.slots.render('default');
12
+ const html = primitivesRenderAccordionItem(title, open, name ?? null, slotHtml);
13
+ ---
14
+
15
+ <Fragment set:html={html} />
@@ -0,0 +1,13 @@
1
+ ---
2
+ import { primitivesRenderAccordion } from '@publier/native';
3
+
4
+ interface Props {
5
+ class?: string;
6
+ }
7
+
8
+ const { class: className } = Astro.props;
9
+ const slotHtml = await Astro.slots.render('default');
10
+ const html = primitivesRenderAccordion(className ?? null, slotHtml);
11
+ ---
12
+
13
+ <Fragment set:html={html} />
@@ -0,0 +1,15 @@
1
+ ---
2
+ import {
3
+ primitivesColorSwatchScript,
4
+ primitivesColorSwatchStyle,
5
+ primitivesRenderColorSwatch,
6
+ } from '@publier/native';
7
+ import type { ColorSwatchProps } from './types.ts';
8
+
9
+ const props = Astro.props as ColorSwatchProps;
10
+ const html = primitivesRenderColorSwatch(JSON.stringify(props));
11
+ ---
12
+
13
+ <Fragment set:html={html} />
14
+ <style is:global set:html={primitivesColorSwatchStyle()}></style>
15
+ <script is:inline set:html={primitivesColorSwatchScript()}></script>
@@ -0,0 +1,21 @@
1
+ ---
2
+ import {
3
+ primitivesCopyButtonScript,
4
+ primitivesCopyButtonStyle,
5
+ primitivesRenderCopyButton,
6
+ } from '@publier/native';
7
+ import type { CopyButtonProps } from './types.ts';
8
+
9
+ const { selector, text, floating = false, class: className, label } = Astro.props as CopyButtonProps;
10
+ const html = primitivesRenderCopyButton(
11
+ selector ?? null,
12
+ text ?? null,
13
+ floating,
14
+ className ?? null,
15
+ label ?? null,
16
+ );
17
+ ---
18
+
19
+ <Fragment set:html={html} />
20
+ <style is:global set:html={primitivesCopyButtonStyle()}></style>
21
+ <script is:inline set:html={primitivesCopyButtonScript()}></script>
@@ -0,0 +1,16 @@
1
+ ---
2
+ import { primitivesImageZoomScript, primitivesRenderImageZoom } from '@publier/native';
3
+ import type { ImageZoomProps } from './types.ts';
4
+
5
+ const { src, alt, width, height, class: customClass } = Astro.props as ImageZoomProps;
6
+ const html = primitivesRenderImageZoom(
7
+ src,
8
+ alt,
9
+ width ?? null,
10
+ height ?? null,
11
+ customClass ?? null,
12
+ );
13
+ ---
14
+
15
+ <Fragment set:html={html} />
16
+ <script is:inline set:html={primitivesImageZoomScript()}></script>
@@ -0,0 +1,13 @@
1
+ ---
2
+ import { primitivesRenderTabPanel } from '@publier/native';
3
+
4
+ interface Props {
5
+ class?: string;
6
+ }
7
+
8
+ const { class: className } = Astro.props;
9
+ const slotHtml = await Astro.slots.render('default');
10
+ const html = primitivesRenderTabPanel(className ?? null, slotHtml);
11
+ ---
12
+
13
+ <Fragment set:html={html} />
@@ -0,0 +1,19 @@
1
+ ---
2
+ import { primitivesRenderTabs, primitivesTabsScript } from '@publier/native';
3
+ import type { TabsProps } from './types.ts';
4
+
5
+ const { labels, defaultIndex = 0, variant, class: className } = Astro.props as TabsProps;
6
+ const id = Math.random().toString(36).slice(2, 10);
7
+ const slotHtml = await Astro.slots.render('default');
8
+ const html = primitivesRenderTabs(
9
+ labels,
10
+ defaultIndex,
11
+ variant ?? null,
12
+ className ?? null,
13
+ slotHtml,
14
+ id,
15
+ );
16
+ ---
17
+
18
+ <Fragment set:html={html} />
19
+ <script is:inline set:html={primitivesTabsScript()}></script>
@@ -0,0 +1,16 @@
1
+ ---
2
+ import { primitivesRenderTooltip } from '@publier/native';
3
+
4
+ interface Props {
5
+ tip: string;
6
+ position?: 'top' | 'bottom' | 'left' | 'right';
7
+ color?: 'primary' | 'accent' | 'info' | 'success' | 'warning' | 'error';
8
+ open?: boolean;
9
+ class?: string;
10
+ }
11
+ const { tip, position = 'top', color, open = false, class: cls } = Astro.props;
12
+ const slotHtml = await Astro.slots.render('default');
13
+ const html = primitivesRenderTooltip(tip, position, color ?? null, open, cls ?? null, slotHtml);
14
+ ---
15
+
16
+ <Fragment set:html={html} />
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Public prop types for the Astro-rendered primitives.
3
+ *
4
+ * These live in a separate `.ts` file (rather than inline in each `.astro`'s
5
+ * frontmatter) so the barrel `index.ts` can re-export them without relying
6
+ * on TypeScript's `.astro` module inference — only provided in Astro build
7
+ * contexts, not during our plain `tsc --noEmit` check.
8
+ *
9
+ * The inline `interface Props` in each `.astro` must stay in sync with these.
10
+ */
11
+
12
+ // ---------------------------------------------------------------------------
13
+ // Accordion
14
+ // ---------------------------------------------------------------------------
15
+
16
+ export interface AccordionProps {
17
+ /**
18
+ * When set, child items share this radio-group name so only one can be open
19
+ * at a time. Omit to let items toggle independently (checkbox mode).
20
+ */
21
+ name?: string;
22
+ }
23
+
24
+ export interface AccordionItemProps {
25
+ /** Heading text rendered on the disclosure trigger. */
26
+ title: string;
27
+ /** Render the panel open on first paint. Defaults to `false`. */
28
+ open?: boolean;
29
+ /**
30
+ * When set, the item renders as a radio input in the named group. Usually
31
+ * provided implicitly by wrapping `<Accordion name="…">`.
32
+ */
33
+ name?: string;
34
+ }
35
+
36
+ // ---------------------------------------------------------------------------
37
+ // Tooltip
38
+ // ---------------------------------------------------------------------------
39
+
40
+ export interface TooltipProps {
41
+ /** Body text shown inside the tooltip bubble. */
42
+ tip: string;
43
+ /**
44
+ * Preferred side of the trigger for the bubble. Defaults to `top`.
45
+ * Maps to daisyUI's `tooltip-top|bottom|left|right` modifiers.
46
+ */
47
+ position?: 'top' | 'bottom' | 'left' | 'right';
48
+ /**
49
+ * Optional daisyUI color variant (`primary`, `accent`, `info`, `success`,
50
+ * `warning`, `error`). Omit for the default surface.
51
+ */
52
+ color?: 'primary' | 'accent' | 'info' | 'success' | 'warning' | 'error';
53
+ /** Render open regardless of hover/focus state (useful for docs). */
54
+ open?: boolean;
55
+ }
56
+
57
+ // ---------------------------------------------------------------------------
58
+ // Tabs
59
+ // ---------------------------------------------------------------------------
60
+
61
+ export interface TabsProps {
62
+ /**
63
+ * Labels for each tab in order. The number of labels MUST equal the number
64
+ * of `<TabPanel>` children; the component renders one `<button role="tab">`
65
+ * per label with matching `aria-controls`.
66
+ */
67
+ labels: string[];
68
+ /** Zero-based index of the tab shown on first paint. Defaults to `0`. */
69
+ defaultIndex?: number;
70
+ /**
71
+ * Visual variant of the tab list. Maps to daisyUI `tabs-box|tabs-border|
72
+ * tabs-lift`. Omit for the default underline style.
73
+ */
74
+ variant?: 'box' | 'border' | 'lift';
75
+ /** Additional CSS classes on the outer container. */
76
+ class?: string;
77
+ }
78
+
79
+ export interface TabPanelProps {
80
+ /** Additional CSS classes on the panel. */
81
+ class?: string;
82
+ }
83
+
84
+ // ---------------------------------------------------------------------------
85
+ // CopyButton
86
+ // ---------------------------------------------------------------------------
87
+
88
+ export interface CopyButtonProps {
89
+ /**
90
+ * Element id (no `#` prefix) passed to `<clipboard-copy for>`; the element's
91
+ * `textContent` or `[value]` is copied. Upstream resolves via `getElementById`,
92
+ * so a CSS selector will not match. Takes precedence over `text` when both
93
+ * are set.
94
+ */
95
+ selector?: string;
96
+ /** Literal text to copy (passed to `<clipboard-copy value>`). */
97
+ text?: string;
98
+ /** Absolutely positions the button over its container (code blocks, etc.). */
99
+ floating?: boolean;
100
+ /**
101
+ * daisyUI button variant. Defaults to `btn-ghost btn-sm`; override for
102
+ * inline placement. Pass the full class string (e.g. `'btn btn-primary'`).
103
+ */
104
+ class?: string;
105
+ /** Accessible label. Defaults to `'Copy to clipboard'`. */
106
+ label?: string;
107
+ }
108
+
109
+ // ---------------------------------------------------------------------------
110
+ // ImageZoom
111
+ // ---------------------------------------------------------------------------
112
+
113
+ export interface ImageZoomProps {
114
+ /** Image source URL. */
115
+ src: string;
116
+ /** Alt text for accessibility. */
117
+ alt: string;
118
+ /** Optional intrinsic width. */
119
+ width?: number;
120
+ /** Optional intrinsic height. */
121
+ height?: number;
122
+ /** Additional CSS class appended to `publier-image-zoom`. */
123
+ class?: string;
124
+ }
125
+
126
+ // ---------------------------------------------------------------------------
127
+ // ColorSwatch
128
+ // ---------------------------------------------------------------------------
129
+
130
+ /** A single color entry in the {@link ColorSwatchProps} grid. */
131
+ export interface ColorEntry {
132
+ name: string;
133
+ value: string;
134
+ /** Force dark label text. Auto-detected from luminance when omitted. */
135
+ textDark?: boolean;
136
+ }
137
+
138
+ export interface ColorSwatchProps {
139
+ colors: ColorEntry[];
140
+ columns?: 2 | 3 | 4 | 5 | 6;
141
+ size?: 'sm' | 'md' | 'lg';
142
+ }
143
+
144
+ // ---------------------------------------------------------------------------
145
+ // ViewAnimation
146
+ // ---------------------------------------------------------------------------
147
+
148
+ export interface ViewAnimationProps {
149
+ /** Additional CSS classes appended to the animated container. */
150
+ class?: string;
151
+ /** Transition delay in ms (capped at 200). Useful for staggered lists. */
152
+ delay?: number;
153
+ /** When true (default), the animation runs only on first intersection. */
154
+ once?: boolean;
155
+ }
@@ -0,0 +1,16 @@
1
+ ---
2
+ import {
3
+ primitivesRenderViewAnimation,
4
+ primitivesViewAnimationScript,
5
+ primitivesViewAnimationStyle,
6
+ } from '@publier/native';
7
+ import type { ViewAnimationProps } from './types.ts';
8
+
9
+ const { class: className, delay = 0, once = true } = Astro.props as ViewAnimationProps;
10
+ const slotHtml = await Astro.slots.render('default');
11
+ const html = primitivesRenderViewAnimation(slotHtml, className ?? null, delay, once);
12
+ ---
13
+
14
+ <Fragment set:html={html} />
15
+ <style is:global set:html={primitivesViewAnimationStyle()}></style>
16
+ <script is:inline set:html={primitivesViewAnimationScript()}></script>
package/src/index.ts ADDED
@@ -0,0 +1,23 @@
1
+
2
+
3
+ export { default as Accordion } from './components/accordion.astro';
4
+ export { default as AccordionItem } from './components/accordion-item.astro';
5
+ export { default as ColorSwatch } from './components/color-swatch.astro';
6
+ export { default as CopyButton } from './components/copy-button.astro';
7
+ export { default as ImageZoom } from './components/image-zoom.astro';
8
+ export { default as TabPanel } from './components/tab-panel.astro';
9
+ export { default as Tabs } from './components/tabs.astro';
10
+ export { default as Tooltip } from './components/tooltip.astro';
11
+ export type {
12
+ AccordionItemProps,
13
+ AccordionProps,
14
+ ColorEntry,
15
+ ColorSwatchProps,
16
+ CopyButtonProps,
17
+ ImageZoomProps,
18
+ TabPanelProps,
19
+ TabsProps,
20
+ TooltipProps,
21
+ ViewAnimationProps,
22
+ } from './components/types.ts';
23
+ export { default as ViewAnimation } from './components/view-animation.astro';
@@ -0,0 +1,8 @@
1
+ /* Tailwind v4 source scan registration for @publier/primitives.
2
+ *
3
+ * Imported by `@publier/ui/src/css/base.css`. Tailwind v4 resolves the @source
4
+ * pattern below relative to THIS file's on-disk location — which works under
5
+ * pnpm where sibling packages live in separate `.pnpm/<pkg>/` directories.
6
+ * See `@publier/shell/styles/tailwind-sources.css` for the full rationale. */
7
+
8
+ @source "../components/**/*.astro";