ranui 0.2.0-alpha.2 → 0.2.0-alpha.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 (102) hide show
  1. package/dist/builder.js +1 -1
  2. package/dist/{button-BstLjXNe.js → button-CJFSrjq_.js} +10 -10
  3. package/dist/button.js +1 -1
  4. package/dist/card-F-3fRynz.js +67 -0
  5. package/dist/card.js +1 -1
  6. package/dist/{checkbox-iHZQb-yQ.js → checkbox-BS5kNY6n.js} +9 -9
  7. package/dist/checkbox.js +1 -1
  8. package/dist/{colorpicker-CGh8pRqo.js → colorpicker-CdzUAVC5.js} +11 -11
  9. package/dist/colorpicker.js +1 -1
  10. package/dist/components/button/index.d.ts +1 -1
  11. package/dist/components/card/index.d.ts +3 -0
  12. package/dist/components/theme-switch/index.d.ts +36 -0
  13. package/dist/{dropdown-RqHMRhFE.js → dropdown-BYS1Trdu.js} +9 -9
  14. package/dist/dropdown.js +1 -1
  15. package/dist/fonts/Geist-Variable.woff2 +0 -0
  16. package/dist/fonts/GeistMono-Variable.woff2 +0 -0
  17. package/dist/fonts/OFL-LICENSE.txt +92 -0
  18. package/dist/fonts/fonts.css +26 -0
  19. package/dist/{form-05Lxxl3D.js → form-BsB5JhS4.js} +9 -9
  20. package/dist/form.js +1 -1
  21. package/dist/{icon-Blm7AbyY.js → icon-pfolda2m.js} +3 -3
  22. package/dist/icon.js +1 -1
  23. package/dist/iife/button.iife.js +1 -1
  24. package/dist/iife/card.iife.js +1 -1
  25. package/dist/iife/checkbox.iife.js +1 -1
  26. package/dist/iife/colorpicker.iife.js +2 -2
  27. package/dist/iife/dropdown.iife.js +1 -1
  28. package/dist/iife/form.iife.js +1 -1
  29. package/dist/iife/icon.iife.js +1 -1
  30. package/dist/iife/image.iife.js +1 -1
  31. package/dist/iife/input.iife.js +1 -1
  32. package/dist/iife/link.iife.js +1 -1
  33. package/dist/iife/loading.iife.js +1 -1
  34. package/dist/iife/math.iife.js +14 -14
  35. package/dist/iife/message.iife.js +1 -1
  36. package/dist/iife/modal.iife.js +1 -1
  37. package/dist/iife/player.iife.js +9 -9
  38. package/dist/iife/popover.iife.js +1 -1
  39. package/dist/iife/progress.iife.js +1 -1
  40. package/dist/iife/radar.iife.js +1 -1
  41. package/dist/iife/route.iife.js +1 -1
  42. package/dist/iife/router.iife.js +1 -1
  43. package/dist/iife/scratch.iife.js +1 -1
  44. package/dist/iife/section.iife.js +1 -1
  45. package/dist/iife/select.iife.js +2 -2
  46. package/dist/iife/skeleton.iife.js +1 -1
  47. package/dist/iife/tab.iife.js +1 -1
  48. package/dist/iife/tabpane.iife.js +1 -1
  49. package/dist/iife/theme-switch.iife.js +1 -0
  50. package/dist/{image-DKm6z7YQ.js → image-BXpKQ9sU.js} +9 -9
  51. package/dist/image.js +1 -1
  52. package/dist/index.cjs +23 -23
  53. package/dist/index.d.ts +4 -0
  54. package/dist/index.iife.js +67 -78
  55. package/dist/index.js +73 -72
  56. package/dist/{input-Dskw1bAl.js → input-BM6e_LQr.js} +13 -13
  57. package/dist/input.js +1 -1
  58. package/dist/{link-BW-gvrpN.js → link-DURZzd7u.js} +7 -7
  59. package/dist/link.js +1 -1
  60. package/dist/{loading-C4QUpm70.js → loading-Bd-gF1AH.js} +24 -24
  61. package/dist/loading.js +1 -1
  62. package/dist/{math-Dv4nXSoI.js → math-IjzOAwnA.js} +7 -7
  63. package/dist/math.js +1 -1
  64. package/dist/{message-De5e1txT.js → message-CLpuP8HY.js} +8 -8
  65. package/dist/message.js +1 -1
  66. package/dist/{modal-DruDj3AB.js → modal-DOTpABRe.js} +7 -7
  67. package/dist/modal.js +1 -1
  68. package/dist/{player-CqTAmg_E.js → player-C2pB5L2N.js} +7 -7
  69. package/dist/player.js +1 -1
  70. package/dist/{popover-BY32HNMl.js → popover-DRUQjdPs.js} +10 -10
  71. package/dist/popover.js +1 -1
  72. package/dist/{progress-gZo0knzu.js → progress-BIEXYYd2.js} +6 -6
  73. package/dist/progress.js +1 -1
  74. package/dist/{radar-19P5Mtld.js → radar-DAF95_Mj.js} +9 -9
  75. package/dist/radar.js +1 -1
  76. package/dist/ranui.css +1 -1
  77. package/dist/{route-BY_E6-2C.js → route-MQZpn2BP.js} +14 -14
  78. package/dist/route.js +1 -1
  79. package/dist/{router-BDcv4F-2.js → router-B9rCrWXm.js} +5 -5
  80. package/dist/router.js +1 -1
  81. package/dist/{scratch-Dbd9G6Q6.js → scratch-QlPyy1f4.js} +1 -1
  82. package/dist/scratch.js +1 -1
  83. package/dist/{section-CNTvgdQ-.js → section-D0qMm9KM.js} +8 -8
  84. package/dist/section.js +1 -1
  85. package/dist/{select-BVdUtQX5.js → select-BSeCT9tF.js} +13 -13
  86. package/dist/select.js +1 -1
  87. package/dist/{signal-XHfNsQNW.js → signal-CSSZxlK5.js} +1 -1
  88. package/dist/{skeleton-BAdJ6vyA.js → skeleton-CFqQmKyt.js} +8 -8
  89. package/dist/skeleton.js +1 -1
  90. package/dist/{tab-DH2owP2V.js → tab-CqFrgo2v.js} +5 -5
  91. package/dist/tab.js +1 -1
  92. package/dist/{tabpane-B_M-Jokw.js → tabpane-B-m3xwqu.js} +7 -7
  93. package/dist/tabpane.js +1 -1
  94. package/dist/test/unit/theme-switch.contract.test.d.ts +1 -0
  95. package/dist/theme-switch-B8K9y2RL.js +170 -0
  96. package/dist/theme-switch.js +5 -0
  97. package/dist/{utils-D4pPF77E.js → utils-DBfrRFoE.js} +116 -198
  98. package/docs/COMPONENTS.md +21 -5
  99. package/docs/DESIGN.md +24 -19
  100. package/docs/style-tokens-public.md +55 -8
  101. package/package.json +16 -10
  102. package/dist/card-DQUJoDUQ.js +0 -60
