beercss 3.13.1 → 3.13.2

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 (159) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +328 -322
  3. package/custom-element/index.d.ts +18 -18
  4. package/custom-element/index.js +7 -7
  5. package/dist/cdn/arch.svg +3 -3
  6. package/dist/cdn/arrow.svg +3 -3
  7. package/dist/cdn/beer.css +4792 -4789
  8. package/dist/cdn/beer.custom-element.js +38 -38
  9. package/dist/cdn/beer.custom-element.min.js +1 -1
  10. package/dist/cdn/beer.js +635 -635
  11. package/dist/cdn/beer.min.css +1 -1
  12. package/dist/cdn/beer.min.js +1 -1
  13. package/dist/cdn/beer.scoped.css +4793 -4790
  14. package/dist/cdn/beer.scoped.min.css +1 -1
  15. package/dist/cdn/boom.svg +3 -3
  16. package/dist/cdn/bun.svg +3 -3
  17. package/dist/cdn/burst.svg +3 -3
  18. package/dist/cdn/circle.svg +3 -3
  19. package/dist/cdn/clamshell.svg +3 -3
  20. package/dist/cdn/diamond.svg +3 -3
  21. package/dist/cdn/fan.svg +3 -3
  22. package/dist/cdn/flower.svg +3 -3
  23. package/dist/cdn/gem.svg +3 -3
  24. package/dist/cdn/ghost-ish.svg +3 -3
  25. package/dist/cdn/heart.svg +3 -3
  26. package/dist/cdn/leaf-clover4.svg +3 -3
  27. package/dist/cdn/leaf-clover8.svg +3 -3
  28. package/dist/cdn/loading-indicator.svg +18 -18
  29. package/dist/cdn/oval.svg +3 -3
  30. package/dist/cdn/pentagon.svg +3 -3
  31. package/dist/cdn/pill.svg +3 -3
  32. package/dist/cdn/pixel-circle.svg +3 -3
  33. package/dist/cdn/pixel-triangle.svg +3 -3
  34. package/dist/cdn/puffy-diamond.svg +3 -3
  35. package/dist/cdn/puffy.svg +3 -3
  36. package/dist/cdn/semicircle.svg +3 -3
  37. package/dist/cdn/sided-cookie12.svg +3 -3
  38. package/dist/cdn/sided-cookie4.svg +3 -3
  39. package/dist/cdn/sided-cookie6.svg +3 -3
  40. package/dist/cdn/sided-cookie7.svg +3 -3
  41. package/dist/cdn/sided-cookie9.svg +3 -3
  42. package/dist/cdn/slanted.svg +3 -3
  43. package/dist/cdn/soft-boom.svg +3 -3
  44. package/dist/cdn/soft-burst.svg +3 -3
  45. package/dist/cdn/square.svg +3 -3
  46. package/dist/cdn/sunny.svg +3 -3
  47. package/dist/cdn/triangle.svg +3 -3
  48. package/dist/cdn/very-sunny.svg +3 -3
  49. package/dist/cdn/wavy-circle.svg +3 -3
  50. package/dist/cdn/wavy.svg +4 -4
  51. package/index.d.ts +18 -18
  52. package/index.js +6 -6
  53. package/package.json +76 -76
  54. package/scoped/index.d.ts +18 -18
  55. package/scoped/index.js +6 -6
  56. package/src/cdn/beer.css +52 -52
  57. package/src/cdn/beer.ts +120 -120
  58. package/src/cdn/customElement.js +38 -38
  59. package/src/cdn/elements/badges.css +74 -74
  60. package/src/cdn/elements/bars.css +91 -91
  61. package/src/cdn/elements/buttons.css +106 -106
  62. package/src/cdn/elements/cards.css +26 -26
  63. package/src/cdn/elements/chips.css +38 -38
  64. package/src/cdn/elements/dialogs.css +151 -151
  65. package/src/cdn/elements/dialogs.ts +69 -69
  66. package/src/cdn/elements/dividers.css +48 -48
  67. package/src/cdn/elements/expansions.css +10 -10
  68. package/src/cdn/elements/fields.css +439 -439
  69. package/src/cdn/elements/fields.ts +165 -164
  70. package/src/cdn/elements/grids.css +171 -171
  71. package/src/cdn/elements/icons.css +77 -77
  72. package/src/cdn/elements/layouts.css +35 -35
  73. package/src/cdn/elements/lists.css +71 -71
  74. package/src/cdn/elements/mainLayouts.css +57 -57
  75. package/src/cdn/elements/media.css +112 -112
  76. package/src/cdn/elements/menus.css +294 -294
  77. package/src/cdn/elements/menus.ts +40 -40
  78. package/src/cdn/elements/navigations.css +462 -460
  79. package/src/cdn/elements/overlays.css +31 -31
  80. package/src/cdn/elements/pages.css +41 -41
  81. package/src/cdn/elements/pages.ts +6 -6
  82. package/src/cdn/elements/progress.css +207 -207
  83. package/src/cdn/elements/progress.ts +34 -34
  84. package/src/cdn/elements/selections.css +256 -256
  85. package/src/cdn/elements/shapes.css +258 -258
  86. package/src/cdn/elements/sliders.css +357 -357
  87. package/src/cdn/elements/sliders.ts +74 -74
  88. package/src/cdn/elements/snackbars.css +47 -47
  89. package/src/cdn/elements/snackbars.ts +26 -26
  90. package/src/cdn/elements/tables.css +65 -65
  91. package/src/cdn/elements/tabs.css +52 -52
  92. package/src/cdn/elements/tooltips.css +131 -131
  93. package/src/cdn/helpers/alignments.css +29 -29
  94. package/src/cdn/helpers/blurs.css +21 -21
  95. package/src/cdn/helpers/colors.css +930 -930
  96. package/src/cdn/helpers/directions.css +28 -28
  97. package/src/cdn/helpers/elevates.css +16 -16
  98. package/src/cdn/helpers/forms.css +75 -75
  99. package/src/cdn/helpers/margins.css +49 -49
  100. package/src/cdn/helpers/opacities.css +19 -19
  101. package/src/cdn/helpers/paddings.css +45 -45
  102. package/src/cdn/helpers/positions.css +45 -45
  103. package/src/cdn/helpers/reset.css +94 -93
  104. package/src/cdn/helpers/responsive.css +22 -22
  105. package/src/cdn/helpers/ripples.css +33 -33
  106. package/src/cdn/helpers/ripples.ts +30 -30
  107. package/src/cdn/helpers/scrolls.css +8 -8
  108. package/src/cdn/helpers/shadows.css +23 -23
  109. package/src/cdn/helpers/sizes.css +45 -45
  110. package/src/cdn/helpers/spaces.css +19 -19
  111. package/src/cdn/helpers/theme.css +186 -186
  112. package/src/cdn/helpers/theme.ts +83 -83
  113. package/src/cdn/helpers/typography.css +225 -225
  114. package/src/cdn/helpers/waves.css +43 -43
  115. package/src/cdn/helpers/zoom.css +19 -19
  116. package/src/cdn/interfaces.ts +3 -3
  117. package/src/cdn/settings/dark.css +38 -38
  118. package/src/cdn/settings/fonts.css +35 -35
  119. package/src/cdn/settings/globals.css +18 -18
  120. package/src/cdn/settings/light.css +39 -39
  121. package/src/cdn/shapes/arch.svg +3 -3
  122. package/src/cdn/shapes/arrow.svg +3 -3
  123. package/src/cdn/shapes/boom.svg +3 -3
  124. package/src/cdn/shapes/bun.svg +3 -3
  125. package/src/cdn/shapes/burst.svg +3 -3
  126. package/src/cdn/shapes/circle.svg +3 -3
  127. package/src/cdn/shapes/clamshell.svg +3 -3
  128. package/src/cdn/shapes/diamond.svg +3 -3
  129. package/src/cdn/shapes/fan.svg +3 -3
  130. package/src/cdn/shapes/flower.svg +3 -3
  131. package/src/cdn/shapes/gem.svg +3 -3
  132. package/src/cdn/shapes/ghost-ish.svg +3 -3
  133. package/src/cdn/shapes/heart.svg +3 -3
  134. package/src/cdn/shapes/leaf-clover4.svg +3 -3
  135. package/src/cdn/shapes/leaf-clover8.svg +3 -3
  136. package/src/cdn/shapes/loading-indicator.svg +18 -18
  137. package/src/cdn/shapes/oval.svg +3 -3
  138. package/src/cdn/shapes/pentagon.svg +3 -3
  139. package/src/cdn/shapes/pill.svg +3 -3
  140. package/src/cdn/shapes/pixel-circle.svg +3 -3
  141. package/src/cdn/shapes/pixel-triangle.svg +3 -3
  142. package/src/cdn/shapes/puffy-diamond.svg +3 -3
  143. package/src/cdn/shapes/puffy.svg +3 -3
  144. package/src/cdn/shapes/semicircle.svg +3 -3
  145. package/src/cdn/shapes/sided-cookie12.svg +3 -3
  146. package/src/cdn/shapes/sided-cookie4.svg +3 -3
  147. package/src/cdn/shapes/sided-cookie6.svg +3 -3
  148. package/src/cdn/shapes/sided-cookie7.svg +3 -3
  149. package/src/cdn/shapes/sided-cookie9.svg +3 -3
  150. package/src/cdn/shapes/slanted.svg +3 -3
  151. package/src/cdn/shapes/soft-boom.svg +3 -3
  152. package/src/cdn/shapes/soft-burst.svg +3 -3
  153. package/src/cdn/shapes/square.svg +3 -3
  154. package/src/cdn/shapes/sunny.svg +3 -3
  155. package/src/cdn/shapes/triangle.svg +3 -3
  156. package/src/cdn/shapes/very-sunny.svg +3 -3
  157. package/src/cdn/shapes/wavy-circle.svg +3 -3
  158. package/src/cdn/shapes/wavy.svg +4 -4
  159. package/src/cdn/utils.ts +154 -154
