@stacksjs/ui 0.75.515 → 0.75.518
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/modal.js +1 -1
- package/dist/fonts.js +3 -3
- package/dist/pagination.js +1 -1
- package/package.json +4 -4
package/dist/components/modal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{Dialog,DialogDescription,DialogPanel,DialogTitle}from"@stacksjs/components";export function createModal(initialValue){let snapshot={open
|
|
1
|
+
export{Dialog,DialogDescription,DialogPanel,DialogTitle}from"@stacksjs/components";export function createModal(initialValue){let snapshot={open:false,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:true,value})},close(){publish({...snapshot,open:false})},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)}
|
package/dist/fonts.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const FORMAT_LABEL={woff2:"woff2",woff:"woff",truetype:"truetype",opentype:"opentype"}
|
|
2
|
-
`)}export function renderFontFaceCss(fonts=[]){return fonts.map((font)=>{const fmt=font.format??"woff2"
|
|
1
|
+
const FORMAT_LABEL={woff2:"woff2",woff:"woff",truetype:"truetype",opentype:"opentype"};const FORMAT_MIME={woff2:"font/woff2",woff:"font/woff",truetype:"font/ttf",opentype:"font/otf"};export function renderFontPreloads(fonts=[]){return fonts.filter((font)=>font.preload!==false).map((font)=>{const fmt=font.format??"woff2";const 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";const fmtLabel=FORMAT_LABEL[fmt];const weight=font.weight??"normal";const style=font.style??"normal";const display=font.display??"swap";const ur=font.unicodeRange;return`@font-face {
|
|
3
3
|
font-family: '${escapeFamily(font.family)}';
|
|
4
4
|
src: url('${escapeUrl(font.src)}') format('${fmtLabel}');
|
|
5
5
|
font-weight: ${weight};
|
|
@@ -8,7 +8,7 @@ const FORMAT_LABEL={woff2:"woff2",woff:"woff",truetype:"truetype",opentype:"open
|
|
|
8
8
|
unicode-range: ${ur};`:""}
|
|
9
9
|
}`}).join(`
|
|
10
10
|
|
|
11
|
-
`)}export function renderFontHead(fonts=[]){if(fonts.length===0)return"";const preloads=renderFontPreloads(fonts)
|
|
11
|
+
`)}export function renderFontHead(fonts=[]){if(fonts.length===0)return"";const preloads=renderFontPreloads(fonts);const faces=renderFontFaceCss(fonts);return`${preloads}
|
|
12
12
|
<style>
|
|
13
13
|
${faces}
|
|
14
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/pagination.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function buildPageSequence(current,last,window=2){if(last<=1)return[];const out=[]
|
|
1
|
+
export function buildPageSequence(current,last,window=2){if(last<=1)return[];const out=[];const lo=Math.max(2,current-window);const hi=Math.min(last-1,current+window);out.push(1);if(lo===3)out.push(2);else if(lo>3)out.push("…");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("…");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.75.
|
|
4
|
+
"version": "0.75.518",
|
|
5
5
|
"description": "The Stacks UI engine.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": [
|
|
@@ -56,11 +56,11 @@
|
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@stacksjs/ts-css": "^0.3.24",
|
|
58
58
|
"@stacksjs/components": "0.2.807",
|
|
59
|
-
"@stacksjs/config": "0.75.
|
|
59
|
+
"@stacksjs/config": "0.75.518"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@stacksjs/build": "0.75.
|
|
63
|
-
"@stacksjs/router": "0.75.
|
|
62
|
+
"@stacksjs/build": "0.75.518",
|
|
63
|
+
"@stacksjs/router": "0.75.518",
|
|
64
64
|
"better-dx": "^0.2.24"
|
|
65
65
|
}
|
|
66
66
|
}
|