@elmethis/qwik 0.0.23 → 0.0.25

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.
@@ -869,30 +869,29 @@ const ElmParallax = qwik.component$(({ images }) => {
869
869
  ]
870
870
  });
871
871
  });
872
- const toggle = "_toggle_1nxqa_1";
873
- const summary = "_summary_1nxqa_14";
874
- const content$2 = "_content_1nxqa_60";
875
- const footer = "_footer_1nxqa_80";
872
+ const toggle = "_toggle_nwv84_1";
873
+ const summary = "_summary_nwv84_14";
874
+ const content$2 = "_content_nwv84_60";
875
+ const footer = "_footer_nwv84_80";
876
876
  const styles$s = {
877
877
  toggle,
878
- "toggle-closed": "_toggle-closed_1nxqa_7",
879
- "toggle-open": "_toggle-open_1nxqa_10",
878
+ "toggle-closed": "_toggle-closed_nwv84_7",
879
+ "toggle-open": "_toggle-open_nwv84_10",
880
880
  summary,
881
- "summary-open": "_summary-open_1nxqa_29",
882
- "summary-closed": "_summary-closed_1nxqa_33",
883
- "chevron-icon": "_chevron-icon_1nxqa_37",
884
- "chevron-icon-open": "_chevron-icon-open_1nxqa_40",
885
- "chevron-icon-closed": "_chevron-icon-closed_1nxqa_43",
886
- "plus-icon": "_plus-icon_1nxqa_47",
887
- "plus-icon-open": "_plus-icon-open_1nxqa_53",
888
- "plus-icon-closed": "_plus-icon-closed_1nxqa_56",
881
+ "summary-open": "_summary-open_nwv84_29",
882
+ "summary-closed": "_summary-closed_nwv84_33",
883
+ "chevron-icon": "_chevron-icon_nwv84_37",
884
+ "chevron-icon-open": "_chevron-icon-open_nwv84_40",
885
+ "chevron-icon-closed": "_chevron-icon-closed_nwv84_43",
886
+ "plus-icon": "_plus-icon_nwv84_47",
887
+ "plus-icon-open": "_plus-icon-open_nwv84_53",
888
+ "plus-icon-closed": "_plus-icon-closed_nwv84_56",
889
889
  content: content$2,
890
- "content-open": "_content-open_1nxqa_73",
891
- "content-closed": "_content-closed_1nxqa_76",
890
+ "content-open": "_content-open_nwv84_73",
891
+ "content-closed": "_content-closed_nwv84_76",
892
892
  footer,
893
- "footer-line": "_footer-line_1nxqa_99",
894
- "footer-cross-icon": "_footer-cross-icon_1nxqa_106",
895
- "footer-chevron-icon": "_footer-chevron-icon_1nxqa_109"
893
+ "footer-line": "_footer-line_nwv84_99",
894
+ "footer-cross-icon": "_footer-cross-icon_nwv84_105"
896
895
  };
