mypgs 1.1.5 → 1.3.3

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 (80) hide show
  1. package/AI_GUIDELINES.md +353 -0
  2. package/README.md +483 -53
  3. package/assets/javascript/_imports.js +26 -0
  4. package/assets/javascript/_pgs.js +53 -2
  5. package/assets/javascript/components/_accordion.js +114 -66
  6. package/assets/javascript/components/_dropdown.js +199 -98
  7. package/assets/javascript/components/_menu.js +33 -69
  8. package/assets/javascript/components/_modals.js +44 -3
  9. package/assets/javascript/components/_notifications.js +162 -0
  10. package/assets/javascript/components/_slides.js +11 -1
  11. package/assets/javascript/components/_stepTabs.js +16 -4
  12. package/assets/javascript/components/_steps.js +32 -6
  13. package/assets/javascript/functions/_formValidate.js +4 -5
  14. package/assets/javascript/index.js +8 -4
  15. package/assets/javascript/patterns/_cookieConsent.js +8 -2
  16. package/assets/javascript/patterns/_header.js +1 -1
  17. package/assets/javascript/pgs.d.ts +17 -2
  18. package/assets/scss/base/_html.scss +23 -1
  19. package/assets/scss/components/_dropdown.scss +24 -88
  20. package/assets/scss/components/_logo.scss +1 -1
  21. package/assets/scss/components/_menu.scss +129 -15
  22. package/assets/scss/components/_modals.scss +15 -3
  23. package/assets/scss/components/_notification.scss +11 -14
  24. package/assets/scss/components/_tooltip.scss +2 -9
  25. package/assets/scss/index.scss +0 -1
  26. package/assets/scss/layout/_gap.scss +7 -1
  27. package/assets/scss/layout/_layout.scss +0 -12
  28. package/assets/scss/layout/_pageShell.scss +102 -108
  29. package/assets/scss/mixin/_mx-form.scss +1 -3
  30. package/assets/scss/mixin/_mx-responsive.scss +2 -2
  31. package/assets/scss/mixin/_mx-semantic.scss +0 -60
  32. package/assets/scss/mixin/mixin.scss +0 -1
  33. package/assets/scss/patterns/_footer.scss +1 -0
  34. package/assets/scss/patterns/_header.scss +20 -18
  35. package/dist/css/index.css +325 -1161
  36. package/dist/css/index.css.map +1 -1
  37. package/dist/css/index.min.css +1 -1
  38. package/dist/index.d.ts +17 -2
  39. package/dist/javascript/index.js +985 -412
  40. package/dist/javascript/index.js.map +1 -1
  41. package/dist/javascript/index.min.js +1 -1
  42. package/package.json +7 -2
  43. package/templates/components/{md-accordion.html → accordion.html} +2 -2
  44. package/templates/components/dropdown.html +91 -0
  45. package/templates/components/menu.html +41 -0
  46. package/templates/components/modal.html +78 -0
  47. package/templates/components/notification.html +35 -0
  48. package/templates/components/{md-slides.html → slides.html} +5 -5
  49. package/templates/components/{md-steps.html → steps.html} +7 -7
  50. package/templates/components/{md-tooltip.html → tooltip.html} +4 -2
  51. package/templates/demo.css +18 -0
  52. package/templates/demo.html +4 -5
  53. package/templates/demo.js +53 -52
  54. package/templates/layout/flex.html +89 -0
  55. package/templates/layout/grid.html +89 -0
  56. package/templates/layout/pageShell.html +59 -0
  57. package/templates/layout/section.html +40 -0
  58. package/templates/{layout/md-footer.html → patterns/footer.html} +1 -0
  59. package/templates/{layout/md-header.html → patterns/header.html} +6 -9
  60. package/assets/javascript/components/_exeNotifications.js +0 -85
  61. package/assets/javascript/functions/_notifications.js +0 -74
  62. package/assets/javascript/functions/_sendForm.js +0 -100
  63. package/assets/scss/base/_reset.scss +0 -15
  64. package/assets/scss/mixin/_mx-menu.scss +0 -154
  65. package/templates/components/md-dropdown.html +0 -16
  66. package/templates/components/md-menu.html +0 -40
  67. package/templates/components/md-modal.html +0 -19
  68. package/templates/components/md-notification.html +0 -13
  69. package/templates/layout/md-pageShell.html +0 -22
  70. package/templates/layout/md-section.html +0 -25
  71. /package/templates/components/{md-breadcumbs.html → breadcumbs.html} +0 -0
  72. /package/templates/components/{md-button.html → button.html} +0 -0
  73. /package/templates/components/{md-card.html → card.html} +0 -0
  74. /package/templates/components/{md-form.html → form.html} +0 -0
  75. /package/templates/components/{md-logo.html → logo.html} +0 -0
  76. /package/templates/components/{md-searchbar.html → searchbar.html} +0 -0
  77. /package/templates/components/{md-stepTabs.html → stepTabs.html} +0 -0
  78. /package/templates/components/{md-table.html → table.html} +0 -0
  79. /package/templates/layout/{md-body.html → body.html} +0 -0
  80. /package/templates/{layout/md-cookieConsent.html → patterns/cookieConsent.html} +0 -0
