@typlog/ui 0.15.0 → 0.16.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/addons.css CHANGED
@@ -1,40 +1,42 @@
1
1
 
2
+ @layer components {
2
3
  .ui-SocialButton:where(.r-variant-classic) {
3
- background-color: var(--social-button-background-color);
4
- color: var(--social-button-text-color);
5
- box-shadow: 0px 1px 2px 0px #0A0D120D, 0px -2px 0px 0px #0A0D120D inset, 0px 0px 0px 1px #0A0D122E inset;
6
- --social-button-background-color: black;
7
- --social-button-text-color: white;
8
- --social-button-hover-filter: brightness(0.92) saturate(1.1);
4
+ background-color: var(--social-button-background-color);
5
+ color: var(--social-button-text-color);
6
+ box-shadow: 0px 1px 2px 0px #0A0D120D, 0px -2px 0px 0px #0A0D120D inset, 0px 0px 0px 1px #0A0D122E inset;
7
+ --social-button-background-color: black;
8
+ --social-button-text-color: white;
9
+ --social-button-hover-filter: brightness(0.92) saturate(1.1);
9
10
  }
10
11
  @media (hover: hover) {
11
12
  .ui-SocialButton:where(:hover) {
12
- filter: var(--social-button-hover-filter);
13
+ filter: var(--social-button-hover-filter);
13
14
  }
14
15
  }
15
16
  .ui-SocialButton:where(.r-brand-google) {
16
- --social-button-background-color: var(--color-background);
17
- --social-button-text-color: var(--gray-12);
17
+ --social-button-background-color: var(--color-background);
18
+ --social-button-text-color: var(--gray-12);
18
19
  }
19
20
  .ui-SocialButton:where(.r-brand-facebook) {
20
- --social-button-background-color: #1877F2;
21
+ --social-button-background-color: #1877F2;
21
22
  }
22
23
  .ui-SocialButton:where(.r-brand-github) {
23
- --social-button-background-color: #333;
24
+ --social-button-background-color: #333;
24
25
  }
25
26
  .ui-SocialButton:where(.r-variant-classic):where(.r-brand-slack) {
26
- --social-button-background-color: #611f69;
27
+ --social-button-background-color: #611f69;
27
28
  }
28
29
  .ui-SocialButton:where(.r-variant-classic):where(:focus-visible) {
29
- outline: 2px solid var(--focus-8);
30
- outline-offset: 2px;
30
+ outline: 2px solid var(--focus-8);
31
+ outline-offset: 2px;
31
32
  }
32
33
  .ui-SocialButton:where(.r-variant-classic):where(:active) {
33
- box-shadow: var(--shadow-1);
34
+ box-shadow: var(--shadow-1);
34
35
  }
35
36
  .ui-SocialButton:where(.r-variant-classic):where([data-disabled]) {
36
- color: var(--gray-a10);
37
- background-color: var(--gray-a2);
37
+ color: var(--gray-a10);
38
+ background-color: var(--gray-a2);
39
+ }
38
40
  }
39
41
 
40
42
  @layer components {
@@ -248,38 +250,40 @@
248
250
  color: var(--gray-a11);
249
251
  text-align: center;
250
252
  }
251
- }
252
253
  @container icon-collection (min-width: 768px) {
253
254
  .ui-IconCollectionToolbar {
254
- flex-direction: row;
255
- align-items: center;
255
+ flex-direction: row;
256
+ align-items: center;
256
257
  }
257
258
  .ui-IconCollectionFilter {
258
- max-width: 28rem;
259
+ max-width: 28rem;
259
260
  }
260
261
  .ui-IconCollectionCards {
261
- grid-template-columns: repeat(2, minmax(0, 1fr));
262
+ grid-template-columns: repeat(2, minmax(0, 1fr));
262
263
  }
263
264
  }
264
265
  @container icon-collection (min-width: 1024px) {
265
266
  .ui-IconCollectionCards {
266
- grid-template-columns: repeat(3, minmax(0, 1fr));
267
+ grid-template-columns: repeat(3, minmax(0, 1fr));
267
268
  }
268
269
  }
269
270
  @container icon-collection (min-width: 1280px) {
270
271
  .ui-IconCollectionCards {
271
- grid-template-columns: repeat(4, minmax(0, 1fr));
272
+ grid-template-columns: repeat(4, minmax(0, 1fr));
273
+ }
272
274
  }
273
275
  }
274
276
 