897
896
  const ElmToggle = qwik.component$(({ summary: summary2 }) => {
898
897
  const isOpen = qwik.useSignal(false);
@@ -967,7 +966,6 @@ const ElmToggle = qwik.component$(({ summary: summary2 }) => {
967
966
  onClick$: toggle2,
968
967
  children: [
969
968
  /* @__PURE__ */ jsxRuntime.jsx("span", {
970
- class: styles$s["footer-chevron-icon"],
971
969
  children: /* @__PURE__ */ jsxRuntime.jsx(ElmMdiIcon, {
972
970
  d: js.mdiChevronRight,
973
971
  color: "gray"
@@ -997,7 +995,9 @@ const ElmToggle = qwik.component$(({ summary: summary2 }) => {
997
995
  class: styles$s["footer-line"]
998
996
  }),
999
997
  /* @__PURE__ */ jsxRuntime.jsx("span", {
1000
- class: styles$s["footer-chevron-icon"],
998
+ style: {
999
+ rotate: "180deg"
1000
+ },
1001
1001
  children: /* @__PURE__ */ jsxRuntime.jsx(ElmMdiIcon, {
1002
1002
  d: js.mdiChevronRight,
1003
1003
  color: "gray"
@@ -2723,7 +2723,7 @@ const styles$6 = {
2723
2723
  };
2724
2724
  const useInView = (props) => {
2725
2725
  const ref = qwik.useSignal();
2726
- const isVisible = qwik.useSignal(false);
2726
+ const isVisible = qwik.useSignal(props?.defaultValue ?? false);
2727
2727
  qwik.useVisibleTask$(() => {
2728
2728
  if (!ref.value) return;
2729
2729
  const observer = new IntersectionObserver(([entry]) => {
@@ -3212,6 +3212,66 @@ const ElmMarkdown = qwik.component$(({ markdown }) => {
3212
3212
  children: elements
3213
3213
  });
3214
3214
  });
3215
+ const useDelayedSignal = (initialValue) => {
3216
+ const signal = qwik.useSignal(initialValue);
3217
+ const delayedSignal = qwik.useSignal(initialValue);
3218
+ const isSignalChanging = qwik.useSignal(false);
3219
+ const dispatch = qwik.$((value, delay) => {
3220
+ isSignalChanging.value = true;
3221
+ signal.value = value;
3222
+ if (delay === void 0 || delay <= 0) {
3223
+ delayedSignal.value = value;
3224
+ isSignalChanging.value = false;
3225
+ } else {
3226
+ const timerId = setTimeout(() => {
3227
+ delayedSignal.value = value;
3228
+ isSignalChanging.value = false;
3229
+ clearTimeout(timerId);
3230
+ }, delay);
3231
+ }
3232
+ });
3233
+ return {
3234
+ signal,
3235
+ delayedSignal,
3236
+ dispatch
3237
+ };
3238
+ };
3239
+ const useLocalStorage = (key, initialValue) => {
3240
+ const state = qwik.useSignal(initialValue);
3241
+ qwik.useVisibleTask$(() => {
3242
+ try {
3243
+ const item = localStorage.getItem(key);
3244
+ if (item !== null) {
3245
+ state.value = JSON.parse(item);
3246
+ }
3247
+ } catch (e) {
3248
+ console.warn(`useLocalStorage: failed to read "${key}"`, e);
3249
+ }
3250
+ }, {
3251
+ strategy: "document-ready"
3252
+ });
3253
+ const set = qwik.$((value) => {
3254
+ try {
3255
+ state.value = value;
3256
+ localStorage.setItem(key, JSON.stringify(value));
3257
+ } catch (e) {
3258
+ console.warn(`useLocalStorage: failed to write "${key}"`, e);
3259
+ }
3260
+ });
3261
+ const remove = qwik.$(() => {
3262
+ try {
3263
+ state.value = initialValue;
3264
+ localStorage.removeItem(key);
3265
+ } catch (e) {
3266
+ console.warn(`useLocalStorage: failed to remove "${key}"`, e);
3267
+ }
3268
+ });
3269
+ return {
3270
+ state,
3271
+ set,
3272
+ remove
3273
+ };
3274
+ };
3215
3275
  exports.ElmBlockFallback = ElmBlockFallback;
3216
3276
  exports.ElmBlockImage = ElmBlockImage;
3217
3277
  exports.ElmBlockQuote = ElmBlockQuote;
@@ -3250,3 +3310,7 @@ exports.ElmTextField = ElmTextField;
3250
3310
  exports.ElmToggle = ElmToggle;
3251
3311
  exports.ElmToggleTheme = ElmToggleTheme;
3252
3312
  exports.ElmValidation = ElmValidation;
3313
+ exports.useDelayedSignal = useDelayedSignal;
3314
+ exports.useElmethisTheme = useElmethisTheme;
3315
+ exports.useInView = useInView;
3316
+ exports.useLocalStorage = useLocalStorage;
@@ -867,30 +867,29 @@ const ElmParallax = component$(({ images }) => {
867
867
  ]
868
868
  });
869
869
  });
870
- const toggle = "_toggle_1nxqa_1";
871
- const summary = "_summary_1nxqa_14";
872
- const content$2 = "_content_1nxqa_60";
873
- const footer = "_footer_1nxqa_80";
870
+ const toggle = "_toggle_nwv84_1";
871
+ const summary = "_summary_nwv84_14";
872
+ const content$2 = "_content_nwv84_60";
873
+ const footer = "_footer_nwv84_80";
874
874
  const styles$s = {
875
875
  toggle,
876
- "toggle-closed": "_toggle-closed_1nxqa_7",
877
- "toggle-open": "_toggle-open_1nxqa_10",
876
+ "toggle-closed": "_toggle-closed_nwv84_7",
877
+ "toggle-open": "_toggle-open_nwv84_10",
878
878
  summary,
879
- "summary-open": "_summary-open_1nxqa_29",
880
- "summary-closed": "_summary-closed_1nxqa_33",
881
- "chevron-icon": "_chevron-icon_1nxqa_37",
882
- "chevron-icon-open": "_chevron-icon-open_1nxqa_40",
883
- "chevron-icon-closed": "_chevron-icon-closed_1nxqa_43",
884
- "plus-icon": "_plus-icon_1nxqa_47",
885
- "plus-icon-open": "_plus-icon-open_1nxqa_53",
886
- "plus-icon-closed": "_plus-icon-closed_1nxqa_56",
879
+ "summary-open": "_summary-open_nwv84_29",
880
+ "summary-closed": "_summary-closed_nwv84_33",
881
+ "chevron-icon": "_chevron-icon_nwv84_37",
882
+ "chevron-icon-open": "_chevron-icon-open_nwv84_40",
883
+ "chevron-icon-closed": "_chevron-icon-closed_nwv84_43",
884
+ "plus-icon": "_plus-icon_nwv84_47",
885
+ "plus-icon-open": "_plus-icon-open_nwv84_53",
886
+ "plus-icon-closed": "_plus-icon-closed_nwv84_56",
887
887
  content: content$2,
888
- "content-open": "_content-open_1nxqa_73",
889
- "content-closed": "_content-closed_1nxqa_76",
888
+ "content-open": "_content-open_nwv84_73",
889
+ "content-closed": "_content-closed_nwv84_76",
890
890
  footer,
891
- "footer-line": "_footer-line_1nxqa_99",
892
- "footer-cross-icon": "_footer-cross-icon_1nxqa_106",
893
- "footer-chevron-icon": "_footer-chevron-icon_1nxqa_109"
891
+ "footer-line": "_footer-line_nwv84_99",
892
+ "footer-cross-icon": "_footer-cross-icon_nwv84_105"
894
893
  };
895
894
  const ElmToggle = component$(({ summary: summary2 }) => {
896
895
  const isOpen = useSignal(false);
@@ -965,7 +964,6 @@ const ElmToggle = component$(({ summary: summary2 }) => {
965
964
  onClick$: toggle2,
966
965
  children: [
967
966
  /* @__PURE__ */ jsx("span", {
968
- class: styles$s["footer-chevron-icon"],
969
967
  children: /* @__PURE__ */ jsx(ElmMdiIcon, {
970
968
  d: mdiChevronRight,
971
969
  color: "gray"
@@ -995,7 +993,9 @@ const ElmToggle = component$(({ summary: summary2 }) => {
995
993
  class: styles$s["footer-line"]
996
994
  }),
997
995
  /* @__PURE__ */ jsx("span", {
998
- class: styles$s["footer-chevron-icon"],
996
+ style: {
997
+ rotate: "180deg"
998
+ },
999
999
  children: /* @__PURE__ */ jsx(ElmMdiIcon, {
1000
1000
  d: mdiChevronRight,
1001
1001
  color: "gray"
@@ -2721,7 +2721,7 @@ const styles$6 = {
2721
2721
  };
2722
2722
  const useInView = (props) => {
2723
2723
  const ref = useSignal();
2724
- const isVisible = useSignal(false);
2724
+ const isVisible = useSignal(props?.defaultValue ?? false);
2725
2725
  useVisibleTask$(() => {
2726
2726
  if (!ref.value) return;
2727
2727
  const observer = new IntersectionObserver(([entry]) => {
@@ -3210,6 +3210,66 @@ const ElmMarkdown = component$(({ markdown }) => {
3210
3210
  children: elements
3211
3211
  });
3212
3212
  });
3213
+ const useDelayedSignal = (initialValue) => {
3214
+ const signal = useSignal(initialValue);
3215
+ const delayedSignal = useSignal(initialValue);
3216
+ const isSignalChanging = useSignal(false);
3217
+ const dispatch = $((value, delay) => {
3218
+ isSignalChanging.value = true;
3219
+ signal.value = value;
3220
+ if (delay === void 0 || delay <= 0) {
3221
+ delayedSignal.value = value;
3222
+ isSignalChanging.value = false;
3223
+ } else {
3224
+ const timerId = setTimeout(() => {
3225
+ delayedSignal.value = value;
3226
+ isSignalChanging.value = false;
3227
+ clearTimeout(timerId);
3228
+ }, delay);
3229
+ }
3230
+ });
3231
+ return {
3232
+ signal,
3233
+ delayedSignal,
3234
+ dispatch
3235
+ };
3236
+ };
3237
+ const useLocalStorage = (key, initialValue) => {
3238
+ const state = useSignal(initialValue);
3239
+ useVisibleTask$(() => {
3240
+ try {
3241
+ const item = localStorage.getItem(key);
3242
+ if (item !== null) {
3243
+ state.value = JSON.parse(item);
3244
+ }
3245
+ } catch (e) {
3246
+ console.warn(`useLocalStorage: failed to read "${key}"`, e);
3247
+ }
3248
+ }, {
3249
+ strategy: "document-ready"
3250
+ });
3251
+ const set = $((value) => {
3252
+ try {
3253
+ state.value = value;
3254
+ localStorage.setItem(key, JSON.stringify(value));
3255
+ } catch (e) {
3256
+ console.warn(`useLocalStorage: failed to write "${key}"`, e);
3257
+ }
3258
+ });
3259
+ const remove = $(() => {
3260
+ try {
3261
+ state.value = initialValue;
3262
+ localStorage.removeItem(key);
3263
+ } catch (e) {
3264
+ console.warn(`useLocalStorage: failed to remove "${key}"`, e);
3265
+ }
3266
+ });
3267
+ return {
3268
+ state,
3269
+ set,
3270
+ remove
3271
+ };
3272
+ };
3213
3273
  export {
3214
3274
  ElmBlockFallback,
3215
3275
  ElmBlockImage,
@@ -3248,5 +3308,9 @@ export {
3248
3308
  ElmTextField,
3249
3309
  ElmToggle,
3250
3310
  ElmToggleTheme,
3251
- ElmValidation
3311
+ ElmValidation,
3312
+ useDelayedSignal,
3313
+ useElmethisTheme,
3314
+ useInView,
3315
+ useLocalStorage
3252
3316
  };
package/lib/style.css CHANGED
@@ -240,20 +240,20 @@
240
240
  }
241
241
  [data-theme=dark] ._parallax_1kb0k_1 {
242
242
  opacity: 0.1;
243
- }._toggle_1nxqa_1 {
243
+ }._toggle_nwv84_1 {
244
244
  margin: 0;
245
245
  display: grid;
246
246
  transition: grid 200ms;
247
247
  overflow: hidden;
248
248
  }
249
- ._toggle_1nxqa_1._toggle-closed_1nxqa_7 {
249
+ ._toggle_nwv84_1._toggle-closed_nwv84_7 {
250
250
  grid-template-rows: 3.5rem 0fr 0rem;
251
251
  }
252
- ._toggle_1nxqa_1._toggle-open_1nxqa_10 {
252
+ ._toggle_nwv84_1._toggle-open_nwv84_10 {
253
253
  grid-template-rows: 3.5rem 1fr 3rem;
254
254
  }
255
255
 
256
- ._summary_1nxqa_14 {
256
+ ._summary_nwv84_14 {
257
257
  box-sizing: border-box;
258
258
  padding-inline: 1rem;
259
259
  display: grid;
@@ -264,42 +264,42 @@
264
264
  border: 1px solid rgba(0, 0, 0, 0.125);
265
265
  background-color: rgba(62, 67, 75, 0.05);
266
266
  }
267
- [data-theme=dark] ._summary_1nxqa_14 {
267
+ [data-theme=dark] ._summary_nwv84_14 {
268
268
  border: 1px solid rgba(255, 255, 255, 0.125);
269
269
  background-color: rgba(190, 194, 202, 0.1);
270
270
  }
271
- ._summary_1nxqa_14._summary-open_1nxqa_29 {
271
+ ._summary_nwv84_14._summary-open_nwv84_29 {
272
272
  border-radius: 0.25rem 0.25rem 0 0;
273
273
  border-bottom-color: transparent;
274
274
  }
275
- ._summary_1nxqa_14._summary-closed_1nxqa_33 {
275
+ ._summary_nwv84_14._summary-closed_nwv84_33 {
276
276
  border-radius: 0.25rem;
277
277
  }
278
278
 
279
- ._chevron-icon_1nxqa_37 {
279
+ ._chevron-icon_nwv84_37 {
280
280
  transition: transform 200ms;
281
281
  }
282
- ._chevron-icon_1nxqa_37._chevron-icon-open_1nxqa_40 {
282
+ ._chevron-icon_nwv84_37._chevron-icon-open_nwv84_40 {
283
283
  transform: rotate(90deg);
284
284
  }
285
- ._chevron-icon_1nxqa_37._chevron-icon-closed_1nxqa_43 {
285
+ ._chevron-icon_nwv84_37._chevron-icon-closed_nwv84_43 {
286
286
  transform: rotate(0deg);
287
287
  }
288
288
 
289
- ._plus-icon_1nxqa_47 {
289
+ ._plus-icon_nwv84_47 {
290
290
  height: 1rem;
291
291
  width: 1rem;
292
292
  transform-origin: center;
293
293
  transition: transform 200ms;
294
294
  }
295
- ._plus-icon_1nxqa_47._plus-icon-open_1nxqa_53 {
295
+ ._plus-icon_nwv84_47._plus-icon-open_nwv84_53 {
296
296
  transform: rotate(135deg);
297
297
  }
298
- ._plus-icon_1nxqa_47._plus-icon-closed_1nxqa_56 {
298
+ ._plus-icon_nwv84_47._plus-icon-closed_nwv84_56 {
299
299
  transform: rotate(0deg);
300
300
  }
301
301
 
302
- ._content_1nxqa_60 {
302
+ ._content_nwv84_60 {
303
303
  box-sizing: border-box;
304
304
  padding: 1rem;
305
305
  overflow: hidden;
@@ -308,21 +308,21 @@
308
308
  border-radius: 0 0 0.25rem 0.25rem;
309
309
  background-color: rgba(62, 67, 75, 0.0125);
310
310
  }
311
- [data-theme=dark] ._content_1nxqa_60 {
311
+ [data-theme=dark] ._content_nwv84_60 {
312
312
  border-color: rgba(255, 255, 255, 0.125);
313
313
  background-color: rgba(190, 194, 202, 0.025);
314
314
  }
315
- ._content_1nxqa_60._content-open_1nxqa_73 {
315
+ ._content_nwv84_60._content-open_nwv84_73 {
316
316
  opacity: 1;
317
317
  }
318
- ._content_1nxqa_60._content-closed_1nxqa_76 {
318
+ ._content_nwv84_60._content-closed_nwv84_76 {
319
319
  opacity: 0;
320
320
  }
321
321
 
322
- ._footer_1nxqa_80 {
322
+ ._footer_nwv84_80 {
323
323
  box-sizing: border-box;
324
324
  margin: 0.25rem 0rem;
325
- padding: 0.5rem;
325
+ padding: 0.5rem 0.25rem;
326
326
  color: #c56565;
327
327
  font-family: monospace;
328
328
  display: flex;
@@ -334,22 +334,18 @@
334
334
  border-radius: 0.25rem;
335
335
  transition: opacity 200ms, background-color 200ms;
336
336
  }
337
- ._footer_1nxqa_80:hover {
337
+ ._footer_nwv84_80:hover {
338
338
  opacity: 0.5;
339
339
  background-color: rgba(96, 104, 117, 0.1);
340
340
  }
341
- ._footer_1nxqa_80._footer-line_1nxqa_99 {
341
+ ._footer_nwv84_80 ._footer-line_nwv84_99 {
342
342
  box-sizing: border-box;
343
- margin: 0 0.25rem;
344
- flex-grow: 1;
343
+ flex: 1;
345
344
  border: none;
346
- border-bottom: solid 1px rgba(128, 128, 128, 0.3);
345
+ border-bottom: 1px solid rgba(128, 128, 128, 0.3);
347
346
  }
348
- ._footer_1nxqa_80._footer-cross-icon_1nxqa_106 {
347
+ ._footer_nwv84_80 ._footer-cross-icon_nwv84_105 {
349
348
  transform: rotate(45deg);
350
- }
351
- ._footer_1nxqa_80._footer-chevron-icon_1nxqa_109 {
352
- transform: rotate(-90deg);
353
349
  }._block-fallback_rt986_1 {
354
350
  position: relative;
355
351
  display: flex;
@@ -0,0 +1,6 @@
1
+ import { type QRL } from "@builder.io/qwik";
2
+ export declare const useLocalStorage: <T>(key: string, initialValue: T) => {
3
+ state: import("@builder.io/qwik").Signal<T>;
4
+ set: QRL<(value: T) => void>;
5
+ remove: QRL<() => void>;
6
+ };
@@ -36,3 +36,7 @@ export { ElmTableRow, type ElmTableRowProps, } from "./components/table/elm-tabl
36
36
  export { ElmTableCell, type ElmTableCellProps, } from "./components/table/elm-table-cell";
37
37
  export { ElmJarkup, type ElmJarkupProps } from "./components/others/elm-jarkup";
38
38
  export { ElmMarkdown, type ElmMarkdownProps, } from "./components/others/elm-markdown";
39
+ export { useDelayedSignal } from "./hooks/useDelayedSignal";
40
+ export { useElmethisTheme } from "./hooks/useElmethisTheme";
41
+ export { useInView } from "./hooks/useInView";
42
+ export { useLocalStorage } from "./hooks/useLocalStorage";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elmethis/qwik",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -47,7 +47,7 @@
47
47
  "eslint-plugin-qwik": "1.19.1",
48
48
  "globals": "17.4.0",
49
49
  "jarkup-ts": "^0.8.0",
50
- "np": "^8.0.4",
50
+ "np": "^11.0.2",
51
51
  "prettier": "3.6.2",
52
52
  "sass": "^1.97.3",
53
53
  "storybook": "8",