package/package.json CHANGED
@@ -1,76 +1,76 @@
1
- {
2
- "author": "Everton and Leonardo",
3
- "description": "Build material design interfaces in record time... without stress for devs.",
4
- "homepage": "https://www.beercss.com/",
5
- "version": "3.13.1",
6
- "name": "beercss",
7
- "license": "MIT",
8
- "type": "module",
9
- "scripts": {
10
- "lint": "npm run lint:ts && npm run lint:style",
11
- "lint:ts": "eslint . --ext .js,.ts,.vue --fix",
12
- "lint:style": "stylelint --fix \"src/**/*.css\"",
13
- "dev": "node ./build/dev.js",
14
- "build": "node ./build/build.js && node ./build/cdn.js",
15
- "test": "vitest",
16
- "generate-llms": "node ./build/generate-llms-md.js"
17
- },
18
- "devDependencies": {
19
- "@stylistic/stylelint-plugin": "^2.1.2",
20
- "@types/jsdom": "^21.1.7",
21
- "@typescript-eslint/eslint-plugin": "^7.11.0",
22
- "@typescript-eslint/parser": "^7.11.0",
23
- "@vitejs/plugin-vue": "^5.0.5",
24
- "@vue/eslint-config-typescript": "^13.0.0",
25
- "@vue/language-plugin-pug": "^2.2.10",
26
- "eslint": "^8.57.0",
27
- "eslint-config-love": "^52.0.0",
28
- "eslint-plugin-import": "^2.29.1",
29
- "eslint-plugin-n": "^17.7.0",
30
- "eslint-plugin-promise": "^6.2.0",
31
- "eslint-plugin-vue": "^9.26.0",
32
- "eslint-plugin-vue-pug": "^0.6.2",
33
- "fs-extra": "^11.2.0",
34
- "jsdom": "^24.1.3",
35
- "pug": "^3.0.3",
36
- "stylelint": "^16.6.1",
37
- "stylelint-config-standard-scss": "^13.1.0",
38
- "typescript": "^5.4.5",
39
- "vite": "^6.2.3",
40
- "vitest": "^3.0.9",
41
- "vue": "^3.4.27",
42
- "vue-eslint-parser": "^9.4.2",
43
- "vue-eslint-parser-template-tokenizer-pug": "^0.4.11",
44
- "vue-tsc": "^2.0.19"
45
- },
46
- "files": [
47
- "custom-element",
48
- "dist/cdn",
49
- "scoped",
50
- "src/cdn",
51
- "index.d.ts",
52
- "index.js"
53
- ],
54
- "keywords": [
55
- "css",
56
- "material",
57
- "semantic html",
58
- "design system",
59
- "material you",
60
- "material 3",
61
- "material design 3",
62
- "material 3 expressive",
63
- "class-light"
64
- ],
65
- "repository": {
66
- "type": "git",
67
- "url": "git+https://github.com/beercss/beercss.git"
68
- },
69
- "bugs": {
70
- "url": "https://github.com/beercss/beercss/issues"
71
- },
72
- "packageManager": "pnpm@9.1.4+sha512.9df9cf27c91715646c7d675d1c9c8e41f6fce88246f1318c1aa6a1ed1aeb3c4f032fcdf4ba63cc69c4fe6d634279176b5358727d8f2cc1e65b65f43ce2f8bfb0",
73
- "dependencies": {
74
- "material-dynamic-colors": "^1.1.2"
75
- }
76
- }
1
+ {
2
+ "author": "Everton and Leonardo",
3
+ "description": "Build material design interfaces in record time... without stress for devs.",
4
+ "homepage": "https://www.beercss.com/",
5
+ "version": "3.13.2",
6
+ "name": "beercss",
7
+ "license": "MIT",
8
+ "type": "module",
9
+ "scripts": {
10
+ "lint": "npm run lint:ts && npm run lint:style",
11
+ "lint:ts": "eslint . --ext .js,.ts,.vue --fix",
12
+ "lint:style": "stylelint --fix \"src/**/*.css\"",
13
+ "dev": "node ./build/dev.js",
14
+ "build": "node ./build/build.js && node ./build/cdn.js",
15
+ "test": "vitest",
16
+ "llms": "node ./build/llms.js"
17
+ },
18
+ "devDependencies": {
19
+ "@stylistic/stylelint-plugin": "^2.1.2",
20
+ "@types/jsdom": "^21.1.7",
21
+ "@typescript-eslint/eslint-plugin": "^7.11.0",
22
+ "@typescript-eslint/parser": "^7.11.0",
23
+ "@vitejs/plugin-vue": "^5.0.5",
24
+ "@vue/eslint-config-typescript": "^13.0.0",
25
+ "@vue/language-plugin-pug": "^2.2.10",
26
+ "eslint": "^8.57.0",
27
+ "eslint-config-love": "^52.0.0",
28
+ "eslint-plugin-import": "^2.29.1",
29
+ "eslint-plugin-n": "^17.7.0",
30
+ "eslint-plugin-promise": "^6.2.0",
31
+ "eslint-plugin-vue": "^9.26.0",
32
+ "eslint-plugin-vue-pug": "^0.6.2",
33
+ "fs-extra": "^11.2.0",
34
+ "jsdom": "^24.1.3",
35
+ "pug": "^3.0.3",
36
+ "stylelint": "^16.6.1",
37
+ "stylelint-config-standard-scss": "^13.1.0",
38
+ "typescript": "^5.4.5",
39
+ "vite": "^6.2.3",
40
+ "vitest": "^3.0.9",
41
+ "vue": "^3.4.27",
42
+ "vue-eslint-parser": "^9.4.2",
43
+ "vue-eslint-parser-template-tokenizer-pug": "^0.4.11",
44
+ "vue-tsc": "^2.0.19"
45
+ },
46
+ "files": [
47
+ "custom-element",
48
+ "dist/cdn",
49
+ "scoped",
50
+ "src/cdn",
51
+ "index.d.ts",
52
+ "index.js"
53
+ ],
54
+ "keywords": [
55
+ "css",
56
+ "material",
57
+ "semantic html",
58
+ "design system",
59
+ "material you",
60
+ "material 3",
61
+ "material design 3",
62
+ "material 3 expressive",
63
+ "class-light"
64
+ ],
65
+ "repository": {
66
+ "type": "git",
67
+ "url": "git+https://github.com/beercss/beercss.git"
68
+ },
69
+ "bugs": {
70
+ "url": "https://github.com/beercss/beercss/issues"
71
+ },
72
+ "packageManager": "pnpm@9.1.4+sha512.9df9cf27c91715646c7d675d1c9c8e41f6fce88246f1318c1aa6a1ed1aeb3c4f032fcdf4ba63cc69c4fe6d634279176b5358727d8f2cc1e65b65f43ce2f8bfb0",
73
+ "dependencies": {
74
+ "material-dynamic-colors": "^1.1.2"
75
+ }
76
+ }
package/scoped/index.d.ts CHANGED
@@ -1,19 +1,19 @@
1
- declare global {
2
- interface IBeerCssTheme {
3
- dark: string,
4
- light: string,
5
- }
6
-
7
- function ui(selector?: string | Element, options?: string | number | IBeerCssTheme): string | IBeerCssTheme | Promise<IBeerCssTheme>;
8
- }
9
-
10
- declare module "ui";
11
-
12
- export interface IBeerCssTheme {
13
- dark: string,
14
- light: string,
15
- }
16
-
17
- export function ui(selector?: string | Element, options?: string | number | IBeerCssTheme): string | IBeerCssTheme | Promise<IBeerCssTheme>;
18
-
1
+ declare global {
2
+ interface IBeerCssTheme {
3
+ dark: string,
4
+ light: string,
5
+ }
6
+
7
+ function ui(selector?: string | Element, options?: string | number | IBeerCssTheme): string | IBeerCssTheme | Promise<IBeerCssTheme>;
8
+ }
9
+
10
+ declare module "ui";
11
+
12
+ export interface IBeerCssTheme {
13
+ dark: string,
14
+ light: string,
15
+ }
16
+
17
+ export function ui(selector?: string | Element, options?: string | number | IBeerCssTheme): string | IBeerCssTheme | Promise<IBeerCssTheme>;
18
+
19
19
  export default ui;