277
+ @layer components {
275
278
  .ui-Turnstile {
276
- background: var(--gray-a3);
279
+ background: var(--gray-a3);
277
280
  }
278
281
  .ui-Turnstile:where(.r-size-normal) {
279
- width: 300px;
280
- height: 65px;
282
+ width: 300px;
283
+ height: 65px;
281
284
  }
282
285
  .ui-Turnstile:where(.r-size-compact) {
283
- width: 150px;
284
- height: 140px;
286
+ width: 150px;
287
+ height: 140px;
288
+ }
285
289
  }
package/addons.d.ts CHANGED
@@ -60,7 +60,11 @@ declare const __VLS_export_3: __VLS_WithSlots_2< DefineComponent<IconGridProps,
60
60
  'header-search'?: (props: {}) => any;
61
61
  }>;
62
62
 
63
- declare const __VLS_export_4: DefineComponent<TurnstileProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
63
+ declare const __VLS_export_4: DefineComponent<TurnstileProps, {
64
+ render: () => Promise<void>;
65
+ reset: () => void;
66
+ remove: () => void;
67
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
64
68
  "update:modelValue": (args_0: string) => any;
65
69
  }, string, PublicProps, Readonly<TurnstileProps> & Readonly<{
66
70
  "onUpdate:modelValue"?: ((args_0: string) => any) | undefined;
@@ -198,7 +202,7 @@ export declare interface IconifyCollectionItem {
198
202
  [key: string]: unknown;
199
203
  }
200
204
 
201
- declare type RadiusType = 'none' | 'small' | 'medium' | 'large' | 'full'
205
+ declare type RadiusType = 'none' | 'small' | 'medium' | 'large' | 'full';
202
206
 
203
207
  export declare const SocialButton: typeof __VLS_export;
204
208
 
@@ -232,7 +236,7 @@ export { }
232
236
 
233
237
  declare global {
234
238
  interface Window {
235
- turnstile: any;
236
- [turnstileLoadFunction]: any;
239
+ turnstile?: TurnstileApi;
240
+ cfTurnstileOnLoad?: () => void;
237
241
  }
238
242
  }
package/addons.js CHANGED
@@ -1720,10 +1720,31 @@ var IconCollection_default = /* @__PURE__ */ defineComponent({
1720
1720
  //#region src/addons/turnstile/Turnstile.vue?vue&type=script&setup=true&lang.ts
1721
1721
  var turnstileSrc = "https://challenges.cloudflare.com/turnstile/v0/api.js";
1722
1722
  var turnstileLoadFunction = "cfTurnstileOnLoad";
1723
- var turnstileState = typeof window !== "undefined" ? window.turnstile !== void 0 ? "ready" : "unloaded" : "unloaded";
1724
- var turnstileLoad;
1725
- var widgetId;
1726
- var resetTimeout;
1723
+ var turnstileLoadPromise;
1724
+ var loadTurnstile = () => {
1725
+ if (typeof window === "undefined") return Promise.reject(/* @__PURE__ */ new Error("Turnstile is only available in a browser."));
1726
+ if (window.turnstile) return Promise.resolve();
1727
+ if (turnstileLoadPromise) return turnstileLoadPromise;
1728
+ turnstileLoadPromise = new Promise((resolve, reject) => {
1729
+ const onLoad = () => {
1730
+ if (window.turnstile) resolve();
1731
+ else reject(/* @__PURE__ */ new Error("Turnstile loaded without exposing its API."));
1732
+ };
1733
+ window[turnstileLoadFunction] = onLoad;
1734
+ const script = document.createElement("script");
1735
+ script.src = `${turnstileSrc}?onload=${turnstileLoadFunction}&render=explicit`;
1736
+ script.async = true;
1737
+ script.addEventListener("error", () => {
1738
+ reject(/* @__PURE__ */ new Error("Failed to load Turnstile."));
1739
+ }, { once: true });
1740
+ document.head.appendChild(script);
1741
+ }).catch((error) => {
1742
+ turnstileLoadPromise = void 0;
1743
+ if (window.cfTurnstileOnLoad) delete window.cfTurnstileOnLoad;
1744
+ throw error;
1745
+ });
1746
+ return turnstileLoadPromise;
1747
+ };
1727
1748
  //#endregion
1728
1749
  //#region src/addons/turnstile/Turnstile.vue
1729
1750
  var Turnstile_default = /* @__PURE__ */ defineComponent({
@@ -1742,29 +1763,48 @@ var Turnstile_default = /* @__PURE__ */ defineComponent({
1742
1763
  }
1743
1764
  },
1744
1765
  emits: ["update:modelValue"],
1745
- setup(__props, { emit: __emit }) {
1766
+ setup(__props, { expose: __expose, emit: __emit }) {
1746
1767
  const props = __props;
1747
1768
  const emit = __emit;
1748
1769
  const element = useTemplateRef("element");
1770
+ const mounted = ref(false);
1771
+ let widgetId;
1772
+ let resetTimeout;
1773
+ const clearResetTimeout = () => {
1774
+ if (resetTimeout !== void 0) {
1775
+ clearTimeout(resetTimeout);
1776
+ resetTimeout = void 0;
1777
+ }
1778
+ };
1749
1779
  const resetTurnstile = () => {
1750
- if (window.turnstile) {
1780
+ if (widgetId !== void 0 && window.turnstile) {
1781
+ clearResetTimeout();
1751
1782
  emit("update:modelValue", "");
1752
- window.turnstile.reset();
1783
+ window.turnstile.reset(widgetId);
1753
1784
  }
1754
1785
  };
1755
1786
  const removeTurnstile = () => {
1756
- if (widgetId) {
1757
- window.turnstile.remove(widgetId);
1787
+ clearResetTimeout();
1788
+ if (widgetId !== void 0) {
1789
+ if (window.turnstile) window.turnstile.remove(widgetId);
1758
1790
  widgetId = void 0;
1759
1791
  }
1760
1792
  };
1761
1793
  const callbackTurnstile = (token) => {
1762
1794
  emit("update:modelValue", token);
1795
+ clearResetTimeout();
1763
1796
  resetTimeout = setTimeout(() => {
1764
1797
  resetTurnstile();
1765
1798
  }, props.resetInterval);
1766
1799
  };
1767
- const renderTurnstile = () => {
1800
+ const renderTurnstile = async () => {
1801
+ if (!mounted.value || widgetId !== void 0 || !element.value) return;
1802
+ if (!window.turnstile) try {
1803
+ await loadTurnstile();
1804
+ } catch {
1805
+ return;
1806
+ }
1807
+ if (!mounted.value || widgetId !== void 0 || !element.value || !window.turnstile) return;
1768
1808
  widgetId = window.turnstile.render(element.value, {
1769
1809
  sitekey: props.sitekey,
1770
1810
  theme: props.theme,
@@ -1774,38 +1814,18 @@ var Turnstile_default = /* @__PURE__ */ defineComponent({
1774
1814
  appearance: props.appearance
1775
1815
  });
1776
1816
  };
1777
- onMounted(async () => {
1778
- const turnstileLoadPromise = new Promise((resolve, reject) => {
1779
- turnstileLoad = {
1780
- resolve,
1781
- reject
1782
- };
1783
- if (turnstileState === "ready") resolve(void 0);
1784
- });
1785
- window[turnstileLoadFunction] = () => {
1786
- turnstileLoad.resolve();
1787
- turnstileState = "ready";
1788
- };
1789
- const ensureTurnstile = () => {
1790
- if (turnstileState === "unloaded") {
1791
- turnstileState = "loading";
1792
- const url = `${turnstileSrc}?onload=${turnstileLoadFunction}&render=explicit`;
1793
- const script = document.createElement("script");
1794
- script.src = url;
1795
- script.async = true;
1796
- script.addEventListener("error", () => {
1797
- turnstileLoad.reject("Failed to load Turnstile.");
1798
- });
1799
- document.head.appendChild(script);
1800
- }
1801
- return turnstileLoadPromise;
1802
- };
1803
- await ensureTurnstile();
1817
+ __expose({
1818
+ render: renderTurnstile,
1819
+ reset: resetTurnstile,
1820
+ remove: removeTurnstile
1821
+ });
1822
+ onMounted(() => {
1823
+ mounted.value = true;
1804
1824
  if (props.renderOnMount) renderTurnstile();
1805
1825
  });
1806
1826
  onBeforeUnmount(() => {
1827
+ mounted.value = false;
1807
1828
  removeTurnstile();
1808
- clearTimeout(resetTimeout);
1809
1829
  });
1810
1830
  return (_ctx, _cache) => {
1811
1831
  return openBlock(), createElementBlock("div", {
package/charts.d.ts CHANGED
@@ -227,7 +227,7 @@ export { }
227
227
 
228
228
  declare global {
229
229
  interface Window {
230
- turnstile: any;
231
- [turnstileLoadFunction]: any;
230
+ turnstile?: TurnstileApi;
231
+ cfTurnstileOnLoad?: () => void;
232
232
  }
233
233
  }