@@ -1,5 +1,5 @@
1
- import { c as s, d as r, s as a, u as h } from "./utils-D4pPF77E.js";
2
- import { t as n } from "./events-C59wGdni.js";
1
+ import { a as s, i as r, n as a, t as n } from "./utils-DBfrRFoE.js";
2
+ import { t as h } from "./events-C59wGdni.js";
3
3
  import { p as o } from "./factory-BdsO0dEW.js";
4
4
  import { a as b, n as c } from "./ssr-DSGwPtEd.js";
5
5
  var u = ".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}", d = class extends c {
@@ -14,13 +14,13 @@ var u = ".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transpar
14
14
  "sheet"
15
15
  ];
16
16
  }
17
- _events = new n();
17
+ _events = new h();
18
18
  _div;
19
19
  parent;
20
20
  _shadowDom;
21
21
  constructor() {
22
- super(), this._shadowDom = s(this, u);
23
- const t = a(this._shadowDom, "slot", () => o().part("content").build());
22
+ super(), this._shadowDom = a(this, u);
23
+ const t = n(this._shadowDom, "slot", () => o().part("content").build());
24
24
  this._div = t;
25
25
  }
26
26
  get label() {
@@ -63,10 +63,10 @@ var u = ".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transpar
63
63
  return this.getAttribute("sheet");
64
64
  }
