@stacksjs/ui 0.70.258 → 0.70.260
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/disclosure.js +1 -1
- package/dist/components/menu.js +1 -1
- package/dist/components/modal.js +1 -37
- package/dist/components/popover.js +1 -1
- package/dist/components/radio-group.js +1 -5
- package/dist/components/select.js +1 -6
- package/dist/components/tabs.js +1 -1
- package/dist/components/toggle.js +1 -1
- package/dist/components/transition.js +1 -1
- package/dist/components.js +1 -10
- package/dist/fonts.js +7 -46
- package/dist/index.js +1 -14
- package/dist/pagination.js +1 -40
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
package/dist/components/menu.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
package/dist/components/modal.js
CHANGED
|
@@ -1,37 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
Dialog,
|
|
3
|
-
DialogDescription,
|
|
4
|
-
DialogPanel,
|
|
5
|
-
DialogTitle
|
|
6
|
-
} from "@stacksjs/components";
|
|
7
|
-
export function createModal(initialValue) {
|
|
8
|
-
let snapshot = { open: !1, value: initialValue };
|
|
9
|
-
const listeners = new Set;
|
|
10
|
-
function publish(next) {
|
|
11
|
-
snapshot = next;
|
|
12
|
-
for (const listener of listeners)
|
|
13
|
-
listener(snapshot);
|
|
14
|
-
}
|
|
15
|
-
return {
|
|
16
|
-
get snapshot() {
|
|
17
|
-
return snapshot;
|
|
18
|
-
},
|
|
19
|
-
open(value = snapshot.value) {
|
|
20
|
-
publish({ open: !0, value });
|
|
21
|
-
},
|
|
22
|
-
close() {
|
|
23
|
-
publish({ ...snapshot, open: !1 });
|
|
24
|
-
},
|
|
25
|
-
toggle(value = snapshot.value) {
|
|
26
|
-
publish({ open: !snapshot.open, value });
|
|
27
|
-
},
|
|
28
|
-
subscribe(listener) {
|
|
29
|
-
listeners.add(listener);
|
|
30
|
-
listener(snapshot);
|
|
31
|
-
return () => listeners.delete(listener);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export function createAlert(initialValue) {
|
|
36
|
-
return createModal(initialValue);
|
|
37
|
-
}
|
|
1
|
+
export{Dialog,DialogDescription,DialogPanel,DialogTitle}from"@stacksjs/components";export function createModal(initialValue){let snapshot={open:!1,value:initialValue};const listeners=new Set;function publish(next){snapshot=next;for(const listener of listeners)listener(snapshot)}return{get snapshot(){return snapshot},open(value=snapshot.value){publish({open:!0,value})},close(){publish({...snapshot,open:!1})},toggle(value=snapshot.value){publish({open:!snapshot.open,value})},subscribe(listener){listeners.add(listener);listener(snapshot);return()=>listeners.delete(listener)}}}export function createAlert(initialValue){return createModal(initialValue)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{Popover,PopoverButton,PopoverPanel}from"@stacksjs/components";
|
package/dist/components/tabs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{TabPanel,Tabs}from"@stacksjs/components";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{Switch}from"@stacksjs/components";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{Transition}from"@stacksjs/components";
|
package/dist/components.js
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
export
|
|
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";
|
|
1
|
+
export*from"./components/autocomplete";export*from"./components/disclosure";export*from"./components/menu";export*from"./components/modal";export*from"./components/popover";export*from"./components/radio-group";export*from"./components/select";export*from"./components/tabs";export*from"./components/toggle";export*from"./components/transition";
|
package/dist/fonts.js
CHANGED
|
@@ -1,53 +1,14 @@
|
|
|
1
|
-
const FORMAT_LABEL = {
|
|
2
|
-
|
|
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 {
|
|
1
|
+
const FORMAT_LABEL={woff2:"woff2",woff:"woff",truetype:"truetype",opentype:"opentype"},FORMAT_MIME={woff2:"font/woff2",woff:"font/woff",truetype:"font/ttf",opentype:"font/otf"};export function renderFontPreloads(fonts=[]){return fonts.filter((font)=>font.preload!==!1).map((font)=>{const fmt=font.format??"woff2",type=FORMAT_MIME[fmt];return`<link rel="preload" href="${escapeAttr(font.src)}" as="font" type="${type}" crossorigin>`}).join(`
|
|
2
|
+
`)}export function renderFontFaceCss(fonts=[]){return fonts.map((font)=>{const fmt=font.format??"woff2",fmtLabel=FORMAT_LABEL[fmt],weight=font.weight??"normal",style=font.style??"normal",display=font.display??"swap",ur=font.unicodeRange;return`@font-face {
|
|
23
3
|
font-family: '${escapeFamily(font.family)}';
|
|
24
4
|
src: url('${escapeUrl(font.src)}') format('${fmtLabel}');
|
|
25
5
|
font-weight: ${weight};
|
|
26
6
|
font-style: ${style};
|
|
27
|
-
font-display: ${display};${ur
|
|
28
|
-
unicode-range: ${ur}
|
|
29
|
-
}
|
|
30
|
-
}).join(`
|
|
7
|
+
font-display: ${display};${ur?`
|
|
8
|
+
unicode-range: ${ur};`:""}
|
|
9
|
+
}`}).join(`
|
|
31
10
|
|
|
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}
|
|
11
|
+
`)}export function renderFontHead(fonts=[]){if(fonts.length===0)return"";const preloads=renderFontPreloads(fonts),faces=renderFontFaceCss(fonts);return`${preloads}
|
|
39
12
|
<style>
|
|
40
13
|
${faces}
|
|
41
|
-
</style
|
|
42
|
-
}
|
|
43
|
-
function escapeAttr(s) {
|
|
44
|
-
return String(s).replace(/[&<>"']/g, (c) => {
|
|
45
|
-
return { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[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
|
-
}
|
|
14
|
+
</style>`}function escapeAttr(s){return String(s).replace(/[&<>"']/g,(c)=>{return{"&":"&","<":"<",">":">",'"':""","'":"'"}[c]})}function escapeUrl(s){return String(s).replace(/['"`()<>{};\\\r\n\t*]/g,"")}function escapeFamily(s){return String(s).replace(/[^A-Z0-9 \-_.]/gi,"")}
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
import
|
|
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";
|
|
1
|
+
import{ui}from"@stacksjs/config";import*as CssEngine from"@cwcss/crosswind";export{CssEngine,ui};export{renderFontFaceCss,renderFontHead,renderFontPreloads}from"./fonts";export{buildPageSequence,paginatorVariant,urlForPage}from"./pagination";
|
package/dist/pagination.js
CHANGED
|
@@ -1,40 +1 @@
|
|
|
1
|
-
export function buildPageSequence(current,
|
|
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
|
-
}
|
|
1
|
+
export function buildPageSequence(current,last,window=2){if(last<=1)return[];const out=[],lo=Math.max(2,current-window),hi=Math.min(last-1,current+window);out.push(1);if(lo===3)out.push(2);else if(lo>3)out.push("\u2026");for(let i=lo;i<=hi;i++)out.push(i);if(hi===last-2)out.push(last-1);else if(hi<last-2)out.push("\u2026");if(last>1)out.push(last);return out}export function urlForPage(view,page){const template=view.next_page_url||view.prev_page_url||view.first_page_url||view.last_page_url;if(template){if(/[?&]page=\d+/.test(template))return template.replace(/([?&])page=\d+/,`$1page=${page}`);return`${template}${template.includes("?")?"&":"?"}page=${page}`}return`?page=${page}`}export function paginatorVariant(p){if(p===null||typeof p!=="object")return"unknown";const v=p;if("next_cursor"in v)return"cursor";if("total"in v&&"last_page"in v)return"full";if("current_page"in v&&"per_page"in v)return"simple";return"unknown"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.70.
|
|
4
|
+
"version": "0.70.260",
|
|
5
5
|
"description": "The Stacks UI engine.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": [
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"@stacksjs/components": "^0.2.148"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@stacksjs/build": "0.70.
|
|
63
|
-
"@stacksjs/config": "0.70.
|
|
62
|
+
"@stacksjs/build": "0.70.260",
|
|
63
|
+
"@stacksjs/config": "0.70.260",
|
|
64
64
|
"better-dx": "^0.2.17",
|
|
65
|
-
"@stacksjs/router": "0.70.
|
|
65
|
+
"@stacksjs/router": "0.70.260"
|
|
66
66
|
}
|
|
67
67
|
}
|