@@ -0,0 +1,353 @@
1
+ # AI Guidelines for `mypgs`
2
+
3
+ This guide is for any AI/Codex agent that initializes or modifies a project based on the `mypgs` NPM library. Before writing custom CSS, JavaScript, or markup, always check whether `mypgs` already provides suitable `pgs` tokens, components, layouts, mixins, variables, or APIs.
4
+
5
+ ## 1. Library Overview
6
+
7
+ `mypgs` is a shared frontend library for building consistent interfaces through:
8
+
9
+ - HTML `pgs` attributes as the contract between markup, SCSS, and JavaScript;
10
+ - SCSS sources with base styles, layouts, components, patterns, CSS variables, and mixins;
11
+ - JavaScript modules for recurring behaviors such as accordions, dropdowns, menus, modals, slides, steps, step tabs, notifications, header, cookie consent, and dark mode;
12
+ - example HTML templates in `templates/`;
13
+ - compiled assets in `dist/`.
14
+
15
+ It solves the problem of rewriting layouts, buttons, forms, modals, menus, tabs, spacing, states, and base interactions every time. It should be used as the design system foundation because it centralizes naming, spacing, colors, radii, shadows, accessible behaviors, and reusable patterns.
16
+
17
+ Prefer `mypgs` over custom CSS/JS when:
18
+
19
+ - you need standard layouts, sections, containers, grids, flex utilities, or a page shell;
20
+ - you need components that already exist in the library;
21
+ - you need to add states, options, or behaviors already handled by the `pgs`, `pgs-state`, and `pgs-option` attributes;
22
+ - the request is about visual consistency, development speed, or reuse.
23
+
24
+ Write custom code only when the pattern does not exist, or when you are adding a new reusable feature to the library.
25
+
26
+ ## 2. General Usage Rules
27
+
28
+ - Use `mypgs` as the first choice for layouts, components, helpers, variables, utilities, and available patterns.
29
+ - Do not recreate existing components from scratch: buttons, forms, dropdowns, modals, menus, slides, accordions, steps, stepTabs, notifications, tooltips, tables, searchbars, logos, headers, footers, and cookie consent.
30
+ - Do not duplicate logic already handled by the `mypgs` JS modules, such as modal open/close, accordion state, Popover API dropdowns, step tabs, notifications, or form validation.
31
+ - Keep `pgs` tokens in markup, SCSS selectors, and JS queries consistent.
32
+ - Prefer composing `pgs` tokens over adding new CSS classes.
33
+ - Classes are acceptable for external integrations or local details, but they must not replace existing PGS tokens.
34
+ - Keep markup semantic and accessible: the library adds many ARIA attributes, but the base structure still needs to be correct.
35
+
36
+ ## 3. Existing File Analysis
37
+
38
+ Files analyzed:
39
+
40
+ - `assets/javascript/_pgs.js`
41
+ - `assets/javascript/index.js`
42
+ - `assets/javascript/_imports.js`
43
+ - `assets/javascript/pgs.d.ts`
44
+ - `dist/index.d.ts`
45
+ - `assets/javascript/base/_darkmode.js`
46
+ - `assets/javascript/base/_object.js`
47
+ - `assets/javascript/components/_accordion.js`
48
+ - `assets/javascript/components/_dropdown.js`
49
+ - `assets/javascript/components/_menu.js`
50
+ - `assets/javascript/components/_modals.js`
51
+ - `assets/javascript/components/_slides.js`
52
+ - `assets/javascript/components/_steps.js`
53
+ - `assets/javascript/components/_stepTabs.js`
54
+ - `assets/javascript/components/_notifications.js`
55
+ - `assets/javascript/functions/_formValidate.js`
56
+ - `assets/javascript/functions/_scrollY.js`
57
+ - `assets/javascript/patterns/_header.js`
58
+ - `assets/javascript/patterns/_cookieConsent.js`
59
+ - `assets/scss/index.scss`
60
+ - `assets/scss/base/*`
61
+ - `assets/scss/layout/*`
62
+ - `assets/scss/components/*`
63
+ - `assets/scss/patterns/*`
64
+ - `assets/scss/mixin/*`
65
+ - `templates/components/*`
66
+ - `templates/layout/*`
67
+ - `templates/patterns/*`
68
+
69
+ Patterns found:
70
+
71
+ - `pgs` is the main attribute: tokens are separated by spaces, for example `pgs="button modal-button"`.
72
+ - `assets/scss/index.scss` imports base, layout, components, and patterns; layouts/components/patterns are almost all scoped under `[pgs~=initP]`.
73
+ - The main markup must enable the library with `htmlBase initP`, and the body with base body tokens. Use `templates/demo.html` and `templates/layout/body.html` as the canonical references.
74
+ - Components use a root token and child tokens with a consistent prefix. Use `templates/components/` as the canonical markup source.
75
+
76
+ - Runtime states use `pgs-state`, for example `open`, `is-active`, `is-completed`, `is-locked`, `success`, `error`, `warning`, and `info`.
77
+ - Configurable options use `pgs-option`, with simple tokens or values inside square brackets. Prefer copying the current option syntax from the relevant template rather than duplicating examples in this guide.
78
+
79
+ - Naming is mostly camelCase for compound tokens (`menuHorizontal`, `buttonStrong`, `flexColumnElements`) and kebab-like for component sub-elements (`accordion-button`, `modal-dialog-content`, `cookieConsent-actionAccept`).
80
+ - JS modules export objects with `init` and/or `api`; `_imports.js` registers them with `pgs.registerModules` for direct `pgs.*` access.
81
+
82
+ ## 4. SCSS Guidelines
83
+
84
+ Recommended imports in a project that consumes the library:
85
+
86
+ ```scss
87
+ @import "../../node_modules/mypgs/assets/scss/mixin/mixin.scss";
88
+ @import "../../node_modules/mypgs/assets/scss/index.scss";
89
+ ```
90
+
91
+ If you only need the mixins:
92
+
93
+ ```scss
94
+ @import "../../node_modules/mypgs/assets/scss/mixin/mixin.scss";
95
+ ```
96
+
97
+ Direct usage of the compiled CSS:
98
+
99
+ ```js
100
+ import "mypgs/style.css";
101
+ ```
102
+
103
+ SCSS rules:
104
+
105
+ - Use the existing custom properties, for example `--color-primary`, `--color-box`, `--color-text`, `--padding`, `--padding-page`, `--gap-texts`, `--gap-elements`, `--gap-sections`, `--border-radius`, `--border-radius-input`, `--border-complete`, `--box-shadow`, and `--focus-visible`.
106
+ - Use existing mixins and tokens instead of rewriting layouts: `flexColumn`, `flexRow`, `grid-*`, `section`, `container`, `card`, `button`, `form`.
107
+ - Configure dropdown placement with `pgs-option="position[side align]"`, for example `position[top left]`, `position[bottom right]`, or `position[left center]`; do not use a SCSS/CSS custom property for dropdown placement.
108
+ - Prefer overrides through custom properties on the component:
109
+
110
+ ```scss
111
+ #dropdownMenuPrimary { //[pgs~="dropdown"]
112
+ --dropdown-background: var(--color-box);
113
+ --dropdown-padding: var(--padding-2);
114
+ --dropdown-maxwidth: min(420px, 90vw);
115
+ }
116
+ ```
117
+
118
+ - Avoid aggressive overrides of `padding`, `gap`, `display`, `position`, and `overflow` when they are already handled by the design system.
119
+ - You may customize colors, border-radius, borders, shadows, and visual details while keeping token consistency.
120
+ - If new reusable styles are needed, add them modularly in the correct group: `base`, `layout`, `components`, `patterns`, or `mixin`.
121
+ - If you add a new PGS component, keep the same contract: root token, child tokens, optional states in `pgs-state`, optional options in `pgs-option`.
122
+
123
+ Recommended:
124
+
125
+ ```scss
126
+ #products .products-card {
127
+ --card-background: var(--color-box);
128
+ --button-background: var(--color-primary);
129
+ border-radius: var(--border-radius)
130
+ }
131
+ ```
132
+
133
+ Allowed, but less recommended:
134
+
135
+ ```scss
136
+ [pgs~="card"].products-card {
137
+ --card-background: var(--color-box);
138
+ --button-background: var(--color-primary);
139
+ border-radius: var(--border-radius)
140
+ }
141
+ ```
142
+
143
+ Avoid:
144
+
145
+ ```scss
146
+ .products-card {
147
+ padding: 37px;
148
+ border-radius: 19px;
149
+ background: #f8f8f8;
150
+ }
151
+ ```
152
+
153
+ ## 5. JS/TS Guidelines
154
+
155
+ Base import:
156
+
157
+ ```js
158
+ import "mypgs";
159
+ ```
160
+
161
+ Or, if you need to access the helper:
162
+
163
+ ```js
164
+ import { pgs } from "mypgs";
165
+ ```
166
+
167
+ The entrypoint automatically initializes the global `pgs` helper, dark mode, SVG object handling, accordion, dropdown, menu, modals, slides, steps, stepTabs, notifications, header, and cookie consent.
168
+
169
+ Available `pgs` helper:
170
+
171
+ ```js
172
+ const modal = pgs(document).querySelector("modal");
173
+ pgs(modal).add("custom-token");
174
+ pgs(modal).remove("custom-token");
175
+ pgs(modal).toggle("custom-token", true);
176
+ pgs(modal).contains("modal");
177
+ pgs(modal).state.add("open");
178
+ pgs(modal).state.toggle("open", false);
179
+ pgs(modal).option.contains("history");
180
+ pgs(modal).option.getValueBrackets("containerID");
181
+ ```
182
+
183
+ Recommended direct access:
184
+
185
+ ```js
186
+ pgs.notification.toast.success("Saved");
187
+ pgs.modal.api(modalEl)?.open();
188
+ ```
189
+
190
+ `assets/javascript/_imports.js` registers modules with `pgs.registerModules`:
191
+
192
+ ```js
193
+ pgs.registerModules({
194
+ notification: PGS_notification,
195
+ });
196
+ ```
197
+
198
+ - `pgs.registerModules` exposes the module directly on `pgs`, for example `pgs.notification`.
199
+
200
+ Before using a module shortcut, verify the current key in `assets/javascript/_imports.js`. If `_imports.js` registers `{ notification: PGS_notification }`, the public shortcut is `pgs.notification`. Do not rely on a hardcoded shortcut list in this guide.
201
+
202
+ JS/TS rules:
203
+
204
+ - Prefer existing APIs and init functions before writing new functions.
205
+ - Do not duplicate existing helpers, modules, or services exposed through `pgs.*`.
206
+ - Initialization functions should accept a root when possible.
207
+ - Use `WeakMap` for instance APIs if you add components, as accordion, dropdown, menu, modals, slides, steps, and stepTabs do.
208
+ - Keep events and states consistent: visual states belong in `pgs-state`, not arbitrary classes.
209
+ - Do not rely on `.open` classes for PGS components when the component uses `pgs-state~="open"`.
210
+
211
+ Existing API example:
212
+
213
+ ```js
214
+ const modalEl = pgs(document).querySelector("modal");
215
+
216
+ pgs.modal.api(modalEl)?.open();
217
+ ```
218
+
219
+ ## 6. Components and Markup
220
+
221
+ Use the templates as the single source of truth for component and layout markup. Do not copy full HTML examples into this guide; this avoids drift when templates change.
222
+
223
+ Canonical template references:
224
+
225
+ - Layouts: `templates/layout/body.html`, `templates/layout/flex.html`, `templates/layout/grid.html`, `templates/layout/pageShell.html`, `templates/layout/section.html`
226
+ - Components: `templates/components/accordion.html`, `templates/components/breadcumbs.html`, `templates/components/button.html`, `templates/components/card.html`, `templates/components/dropdown.html`, `templates/components/form.html`, `templates/components/logo.html`, `templates/components/menu.html`, `templates/components/modal.html`, `templates/components/notification.html`, `templates/components/searchbar.html`, `templates/components/slides.html`, `templates/components/stepTabs.html`, `templates/components/steps.html`, `templates/components/table.html`, `templates/components/tooltip.html`
227
+ - Patterns: `templates/patterns/cookieConsent.html`, `templates/patterns/footer.html`, `templates/patterns/header.html`
228
+ - Complete demo assembly. DO NOT use this for inspiration. It is only used to show all the modules: `templates/demo.html`
229
+
230
+ Before creating markup, open the relevant template and reuse its current structure, tokens, ARIA attributes, and `pgs-option` syntax.
231
+
232
+ To extend a component:
233
+
234
+ - keep the required root and child tokens;
235
+ - add a specific `pgs` token or a local class only for the variant;
236
+ - configure through custom properties or `pgs-option`;
237
+ - do not remove elements that JS looks up with `pgs(...).querySelector(...)`.
238
+
239
+ ## 7. What NOT To Do
240
+
241
+ - Do not replace `mypgs` with custom solutions without a clear technical reason.
242
+ - Do not hardcode colors if variables or custom properties exist; always use `var(--color-primary)`, etc.
243
+ - Do not create duplicate components for buttons, forms, modals, dropdowns, slides, tabs, notifications, or menus.
244
+ - Do not duplicate open, close, state, or accessibility logic already handled by the modules.
245
+ - Do not make the code more complex than necessary.
246
+ - Do not invent APIs: if a method is not present in `assets/javascript/*` or in the `.d.ts` files, it must be verified or explicitly added.
247
+
248
+ ## 8. Practical Examples
249
+
250
+ Recommended import in a project:
251
+
252
+ ```js
253
+ import "mypgs";
254
+ import "mypgs/style.css";
255
+ ```
256
+
257
+ Source SCSS import:
258
+
259
+ ```scss
260
+ @import "../../node_modules/mypgs/assets/scss/mixin/mixin.scss";
261
+ @import "../../node_modules/mypgs/assets/scss/index.scss";
262
+ ```
263
+
264
+ Recommended: use PGS layout tokens from `templates/layout/`.
265
+
266
+ Avoid: equivalent custom layout with ad hoc classes when a PGS layout token already exists.
267
+
268
+ Recommended: customize a button with variables.
269
+
270
+ ```scss
271
+ #danger-action {
272
+ --button-background: var(--color-error);
273
+ --button-color: var(--color-whiteFixed);
274
+ }
275
+ ```
276
+
277
+ Avoid: rewriting the whole button.
278
+
279
+ ```scss
280
+ .danger-action {
281
+ display: inline-flex;
282
+ gap: 12px;
283
+ padding: 14px 22px;
284
+ border-radius: 999px;
285
+ background: #ff6161;
286
+ }
287
+ ```
288
+
289
+ Recommended: PGS state.
290
+
291
+ ```js
292
+ const accordion = pgs(document).querySelector("accordion");
293
+ pgs(accordion).state.toggle("open", true);
294
+ ```
295
+
296
+ Avoid: parallel class not read by the library.
297
+
298
+ ```js
299
+ accordion.classList.add("open");
300
+ ```
301
+
302
+ Recommended: use the notification API registered on `pgs`.
303
+
304
+ ```js
305
+ pgs.notification.toast.success("Saved");
306
+ ```
307
+
308
+ Avoid: creating a separate toast system outside `pgs.notification`.
309
+
310
+ ## 9. Rules for New Features
311
+
312
+ Before developing a new feature:
313
+
314
+ - check `README.md`, `templates/`, `assets/scss/`, and `assets/javascript/`;
315
+ - search for existing tokens or APIs with `rg "featureName|pgs-token"`;
316
+ - verify whether `mypgs` already provides suitable components, helpers, mixins, or variables;
317
+ - use naming consistent with the existing project;
318
+ - clearly separate HTML structure, SCSS styling, and JS logic;
319
+ - write simple, modular, maintainable code;
320
+ - update this guide if you introduce an important new pattern.
321
+
322
+ For a new reusable component:
323
+
324
+ - create SCSS in `assets/scss/components/` or `assets/scss/patterns/`;
325
+ - import the file from `assets/scss/index.scss` in the correct block;
326
+ - create JS in `assets/javascript/components/` or `assets/javascript/patterns/` only if behavior is needed;
327
+ - export an object with `init` and/or `api` when the module needs a public API;
328
+ - register it in `assets/javascript/_imports.js` with `pgs.registerModules` if it must be available as `pgs.moduleName`;
329
+ - add a template in `templates/components/` or `templates/layout/`;
330
+ - update `README.md` and this guide if the usage changes.
331
+
332
+ Example for a new module:
333
+
334
+ ```js
335
+ import { PGS_myNewComponent } from "./components/_myNewComponent.js";
336
+
337
+ pgs.registerModules({
338
+ myNewComponent: PGS_myNewComponent,
339
+ });
340
+ ```
341
+
342
+ ## 10. Quick AI Checklist
343
+
344
+ - Did I check whether a suitable `pgs` token or component already exists?
345
+ - Did I consult `templates/` to copy the correct markup?
346
+ - Did I enable `htmlBase initP` and the base body tokens when the full library is needed?
347
+ - Am I using PGS CSS variables and mixins instead of hardcoded values?
348
+ - Am I using `pgs-state` for runtime states and `pgs-option` for configuration?
349
+ - Am I avoiding custom classes when a PGS token is enough?
350
+ - Did I verify JS APIs in the source or TypeScript declarations?
351
+ - Did I keep markup, style, and logic separate?
352
+ - Did I avoid direct edits to `dist/` as the source of truth?
353
+ - If I introduced a new pattern, did I update this guide?