@stacksjs/ui 0.70.57 → 0.70.58

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.
@@ -0,0 +1 @@
1
+
File without changes
@@ -0,0 +1,5 @@
1
+ export {
2
+ Disclosure,
3
+ DisclosureButton,
4
+ DisclosurePanel,
5
+ } from '@stacksjs/stx';
@@ -0,0 +1,5 @@
1
+ export {
2
+ Disclosure,
3
+ DisclosureButton,
4
+ DisclosurePanel
5
+ } from "@stacksjs/stx";
@@ -0,0 +1 @@
1
+ export { Menu, MenuButton, MenuItem, MenuItems } from '@stacksjs/stx';
@@ -0,0 +1 @@
1
+ export { Menu, MenuButton, MenuItem, MenuItems } from "@stacksjs/stx";
@@ -0,0 +1,6 @@
1
+ export {
2
+ Dialog,
3
+ DialogDescription,
4
+ DialogPanel,
5
+ DialogTitle,
6
+ } from '@stacksjs/stx';
@@ -0,0 +1,6 @@
1
+ export {
2
+ Dialog,
3
+ DialogDescription,
4
+ DialogPanel,
5
+ DialogTitle
6
+ } from "@stacksjs/stx";
@@ -0,0 +1 @@
1
+ export { Popover, PopoverButton, PopoverPanel } from '@stacksjs/stx';
@@ -0,0 +1 @@
1
+ export { Popover, PopoverButton, PopoverPanel } from "@stacksjs/stx";
@@ -0,0 +1,5 @@
1
+ export {
2
+ RadioGroup,
3
+ RadioGroupLabel,
4
+ RadioGroupOption,
5
+ } from '@stacksjs/stx';
@@ -0,0 +1,5 @@
1
+ export {
2
+ RadioGroup,
3
+ RadioGroupLabel,
4
+ RadioGroupOption
5
+ } from "@stacksjs/stx";
@@ -0,0 +1,6 @@
1
+ export {
2
+ Combobox,
3
+ ComboboxInput,
4
+ ComboboxOption,
5
+ ComboboxOptions,
6
+ } from '@stacksjs/stx';
@@ -0,0 +1,6 @@
1
+ export {
2
+ Combobox,
3
+ ComboboxInput,
4
+ ComboboxOption,
5
+ ComboboxOptions
6
+ } from "@stacksjs/stx";
@@ -0,0 +1 @@
1
+ export { Tab, TabGroup, TabList, TabPanel, TabPanels } from '@stacksjs/stx';
@@ -0,0 +1 @@
1
+ export { Tab, TabGroup, TabList, TabPanel, TabPanels } from "@stacksjs/stx";
@@ -0,0 +1 @@
1
+ export { Switch } from '@stacksjs/stx';
@@ -0,0 +1 @@
1
+ export { Switch } from "@stacksjs/stx";
@@ -0,0 +1 @@
1
+ export { TransitionChild, TransitionRoot } from '@stacksjs/stx';
@@ -0,0 +1 @@
1
+ export { TransitionChild, TransitionRoot } from "@stacksjs/stx";
@@ -0,0 +1,10 @@
1
+ export * from './components/autocomplete';
2
+ export * from './components/disclosure';
3
+ export * from './components/menu';
4
+ export * from './components/modal';
5
+ export * from './components/popover';
6
+ export * from './components/radio-group';
7
+ export * from './components/select';
8
+ export * from './components/tabs';
9
+ export * from './components/toggle';
10
+ export * from './components/transition';
@@ -0,0 +1,10 @@
1
+ export * from "./components/autocomplete";
2
+ export * from "./components/disclosure";
3
+ export * from "./components/menu";
4
+ export * from "./components/modal";
5
+ export * from "./components/popover";
6
+ export * from "./components/radio-group";
7
+ export * from "./components/select";
8
+ export * from "./components/tabs";
9
+ export * from "./components/toggle";
10
+ export * from "./components/transition";
package/dist/fonts.js ADDED
@@ -0,0 +1,53 @@
1
+ const FORMAT_LABEL = {
2
+ woff2: "woff2",
3
+ woff: "woff",
4
+ truetype: "truetype",
5
+ opentype: "opentype"
6
+ }, FORMAT_MIME = {
7
+ woff2: "font/woff2",
8
+ woff: "font/woff",
9
+ truetype: "font/ttf",
10
+ opentype: "font/otf"
11
+ };
12
+ export function renderFontPreloads(fonts = []) {
13
+ return fonts.filter((font) => font.preload !== !1).map((font) => {
14
+ const fmt = font.format ?? "woff2", type = FORMAT_MIME[fmt];
15
+ return `<link rel="preload" href="${escapeAttr(font.src)}" as="font" type="${type}" crossorigin>`;
16
+ }).join(`
17
+ `);
18
+ }
19
+ export function renderFontFaceCss(fonts = []) {
20
+ return fonts.map((font) => {
21
+ const fmt = font.format ?? "woff2", fmtLabel = FORMAT_LABEL[fmt], weight = font.weight ?? "normal", style = font.style ?? "normal", display = font.display ?? "swap", ur = font.unicodeRange;
22
+ return `@font-face {
23
+ font-family: '${escapeFamily(font.family)}';
24
+ src: url('${escapeUrl(font.src)}') format('${fmtLabel}');
25
+ font-weight: ${weight};
26
+ font-style: ${style};
27
+ font-display: ${display};${ur ? `
28
+ unicode-range: ${ur};` : ""}
29
+ }`;
30
+ }).join(`
31
+
32
+ `);
33
+ }
34
+ export function renderFontHead(fonts = []) {
35
+ if (fonts.length === 0)
36
+ return "";
37
+ const preloads = renderFontPreloads(fonts), faces = renderFontFaceCss(fonts);
38
+ return `${preloads}
39
+ <style>
40
+ ${faces}
41
+ </style>`;
42
+ }
43
+ function escapeAttr(s) {
44
+ return String(s).replace(/[&<>"']/g, (c) => {
45
+ return { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[c];
46
+ });
47
+ }
48
+ function escapeUrl(s) {
49
+ return String(s).replace(/['"`()<>{};\\\r\n\t*]/g, "");
50
+ }
51
+ function escapeFamily(s) {
52
+ return String(s).replace(/[^A-Z0-9 \-_.]/gi, "");
53
+ }
package/dist/index.js CHANGED
@@ -1,2 +1,14 @@
1
- // @bun
2
- export{H as urlForPage,h as ui,B as renderFontPreloads,A as renderFontHead,z as renderFontFaceCss,G as paginatorVariant,F as buildPageSequence,q as CssEngine};
1
+ import { ui } from "@stacksjs/config";
2
+ import * as CssEngine from "@cwcss/crosswind";
3
+
4
+ export { CssEngine, ui };
5
+ export {
6
+ renderFontFaceCss,
7
+ renderFontHead,
8
+ renderFontPreloads
9
+ } from "./fonts";
10
+ export {
11
+ buildPageSequence,
12
+ paginatorVariant,
13
+ urlForPage
14
+ } from "./pagination";
@@ -0,0 +1,40 @@
1
+ export function buildPageSequence(current, last, window = 2) {
2
+ if (last <= 1)
3
+ return [];
4
+ const out = [], lo = Math.max(2, current - window), hi = Math.min(last - 1, current + window);
5
+ out.push(1);
6
+ if (lo === 3)
7
+ out.push(2);
8
+ else if (lo > 3)
9
+ out.push("\u2026");
10
+ for (let i = lo;i <= hi; i++)
11
+ out.push(i);
12
+ if (hi === last - 2)
13
+ out.push(last - 1);
14
+ else if (hi < last - 2)
15
+ out.push("\u2026");
16
+ if (last > 1)
17
+ out.push(last);
18
+ return out;
19
+ }
20
+ export function urlForPage(view, page) {
21
+ const template = view.next_page_url || view.prev_page_url || view.first_page_url || view.last_page_url;
22
+ if (template) {
23
+ if (/[?&]page=\d+/.test(template))
24
+ return template.replace(/([?&])page=\d+/, `$1page=${page}`);
25
+ return `${template}${template.includes("?") ? "&" : "?"}page=${page}`;
26
+ }
27
+ return `?page=${page}`;
28
+ }
29
+ export function paginatorVariant(p) {
30
+ if (p === null || typeof p !== "object")
31
+ return "unknown";
32
+ const v = p;
33
+ if ("next_cursor" in v)
34
+ return "cursor";
35
+ if ("total" in v && "last_page" in v)
36
+ return "full";
37
+ if ("current_page" in v && "per_page" in v)
38
+ return "simple";
39
+ return "unknown";
40
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/ui",
3
3
  "type": "module",
4
- "version": "0.70.57",
4
+ "version": "0.70.58",
5
5
  "description": "The Stacks UI engine.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": [
@@ -59,9 +59,9 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "@stacksjs/build": "workspace:*",
62
- "@stacksjs/config": "0.70.57",
62
+ "@stacksjs/config": "0.70.58",
63
63
  "better-dx": "^0.2.12",
64
- "@stacksjs/router": "0.70.57",
64
+ "@stacksjs/router": "0.70.58",
65
65
  "@stacksjs/stx": "^0.2.82"
66
66
  }
67
67
  }