package/scoped/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import "../dist/cdn/beer.scoped.min.css";
2
- import { ui } from "../dist/cdn/beer.min.js";
3
- export {
4
- ui as default,
5
- ui,
6
- };
1
+ import "../dist/cdn/beer.scoped.min.css";
2
+ import { ui } from "../dist/cdn/beer.min.js";
3
+ export {
4
+ ui as default,
5
+ ui,
6
+ };
package/src/cdn/beer.css CHANGED
@@ -1,52 +1,52 @@
1
- @import "./settings/globals.css";
2
- @import "./settings/light.css";
3
- @import "./settings/dark.css";
4
- @import "./settings/fonts.css";
5
- @import "./helpers/reset.css";
6
- @import "./helpers/theme.css";
7
- @import "./helpers/alignments.css";
8
- @import "./helpers/blurs.css";
9
- @import "./helpers/colors.css";
10
- @import "./helpers/directions.css";
11
- @import "./helpers/elevates.css";
12
- @import "./helpers/forms.css";
13
- @import "./helpers/margins.css";
14
- @import "./helpers/opacities.css";
15
- @import "./helpers/paddings.css";
16
- @import "./helpers/positions.css";
17
- @import "./helpers/ripples.css";
18
- @import "./helpers/scrolls.css";
19
- @import "./helpers/shadows.css";
20
- @import "./helpers/sizes.css";
21
- @import "./helpers/spaces.css";
22
- @import "./helpers/responsive.css";
23
- @import "./helpers/typography.css";
24
- @import "./helpers/waves.css";
25
- @import "./helpers/zoom.css";
26
- @import "./elements/badges.css";
27
- @import "./elements/bars.css";
28
- @import "./elements/buttons.css";
29
- @import "./elements/cards.css";
30
- @import "./elements/chips.css";
31
- @import "./elements/dialogs.css";
32
- @import "./elements/dividers.css";
33
- @import "./elements/expansions.css";
34
- @import "./elements/fields.css";
35
- @import "./elements/grids.css";
36
- @import "./elements/icons.css";
37
- @import "./elements/layouts.css";
38
- @import "./elements/lists.css";
39
- @import "./elements/mainLayouts.css";
40
- @import "./elements/media.css";
41
- @import "./elements/menus.css";
42
- @import "./elements/navigations.css";
43
- @import "./elements/overlays.css";
44
- @import "./elements/pages.css";
45
- @import "./elements/progress.css";
46
- @import "./elements/shapes.css";
47
- @import "./elements/selections.css";
48
- @import "./elements/sliders.css";
49
- @import "./elements/snackbars.css";
50
- @import "./elements/tables.css";
51
- @import "./elements/tabs.css";
52
- @import "./elements/tooltips.css";
1
+ @import "./settings/globals.css";
2
+ @import "./settings/light.css";
3
+ @import "./settings/dark.css";
4
+ @import "./settings/fonts.css";
5
+ @import "./helpers/reset.css";
6
+ @import "./helpers/theme.css";
7
+ @import "./helpers/alignments.css";
8
+ @import "./helpers/blurs.css";
9
+ @import "./helpers/colors.css";
10
+ @import "./helpers/directions.css";
11
+ @import "./helpers/elevates.css";
12
+ @import "./helpers/forms.css";
13
+ @import "./helpers/margins.css";
14
+ @import "./helpers/opacities.css";
15
+ @import "./helpers/paddings.css";
16
+ @import "./helpers/positions.css";
17
+ @import "./helpers/ripples.css";
18
+ @import "./helpers/scrolls.css";
19
+ @import "./helpers/shadows.css";
20
+ @import "./helpers/sizes.css";
21
+ @import "./helpers/spaces.css";
22
+ @import "./helpers/responsive.css";
23
+ @import "./helpers/typography.css";
24
+ @import "./helpers/waves.css";
25
+ @import "./helpers/zoom.css";
26
+ @import "./elements/badges.css";
27
+ @import "./elements/bars.css";
28
+ @import "./elements/buttons.css";
29
+ @import "./elements/cards.css";
30
+ @import "./elements/chips.css";
31
+ @import "./elements/dialogs.css";
32
+ @import "./elements/dividers.css";
33
+ @import "./elements/expansions.css";
34
+ @import "./elements/fields.css";
35
+ @import "./elements/grids.css";
36
+ @import "./elements/icons.css";
37
+ @import "./elements/layouts.css";
38
+ @import "./elements/lists.css";
39
+ @import "./elements/mainLayouts.css";
40
+ @import "./elements/media.css";
41
+ @import "./elements/menus.css";
42
+ @import "./elements/navigations.css";
43
+ @import "./elements/overlays.css";
44
+ @import "./elements/pages.css";
45
+ @import "./elements/progress.css";
46
+ @import "./elements/shapes.css";
47
+ @import "./elements/selections.css";
48
+ @import "./elements/sliders.css";
49
+ @import "./elements/snackbars.css";
50
+ @import "./elements/tables.css";
51
+ @import "./elements/tabs.css";
52
+ @import "./elements/tooltips.css";
package/src/cdn/beer.ts CHANGED
@@ -1,120 +1,120 @@
1
- import {updateAllFields} from "./elements/fields";
2
- import {updateAllSliders} from "./elements/sliders";
3
- import {updateMode, updateTheme} from "./helpers/theme";
4
- import {type IBeerCssTheme} from "./interfaces";
5
- import {addClass, guid, hasClass, hasTag, onWeak, query, queryAll, removeClass, updateAllClickable} from "./utils";
6
- import {updateDialog} from "./elements/dialogs";
7
- import {updateMenu} from "./elements/menus";
8
- import {updateSnackbar} from "./elements/snackbars";
9
- import {updatePage} from "./elements/pages";
10
- import {updateAllRipples} from "./helpers/ripples";
11
- import { updateAllProgress } from "./elements/progress";
12
-
13
- const _context = globalThis as any;
14
- let _timeoutMutation: ReturnType<typeof setTimeout>;
15
- let _mutation: MutationObserver | null;
16
-
17
- function onMutation() {
18
- if (_timeoutMutation) clearTimeout(_timeoutMutation);
19
- _timeoutMutation = setTimeout(async () => await _ui(), 180);
20
- }
21
-
22
- async function run(from: Element, to: Element | null, options?: any, e?: Event): Promise<void> {
23
- if (!to) {
24
- to = query(from.getAttribute("data-ui"));
25
- if (!to) {
26
- from.classList.toggle("active");
27
- return;
28
- }
29
- }
30
-
31
- updateAllClickable(from);
32
-
33
- if (hasTag(to, "dialog")) {
34
- await updateDialog(from, to as HTMLDialogElement);
35
- return;
36
- }
37
-
38
- if (hasTag(to, "menu")) {
39
- updateMenu(from, to as HTMLMenuElement, e);
40
- return;
41
- }
42
-
43
- if (hasClass(to, "snackbar")) {
44
- updateSnackbar(to, options as number);
45
- return;
46
- }
47
-
48
- if (hasClass(to, "page")) {
49
- updatePage(to);
50
- return;
51
- }
52
-
53
- if (hasClass(to, "active")) {
54
- removeClass(from, "active");
55
- removeClass(to, "active");
56
- return;
57
- }
58
-
59
- addClass(to, "active");
60
- }
61
-
62
- function onClickElement(e: Event) {
63
- void run(e.currentTarget as HTMLElement, null, null, e);
64
- }
65
-
66
- function onKeydownElement(e: KeyboardEvent) {
67
- if (e.key === "Enter") void run(e.currentTarget as HTMLElement, null, null, e);
68
- }
69
-
70
- function setup() {
71
- if (_context.ui || _mutation || !_context.MutationObserver) return;
72
- _mutation = new MutationObserver(onMutation);
73
- _mutation.observe(document.body, { childList: true, subtree: true });
74
- onMutation();
75
- }
76
-
77
- function updateAllDataUis() {
78
- const elements = queryAll("[data-ui]");
79
- for (let i = 0, n = elements.length; i < n; i++) {
80
- onWeak(elements[i], "click", onClickElement);
81
- if (hasTag(elements[i], "a") && !elements[i].getAttribute("href")) onWeak(elements[i], "keydown", onKeydownElement);
82
- }
83
- }
84
-
85
- function _ui(selector?: string | Element, options?: string | number | IBeerCssTheme): string | IBeerCssTheme | Promise<IBeerCssTheme> | undefined {
86
- if (selector) {
87
- if (selector === "setup") { setup(); return; }
88
- if (selector === "guid") return guid();
89
- if (selector === "mode") return updateMode(options as string);
90
- if (selector === "theme") return updateTheme(options);
91
-
92
- const to = query(selector);
93
- if (!to) return;
94
- void run(to, to, options);
95
- }
96
-
97
- updateAllDataUis();
98
- updateAllFields();
99
- updateAllSliders();
100
- updateAllRipples();
101
- updateAllProgress();
102
- }
103
-
104
- function start() {
105
- if (_context.ui) return;
106
-
107
- const body = _context.document?.body;
108
- if (body && !body.classList.contains("dark") && !body.classList.contains("light")) updateMode("auto");
109
-
110
- setup();
111
- _context.ui = _ui;
112
- }
113
-
114
- start();
115
-
116
- const ui = _context.ui;
117
- export {
118
- ui as default,
119
- ui,
120
- };
1
+ import {updateAllFields} from "./elements/fields";
2
+ import {updateAllSliders} from "./elements/sliders";
3
+ import {updateMode, updateTheme} from "./helpers/theme";
4
+ import {type IBeerCssTheme} from "./interfaces";
5
+ import {addClass, guid, hasClass, hasTag, onWeak, query, queryAll, removeClass, updateAllClickable} from "./utils";
6
+ import {updateDialog} from "./elements/dialogs";
7
+ import {updateMenu} from "./elements/menus";
8
+ import {updateSnackbar} from "./elements/snackbars";
9
+ import {updatePage} from "./elements/pages";
10
+ import {updateAllRipples} from "./helpers/ripples";
11
+ import { updateAllProgress } from "./elements/progress";
12
+
13
+ const _context = globalThis as any;
14
+ let _timeoutMutation: ReturnType<typeof setTimeout>;
15
+ let _mutation: MutationObserver | null;
16
+
17
+ function onMutation() {
18
+ if (_timeoutMutation) clearTimeout(_timeoutMutation);
19
+ _timeoutMutation = setTimeout(async () => await _ui(), 180);
20
+ }
21
+
22
+ async function run(from: Element, to: Element | null, options?: any, e?: Event): Promise<void> {
23
+ if (!to) {
24
+ to = query(from.getAttribute("data-ui"));
25
+ if (!to) {
26
+ from.classList.toggle("active");
27
+ return;
28
+ }
29
+ }
30
+
31
+ updateAllClickable(from);
32
+
33
+ if (hasTag(to, "dialog")) {
34
+ await updateDialog(from, to as HTMLDialogElement);
35
+ return;
36
+ }
37
+
38
+ if (hasTag(to, "menu")) {
39
+ updateMenu(from, to as HTMLMenuElement, e);
40
+ return;
41
+ }
42
+
43
+ if (hasClass(to, "snackbar")) {
44
+ updateSnackbar(to, options as number);
45
+ return;
46
+ }
47
+
48
+ if (hasClass(to, "page")) {
49
+ updatePage(to);
50
+ return;
51
+ }
52
+
53
+ if (hasClass(to, "active")) {
54
+ removeClass(from, "active");
55
+ removeClass(to, "active");
56
+ return;
57
+ }
58
+
59
+ addClass(to, "active");
60
+ }
61
+
62
+ function onClickElement(e: Event) {
63
+ void run(e.currentTarget as HTMLElement, null, null, e);
64
+ }
65
+
66
+ function onKeydownElement(e: KeyboardEvent) {
67
+ if (e.key === "Enter") void run(e.currentTarget as HTMLElement, null, null, e);
68
+ }
69
+
70
+ function setup() {
71
+ if (_context.ui || _mutation || !_context.MutationObserver) return;
72
+ _mutation = new MutationObserver(onMutation);
73
+ _mutation.observe(document.body, { childList: true, subtree: true });
74
+ onMutation();
75
+ }
76
+
77
+ function updateAllDataUis() {
78
+ const elements = queryAll("[data-ui]");
79
+ for (let i = 0, n = elements.length; i < n; i++) {
80
+ onWeak(elements[i], "click", onClickElement);
81
+ if (hasTag(elements[i], "a") && !elements[i].getAttribute("href")) onWeak(elements[i], "keydown", onKeydownElement);
82
+ }
83
+ }
84
+
85
+ function _ui(selector?: string | Element, options?: string | number | IBeerCssTheme): string | IBeerCssTheme | Promise<IBeerCssTheme> | undefined {
86
+ if (selector) {
87
+ if (selector === "setup") { setup(); return; }
88
+ if (selector === "guid") return guid();
89
+ if (selector === "mode") return updateMode(options as string);
90
+ if (selector === "theme") return updateTheme(options);
91
+
92
+ const to = query(selector);
93
+ if (!to) return;
94
+ void run(to, to, options);
95
+ }
96
+
97
+ updateAllDataUis();
98
+ updateAllFields();
99
+ updateAllSliders();
100
+ updateAllRipples();
101
+ updateAllProgress();
102
+ }
103
+
104
+ function start() {
105
+ if (_context.ui) return;
106
+
107
+ const body = _context.document?.body;
108
+ if (body && !body.classList.contains("dark") && !body.classList.contains("light")) updateMode("auto");
109
+
110
+ setup();
111
+ _context.ui = _ui;
112
+ }
113
+
114
+ start();
115
+
116
+ const ui = _context.ui;
117
+ export {
118
+ ui as default,
119
+ ui,
120
+ };
@@ -1,39 +1,39 @@
1
- class BeerCssCustomElement extends HTMLElement {
2
- static isCssLoaded = false;
3
- static isJsLoaded = false;
4
-
5
- constructor() {
6
- super();
7
- this.run();
8
- }
9
-
10
- async addJs() {
11
- if (BeerCssCustomElement.isJsLoaded) return;
12
- BeerCssCustomElement.isJsLoaded = true;
13
-
14
- if (window.ui) return;
15
- return await import("https://cdn.jsdelivr.net/npm/beercss@3.13.1/dist/cdn/beer.min.js");
16
- }
17
-
18
- async addCss() {
19
- if (BeerCssCustomElement.isCssLoaded) return;
20
- BeerCssCustomElement.isCssLoaded = true;
21
- const isScoped = !!getComputedStyle(document.documentElement).getPropertyValue("--scoped");
22
- if (isScoped) return;
23
-
24
- const head = document.querySelector("head");
25
- const element = document.createElement("link");
26
- element.setAttribute("href", "https://cdn.jsdelivr.net/npm/beercss@3.13.1/dist/cdn/beer.scoped.min.css");
27
- element.setAttribute("rel", "stylesheet");
28
- head.appendChild(element);
29
- }
30
-
31
- async run() {
32
- this.classList.add("beer");
33
- await Promise.all([this.addJs(), this.addCss()]);
34
- ui();
35
- }
36
- }
37
-
38
- customElements.define("beer-css", BeerCssCustomElement);
1
+ class BeerCssCustomElement extends HTMLElement {
2
+ static isCssLoaded = false;
3
+ static isJsLoaded = false;
4
+
5
+ constructor() {
6
+ super();
7
+ this.run();
8
+ }
9
+
10
+ async addJs() {
11
+ if (BeerCssCustomElement.isJsLoaded) return;
12
+ BeerCssCustomElement.isJsLoaded = true;
13
+
14
+ if (window.ui) return;
15
+ return await import("https://cdn.jsdelivr.net/npm/beercss@3.13.2/dist/cdn/beer.min.js");
16
+ }
17
+
18
+ async addCss() {
19
+ if (BeerCssCustomElement.isCssLoaded) return;
20
+ BeerCssCustomElement.isCssLoaded = true;
21
+ const isScoped = !!getComputedStyle(document.documentElement).getPropertyValue("--scoped");
22
+ if (isScoped) return;
23
+
24
+ const head = document.querySelector("head");
25
+ const element = document.createElement("link");
26
+ element.setAttribute("href", "https://cdn.jsdelivr.net/npm/beercss@3.13.2/dist/cdn/beer.scoped.min.css");
27
+ element.setAttribute("rel", "stylesheet");
28
+ head.appendChild(element);
29
+ }
30
+
31
+ async run() {
32
+ this.classList.add("beer");
33
+ await Promise.all([this.addJs(), this.addCss()]);
34
+ ui();
35
+ }
36
+ }
37
+
38
+ customElements.define("beer-css", BeerCssCustomElement);
39
39
  export default BeerCssCustomElement;