mypgs 1.4.0 → 1.5.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.
- package/README.md +26 -1
- package/assets/javascript/index.js +3 -1
- package/assets/scss/index.scss +3 -3
- package/package.json +12 -2
- package/plugins/vite-plugin-pgs.d.ts +3 -0
- package/plugins/vite-plugin-pgs.js +19 -0
- package/react.d.ts +11 -0
- package/react.js +1 -0
- package/templates/html/demo.js +6 -13
- package/assets/javascript/pgs.d.ts +0 -70
- /package/assets/javascript/{patterns → layout}/_header.js +0 -0
- /package/assets/scss/{patterns → layout}/_footer.scss +0 -0
- /package/assets/scss/{patterns → layout}/_header.scss +0 -0
- /package/templates/html/{patterns → layout}/footer.html +0 -0
- /package/templates/html/{patterns → layout}/header.html +0 -0
package/README.md
CHANGED
|
@@ -39,6 +39,21 @@ import { pgs } from "mypgs";
|
|
|
39
39
|
import "mypgs/style.css";
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
+
In progetti React/TSX con Vite, abilita i tipi JSX e il plugin che converte `pgsHtml` in `pgs`:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import "mypgs/react";
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import react from "@vitejs/plugin-react";
|
|
50
|
+
import pgsVite from "mypgs/vite-plugin-pgs";
|
|
51
|
+
|
|
52
|
+
export default {
|
|
53
|
+
plugins: [pgsVite(), react()],
|
|
54
|
+
};
|
|
55
|
+
```
|
|
56
|
+
|
|
42
57
|
Markup minimo consigliato:
|
|
43
58
|
|
|
44
59
|
```html
|
|
@@ -305,7 +320,17 @@ Il pacchetto espone:
|
|
|
305
320
|
"default": "./dist/javascript/index.js"
|
|
306
321
|
},
|
|
307
322
|
"./style.css": "./dist/css/index.css",
|
|
308
|
-
"./style.min.css": "./dist/css/index.min.css"
|
|
323
|
+
"./style.min.css": "./dist/css/index.min.css",
|
|
324
|
+
"./react": {
|
|
325
|
+
"types": "./react.d.ts",
|
|
326
|
+
"import": "./react.js",
|
|
327
|
+
"default": "./react.js"
|
|
328
|
+
},
|
|
329
|
+
"./vite-plugin-pgs": {
|
|
330
|
+
"types": "./plugins/vite-plugin-pgs.d.ts",
|
|
331
|
+
"import": "./plugins/vite-plugin-pgs.js",
|
|
332
|
+
"default": "./plugins/vite-plugin-pgs.js"
|
|
333
|
+
}
|
|
309
334
|
}
|
|
310
335
|
```
|
|
311
336
|
|
package/assets/scss/index.scss
CHANGED
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
@include meta.load-css("layout/grid");
|
|
24
24
|
@include meta.load-css("layout/pageShell");
|
|
25
25
|
@include meta.load-css("layout/gap");
|
|
26
|
+
@include meta.load-css("layout/header");
|
|
27
|
+
@include meta.load-css("layout/footer");
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
/*
|
|
@@ -56,7 +58,5 @@
|
|
|
56
58
|
|--------------------------------------------------------------------------
|
|
57
59
|
*/
|
|
58
60
|
[pgs~=initP] {
|
|
59
|
-
@include meta.load-css("patterns/header");
|
|
60
|
-
@include meta.load-css("patterns/footer");
|
|
61
61
|
@include meta.load-css("patterns/cookieConsent");
|
|
62
|
-
}
|
|
62
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mypgs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "MyPGS frontend theme and UI behaviors, with bundled JavaScript and CSS assets.",
|
|
5
5
|
"main": "./dist/javascript/index.js",
|
|
6
6
|
"module": "./assets/javascript/index.js",
|
|
@@ -12,7 +12,17 @@
|
|
|
12
12
|
"default": "./dist/javascript/index.js"
|
|
13
13
|
},
|
|
14
14
|
"./style.css": "./dist/css/index.css",
|
|
15
|
-
"./style.min.css": "./dist/css/index.min.css"
|
|
15
|
+
"./style.min.css": "./dist/css/index.min.css",
|
|
16
|
+
"./react": {
|
|
17
|
+
"types": "./react.d.ts",
|
|
18
|
+
"import": "./react.js",
|
|
19
|
+
"default": "./react.js"
|
|
20
|
+
},
|
|
21
|
+
"./vite-plugin-pgs": {
|
|
22
|
+
"types": "./plugins/vite-plugin-pgs.d.ts",
|
|
23
|
+
"import": "./plugins/vite-plugin-pgs.js",
|
|
24
|
+
"default": "./plugins/vite-plugin-pgs.js"
|
|
25
|
+
}
|
|
16
26
|
},
|
|
17
27
|
"style": "./dist/css/index.css",
|
|
18
28
|
"scripts": {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default function pgsVite() {
|
|
2
|
+
return {
|
|
3
|
+
name: "vite-plugin-pgs-html",
|
|
4
|
+
enforce: "pre",
|
|
5
|
+
|
|
6
|
+
transform(code, id) {
|
|
7
|
+
if (!/\.(jsx|tsx)$/.test(id)) return null;
|
|
8
|
+
|
|
9
|
+
const nextCode = code.replace(/\bpgsHtml(\s*)=/g, "pgs$1=");
|
|
10
|
+
|
|
11
|
+
if (nextCode === code) return null;
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
code: nextCode,
|
|
15
|
+
map: null,
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
package/react.d.ts
ADDED
package/react.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/templates/html/demo.js
CHANGED
|
@@ -31,15 +31,13 @@ const templateFiles = [
|
|
|
31
31
|
"layout/flex.html",
|
|
32
32
|
"layout/grid.html",
|
|
33
33
|
"layout/pageShell.html",
|
|
34
|
+
"layout/footer.html",
|
|
35
|
+
"layout/header.html",
|
|
34
36
|
"patterns/cookieConsent.html",
|
|
35
|
-
"patterns/header.html",
|
|
36
|
-
"patterns/footer.html",
|
|
37
37
|
];
|
|
38
38
|
|
|
39
39
|
function getTemplateTitle(path) {
|
|
40
|
-
return path
|
|
41
|
-
.replace(".html", "")
|
|
42
|
-
.replace("/", " / ")
|
|
40
|
+
return path.replace(".html", "").replace("/", " / ")
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
function renderSourceTemplate(section, html) {
|
|
@@ -72,9 +70,7 @@ function renderTitle(section, path) {
|
|
|
72
70
|
|
|
73
71
|
async function loadTemplate(path) {
|
|
74
72
|
const response = await fetch(path);
|
|
75
|
-
if (!response.ok) {
|
|
76
|
-
throw new Error(`${path}: ${response.status}`);
|
|
77
|
-
}
|
|
73
|
+
if (!response.ok) throw new Error(`${path}: ${response.status}`);
|
|
78
74
|
return response.text();
|
|
79
75
|
}
|
|
80
76
|
|
|
@@ -90,8 +86,8 @@ async function bootDemo() {
|
|
|
90
86
|
const AFTER = document.getElementById("templates-demo-after");
|
|
91
87
|
|
|
92
88
|
for (const path of templateFiles) {
|
|
93
|
-
const isHeader = path === "
|
|
94
|
-
const isfooter = path === "
|
|
89
|
+
const isHeader = path === "layout/header.html";
|
|
90
|
+
const isfooter = path === "layout/footer.html";
|
|
95
91
|
const isBody = path === "layout/body.html";
|
|
96
92
|
|
|
97
93
|
if (isHeader || isfooter) {
|
|
@@ -103,7 +99,6 @@ async function bootDemo() {
|
|
|
103
99
|
message.textContent = `Template non caricato: ${error.message}`;
|
|
104
100
|
layoutRoot.append(message);
|
|
105
101
|
}
|
|
106
|
-
|
|
107
102
|
continue;
|
|
108
103
|
}
|
|
109
104
|
|
|
@@ -116,7 +111,6 @@ async function bootDemo() {
|
|
|
116
111
|
const html = await loadTemplate(path);
|
|
117
112
|
renderSourceTemplate(section, html);
|
|
118
113
|
MAIN.append(section);
|
|
119
|
-
|
|
120
114
|
continue
|
|
121
115
|
}
|
|
122
116
|
|
|
@@ -133,7 +127,6 @@ async function bootDemo() {
|
|
|
133
127
|
|
|
134
128
|
if (path == "layout/section.html" || path == "layout/pageShell.html") {
|
|
135
129
|
section.style.display = "contents";
|
|
136
|
-
|
|
137
130
|
Array.from(section.children).forEach(c => c.style.width = "100%");
|
|
138
131
|
}
|
|
139
132
|
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
type PgsSelectorValue = string | string[];
|
|
3
|
-
type PgsStateValue = string | string[];
|
|
4
|
-
|
|
5
|
-
interface PgsQueryableApi {
|
|
6
|
-
querySelector(value: PgsSelectorValue): Element | null;
|
|
7
|
-
querySelectorAll(value: PgsSelectorValue): NodeListOf<Element>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface PgsStateApi {
|
|
11
|
-
(...values: PgsStateValue[]): PgsStateApi;
|
|
12
|
-
add(...values: PgsStateValue[]): PgsStateApi;
|
|
13
|
-
remove(...values: PgsStateValue[]): PgsStateApi;
|
|
14
|
-
toggle(value: string, force?: boolean): boolean;
|
|
15
|
-
contains(value: string): boolean;
|
|
16
|
-
value: string | null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface PgsOptionApi {
|
|
20
|
-
contains(key: string): boolean;
|
|
21
|
-
getValueBrackets(key: string): string | undefined;
|
|
22
|
-
value: string | null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface PgsElementApi extends PgsQueryableApi {
|
|
26
|
-
(): PgsElementApi;
|
|
27
|
-
add(...values: string[]): PgsElementApi;
|
|
28
|
-
remove(...values: string[]): PgsElementApi;
|
|
29
|
-
toggle(value: string, force?: boolean): boolean;
|
|
30
|
-
contains(value: string): boolean;
|
|
31
|
-
value: string | null;
|
|
32
|
-
state: PgsStateApi;
|
|
33
|
-
option: PgsOptionApi;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface PgsDocumentApi extends PgsQueryableApi {
|
|
37
|
-
(): PgsDocumentApi;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
type PgsApi = PgsElementApi | PgsDocumentApi;
|
|
41
|
-
|
|
42
|
-
interface PgsFunction {
|
|
43
|
-
(root: Document): PgsDocumentApi;
|
|
44
|
-
(root: Element): PgsElementApi;
|
|
45
|
-
(root: Document | Element): PgsApi;
|
|
46
|
-
registerImport(...modules: unknown[]): PgsFunction;
|
|
47
|
-
registerModules(modules: Record<string, any>): PgsFunction;
|
|
48
|
-
import(...names: string[]): Record<string, any>;
|
|
49
|
-
accordion?: any;
|
|
50
|
-
dropdown?: any;
|
|
51
|
-
menu?: any;
|
|
52
|
-
modal?: any;
|
|
53
|
-
notification?: any;
|
|
54
|
-
slides?: any;
|
|
55
|
-
stepTabs?: any;
|
|
56
|
-
steps?: any;
|
|
57
|
-
summary?: any;
|
|
58
|
-
formValidate?: any;
|
|
59
|
-
scrollHorizontal?: any;
|
|
60
|
-
[moduleName: string]: any;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
interface PgsBag extends PgsElementApi {}
|
|
64
|
-
|
|
65
|
-
var pgs: PgsFunction;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function pgs(root: Document): PgsDocumentApi;
|
|
69
|
-
export function pgs(root: Element): PgsElementApi;
|
|
70
|
-
export function pgs(root: Document | Element): PgsApi;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|