65
65
  set sheet(t) {
66
- h(this, "sheet", t);
66
+ r(this, "sheet", t);
67
67
  }
68
68
  handlerExternalCss = () => {
69
- r(this, this._shadowDom, "sheet", null, this.sheet);
69
+ s(this, this._shadowDom, "sheet", null, this.sheet);
70
70
  };
71
71
  initAttribute = () => {
72
72
  this.parent = this.parentNode, this.key && (this.parent?.updateAttribute(this.key, "icon", this.icon), this.parent?.updateAttribute(this.key, "iconSize", this.iconSize), this.parent?.updateAttribute(this.key, "effect", this.effect));
package/dist/tabpane.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t } from "./tabpane-B_M-Jokw.js";
1
+ import { t } from "./tabpane-B-m3xwqu.js";
2
2
  export {
3
3
  t as TabPane,
4
4
  t as default
@@ -0,0 +1 @@
1
+ import '@/components/theme-switch';
@@ -0,0 +1,170 @@
1
+ import { a as u, i as m, n as b, r as v, t as f } from "./utils-DBfrRFoE.js";
2
+ import { t as g } from "./events-C59wGdni.js";
3
+ import { a as p, n as w } from "./ssr-DSGwPtEd.js";
4
+ var i = "ran-theme", a = null, s = null, o = (e) => {
5
+ if (e && "style" in e) return e;
6
+ if (e && "documentElement" in e) return e.documentElement;
7
+ if (!(typeof document > "u"))
8
+ return document.documentElement;
9
+ }, l = (e) => {
10
+ const t = typeof window < "u" && window.matchMedia("(prefers-color-scheme: dark)").matches;
11
+ e.setAttribute("data-ran-theme", t ? "dark" : "light"), e.setAttribute("theme", t ? "dark" : "light");
12
+ }, y = () => {
13
+ a && s && (a.removeEventListener("change", s), a = null, s = null);
14
+ }, d = (e, t) => {
15
+ const r = o(t);
16
+ if (r) {
17
+ if (y(), e === "system") {
18
+ if (typeof window > "u") return;
19
+ l(r), a = window.matchMedia("(prefers-color-scheme: dark)"), s = () => l(r), a.addEventListener("change", s);
20
+ try {
21
+ localStorage.setItem(i, "system");
22
+ } catch {
23
+ }
24
+ return;
25
+ }
26
+ r.setAttribute("data-ran-theme", e), r.setAttribute("theme", e);
27
+ try {
28
+ localStorage.setItem(i, e);
29
+ } catch {
30
+ }
31
+ }
32
+ }, k = (e) => {
33
+ const t = o(e);
34
+ if (!t) return "";
35
+ const r = t.getAttribute("data-ran-theme") || t.getAttribute("theme") || "";
36
+ if (r === "light" || r === "dark") {
37
+ try {
38
+ if (localStorage.getItem(i) === "system") return "system";
39
+ } catch {
40
+ }
41
+ return r;
42
+ }
43
+ return "";
44
+ }, _ = (e, t, r) => {
45
+ const n = o(r);
46
+ n && n.style.setProperty(e, String(t));
47
+ }, x = (e, t) => {
48
+ const r = o(t);
49
+ r && r.style.removeProperty(e);
50
+ }, L = (e, t) => {
51
+ Object.entries(e).forEach(([r, n]) => {
52
+ if (n == null) {
53
+ x(r, t);
54
+ return;
55
+ }
56
+ _(r, n, t);
57
+ });
58
+ }, z = (e) => {
59
+ if (!(typeof localStorage > "u"))
60
+ try {
61
+ const t = localStorage.getItem(i);
62
+ (t === "light" || t === "dark" || t === "system") && d(t, e);
63
+ } catch {
64
+ }
65
+ }, E = ".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{display:var(--ran-theme-switch-display, inline-flex);box-sizing:border-box}.ran-theme-switch{display:inline-flex;align-items:center;gap:var(--ran-theme-switch-gap, 2px);padding:var(--ran-theme-switch-padding, 2px);border-width:var(--ran-skin-border-width, 1px);border-style:var(--ran-skin-border-style, solid);border-color:var(--ran-theme-switch-border-color, var(--ran-color-border, #eaeaea));border-radius:var(--ran-theme-switch-radius, var(--ran-radius-full, 9999px));background:var(--ran-theme-switch-background, transparent);box-sizing:border-box}.ran-theme-switch button{width:var(--ran-theme-switch-button-size, 28px);height:var(--ran-theme-switch-button-size, 28px);display:grid;place-items:center;border:none;border-radius:var(--ran-theme-switch-radius, var(--ran-radius-full, 9999px));background:transparent;color:var(--ran-theme-switch-color, var(--ran-color-text-secondary, #4d4d4d));cursor:pointer;padding:0;transition:color var(--ran-motion-duration-fast, .15s) ease}.ran-theme-switch button:hover{color:var(--ran-theme-switch-hover-color, var(--ran-color-text, #171717))}.ran-theme-switch button[aria-pressed=true]{background:var(--ran-theme-switch-active-background, var(--ran-color-bg-hover, #ebebeb));color:var(--ran-theme-switch-active-color, var(--ran-color-text, #171717))}.ran-theme-switch button:focus-visible{outline:var(--ran-theme-switch-focus-outline, 2px solid var(--ran-color-primary, #006bff));outline-offset:2px}.ran-theme-switch svg{width:var(--ran-theme-switch-icon-size, 16px);height:var(--ran-theme-switch-icon-size, 16px)}", h = [
66
+ "system",
67
+ "light",
68
+ "dark"
69
+ ], S = {
70
+ system: '<svg viewBox="0 0 16 16" aria-hidden="true"><rect x="1.5" y="2.5" width="13" height="9" rx="1.5" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M5.5 14h5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',
71
+ light: '<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="3" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M8 1v1.8M8 13.2V15M15 8h-1.8M2.8 8H1m11.4-4.4-1.3 1.3M4.9 11.1l-1.3 1.3m9.8 0-1.3-1.3M4.9 4.9 3.6 3.6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',
72
+ dark: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M13.5 9.5A6 6 0 0 1 6.5 2.5a6 6 0 1 0 7 7z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>'
73
+ }, c = "ran-theme-switch-sync", A = class extends w {
74
+ static get observedAttributes() {
75
+ return [
76
+ "label-system",
77
+ "label-light",
78
+ "label-dark",
79
+ "sheet"
80
+ ];
81
+ }
82
+ _events = new g();
83
+ _shadowDom;
84
+ _group;
85
+ constructor() {
86
+ super(), this._shadowDom = b(this, E), this._group = f(this._shadowDom, ".ran-theme-switch", () => {
87
+ const e = document.createElement("div");
88
+ e.className = "ran-theme-switch", e.setAttribute("part", "switch"), e.setAttribute("role", "group");
89
+ for (const t of h) {
90
+ const r = document.createElement("button");
91
+ r.type = "button", r.dataset.choice = t, r.setAttribute("part", `button ${t}`), r.setAttribute("aria-pressed", "false"), r.innerHTML = S[t], e.appendChild(r);
92
+ }
93
+ return e;
94
+ });
95
+ }
96
+ get sheet() {
97
+ return v(this, "sheet");
98
+ }
99
+ set sheet(e) {
100
+ m(this, "sheet", e);
101
+ }
102
+ get value() {
103
+ return k() || "system";
104
+ }
105
+ set value(e) {
106
+ h.includes(e) && this._select(e);
107
+ }
108
+ _label(e) {
109
+ const t = {
110
+ system: "System theme",
111
+ light: "Light theme",
112
+ dark: "Dark theme"
113
+ }[e];
114
+ return this.getAttribute(`label-${e}`) || t;
115
+ }
116
+ _syncLabels() {
117
+ this._group.setAttribute("aria-label", this.getAttribute("label") || "Theme");
118
+ for (const e of this._group.querySelectorAll("button")) e.setAttribute("aria-label", this._label(e.dataset.choice));
119
+ }
120
+ _reflect() {
121
+ const e = this.value;
122
+ for (const t of this._group.querySelectorAll("button")) t.setAttribute("aria-pressed", t.dataset.choice === e ? "true" : "false");
123
+ }
124
+ _select(e) {
125
+ d(e), this._reflect(), this._syncMeta(e), document.dispatchEvent(new CustomEvent(c)), this.dispatchEvent(new CustomEvent("change", {
126
+ detail: { theme: e },
127
+ bubbles: !0,
128
+ composed: !0
129
+ }));
130
+ }
131
+ _syncMeta(e) {
132
+ if (typeof requestAnimationFrame > "u") return;
133
+ const t = document.querySelectorAll('meta[name="theme-color"]');
134
+ t.length && requestAnimationFrame(() => {
135
+ for (const r of t)
136
+ if (r.dataset.ranOriginalContent === void 0 && (r.dataset.ranOriginalContent = r.getAttribute("content") || ""), e === "system") r.setAttribute("content", r.dataset.ranOriginalContent);
137
+ else {
138
+ const n = getComputedStyle(document.documentElement).getPropertyValue("--ran-color-bg").trim() || getComputedStyle(document.body).backgroundColor;
139
+ r.setAttribute("content", n);
140
+ }
141
+ });
142
+ }
143
+ _handleClick = (e) => {
144
+ const t = e.target.closest?.("button")?.dataset.choice;
145
+ t && h.includes(t) && this._select(t);
146
+ };
147
+ _handleSync = () => this._reflect();
148
+ handlerExternalCss = () => {
149
+ u(this, this._shadowDom, "sheet", null, this.sheet);
150
+ };
151
+ connectedCallback() {
152
+ this.handlerExternalCss(), this._syncLabels(), this._reflect(), this._events.on(this._group, "click", this._handleClick), document.addEventListener(c, this._handleSync), typeof window < "u" && window.addEventListener("storage", this._handleSync);
153
+ }
154
+ disconnectedCallback() {
155
+ this._events.abort(), document.removeEventListener(c, this._handleSync), typeof window < "u" && window.removeEventListener("storage", this._handleSync);
156
+ }
157
+ attributeChangedCallback(e, t, r) {
158
+ t !== r && (e === "sheet" && this.handlerExternalCss(), e.startsWith("label") && this._syncLabels());
159
+ }
160
+ };
161
+ p("r-theme-switch", A);
162
+ export {
163
+ d as a,
164
+ z as i,
165
+ x as n,
166
+ _ as o,
167
+ k as r,
168
+ L as s,
169
+ A as t
170
+ };
@@ -0,0 +1,5 @@
1
+ import { t as e } from "./theme-switch-B8K9y2RL.js";
2
+ export {
3
+ e as ThemeSwitch,
4
+ e as default
5
+ };