mypgs 1.5.0 → 1.6.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.
Files changed (48) hide show
  1. package/AGENTS.md +6 -3
  2. package/README.md +22 -373
  3. package/assets/javascript/_imports.js +4 -0
  4. package/assets/javascript/_pgs.js +58 -0
  5. package/assets/javascript/base/_darkmode.js +27 -105
  6. package/assets/javascript/base/_svg.js +103 -0
  7. package/assets/javascript/components/_menu.js +1 -3
  8. package/assets/javascript/components/_search.js +391 -0
  9. package/assets/javascript/index.js +2 -0
  10. package/assets/javascript/layout/_header.js +26 -7
  11. package/assets/scss/base/_color.scss +8 -15
  12. package/assets/scss/base/_general.scss +36 -48
  13. package/assets/scss/base/_heading.scss +14 -16
  14. package/assets/scss/base/_variables.scss +4 -2
  15. package/assets/scss/components/_card.scss +10 -0
  16. package/assets/scss/components/_dropdown.scss +2 -1
  17. package/assets/scss/components/_logo.scss +2 -2
  18. package/assets/scss/components/_menu.scss +20 -27
  19. package/assets/scss/components/_modals.scss +11 -1
  20. package/assets/scss/components/_search.scss +134 -0
  21. package/assets/scss/index.scss +8 -4
  22. package/assets/scss/layout/_header.scss +1 -1
  23. package/assets/scss/layout/_pageShell.scss +1 -0
  24. package/dist/css/index.css +658 -620
  25. package/dist/css/index.css.map +1 -1
  26. package/dist/css/index.min.css +1 -1
  27. package/dist/index.d.ts +78 -0
  28. package/dist/javascript/index.js +904 -370
  29. package/dist/javascript/index.js.map +1 -1
  30. package/dist/javascript/index.min.js +1 -1
  31. package/docs/componenti-e-markup.md +90 -0
  32. package/docs/convenzioni.md +12 -0
  33. package/docs/export-e-sviluppo.md +109 -0
  34. package/docs/helper-javascript.md +127 -0
  35. package/docs/utilizzo-css-scss.md +36 -0
  36. package/package.json +1 -6
  37. package/plugins/vite-plugin-pgs.d.ts +10 -0
  38. package/templates/html/components/logo.html +1 -1
  39. package/templates/html/components/menu.html +13 -1
  40. package/templates/html/components/{searchbar.html → search.html} +7 -5
  41. package/templates/html/demo.js +1 -8
  42. package/templates/html/layout/header.html +11 -5
  43. package/templates/react/components/logo.jsx +1 -1
  44. package/templates/react/components/{searchbar.jsx → search.jsx} +9 -7
  45. package/templates/react/patterns/header.jsx +16 -10
  46. package/assets/scss/components/_searchbar.scss +0 -70
  47. package/react.d.ts +0 -11
  48. package/react.js +0 -1
package/dist/index.d.ts CHANGED
@@ -17,8 +17,12 @@ declare global {
17
17
  }
18
18
 
19
19
  interface PgsOptionApi {
20
+ add(...values: PgsStateValue[]): PgsOptionApi;
21
+ remove(...values: PgsStateValue[]): PgsOptionApi;
22
+ toggle(value: string, force?: boolean): boolean;
20
23
  contains(key: string): boolean;
21
24
  getValueBrackets(key: string): string | undefined;
25
+ setValueBrackets(key: string, value?: string): PgsOptionApi;
22
26
  value: string | null;
23
27
  }
24
28
 
@@ -39,6 +43,71 @@ declare global {
39
43
 
40
44
  type PgsApi = PgsElementApi | PgsDocumentApi;
41
45
 
46
+ type PgsSearchSuggestionInput = string | number | {
47
+ label?: string;
48
+ value?: string | number;
49
+ disabled?: boolean;
50
+ data?: unknown;
51
+ };
52
+
53
+ interface PgsSearchSuggestion {
54
+ label: string;
55
+ value: string;
56
+ disabled: boolean;
57
+ data: unknown;
58
+ }
59
+
60
+ interface PgsSearchSourceContext {
61
+ query: string;
62
+ signal: AbortSignal;
63
+ limit: number;
64
+ element: Element;
65
+ input: HTMLInputElement;
66
+ }
67
+
68
+ interface PgsSearchSelectDetail {
69
+ item: PgsSearchSuggestion;
70
+ index: number;
71
+ value: string;
72
+ input: HTMLInputElement;
73
+ element: Element;
74
+ }
75
+
76
+ interface PgsSearchOptions {
77
+ minLength: number;
78
+ debounce: number;
79
+ limit: number;
80
+ submitOnSelect: boolean;
81
+ searchOnFocus: boolean;
82
+ source: PgsSearchSuggestionInput[] | ((context: PgsSearchSourceContext) => PgsSearchSuggestionInput[] | Promise<PgsSearchSuggestionInput[]>) | null;
83
+ onSelect: ((detail: PgsSearchSelectDetail) => void) | null;
84
+ }
85
+
86
+ interface PgsSearchInstance {
87
+ element: Element;
88
+ input: HTMLInputElement;
89
+ list: Element;
90
+ configure(options: Partial<PgsSearchOptions>): PgsSearchInstance;
91
+ setSource(source: PgsSearchOptions["source"]): PgsSearchInstance;
92
+ search(query?: string): Promise<PgsSearchSuggestion[]>;
93
+ open(): void;
94
+ close(): void;
95
+ clear(): void;
96
+ cancel(): void;
97
+ select(index?: number, submit?: boolean): PgsSearchSuggestion | null;
98
+ refresh(): Promise<PgsSearchSuggestion[]>;
99
+ destroy(): void;
100
+ items(): PgsSearchSuggestion[];
101
+ isOpen(): boolean;
102
+ isLoading(): boolean;
103
+ setActiveIndex(index: number): void;
104
+ }
105
+
106
+ interface PgsSearchModule {
107
+ init(root?: Document | Element): void;
108
+ api(selector: Element): PgsSearchInstance | undefined;
109
+ }
110
+
42
111
  interface PgsFunction {
43
112
  (root: Document): PgsDocumentApi;
44
113
  (root: Element): PgsElementApi;
@@ -51,6 +120,7 @@ declare global {
51
120
  menu?: any;
52
121
  modal?: any;
53
122
  notification?: any;
123
+ search?: PgsSearchModule;
54
124
  slides?: any;
55
125
  stepTabs?: any;
56
126
  steps?: any;
@@ -61,6 +131,14 @@ declare global {
61
131
 
62
132
  interface PgsBag extends PgsElementApi {}
63
133
 
134
+ namespace React {
135
+ interface HTMLAttributes<T> {
136
+ /** Use pgsHtml in JSX/TSX. The Vite plugin converts it to pgs. */
137
+ pgs?: never;
138
+ pgsHtml?: string;
139
+ }
140
+ }
141
+
64
142
  var pgs: PgsFunction;
65
143
  }
66
144