melonykit 0.16.0 → 0.16.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.
@@ -1,4 +1,4 @@
1
- import { h as e } from "./functions-CexzzAfY.js";
1
+ import { h as e } from "./functions-HFX7hCQR.js";
2
2
  import { signal as t } from "@preact/signals";
3
3
  import { useEffect as n, useMemo as r } from "preact/hooks";
4
4
  //#region src/browser/_route-to.js
package/dist/browser.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as e, n as t, r as n, t as r } from "./browser-WVsjaJ9n.js";
1
+ import { i as e, n as t, r as n, t as r } from "./browser-DEPpkjr9.js";
2
2
  export { t as getClientSetting, e as routeTo, r as setClientSetting, n as useQuery };
@@ -165,8 +165,13 @@ var d = (e) => {
165
165
  return c.setDate(c[r + "Date"]() + 1), o[r + "FullYear"]() === e && o[r + "Month"]() === t && o[r + "Date"]() === n ? a ? "Tdy" : "Today" : s[r + "FullYear"]() === e && s[r + "Month"]() === t && s[r + "Date"]() === n ? a ? "Ysd" : "Yesterday" : c[r + "FullYear"]() === e && c[r + "Month"]() === t && c[r + "Date"]() === n ? a ? "Tmw" : "Tomorrow" : i;
166
166
  };
167
167
  //#endregion
168
+ //#region src/functions/_kebab-case-to-title-case.js
169
+ function h(e) {
170
+ return r(e) ? e.split("-").filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" ") : "";
171
+ }
172
+ //#endregion
168
173
  //#region src/functions/_request.js
169
- async function h({ url: e, body: t, method: n = "POST", headers: r = {} } = {}) {
174
+ async function g({ url: e, body: t, method: n = "POST", headers: r = {} } = {}) {
170
175
  let i = n !== "GET" && t !== void 0 ? JSON.stringify(t) : void 0, a = await fetch(e, {
171
176
  method: n,
172
177
  headers: {
@@ -187,12 +192,12 @@ async function h({ url: e, body: t, method: n = "POST", headers: r = {} } = {})
187
192
  }
188
193
  //#endregion
189
194
  //#region src/functions/_size.js
190
- function g(e) {
195
+ function _(e) {
191
196
  return e == null ? 0 : Array.isArray(e) || typeof e == "string" ? e.length : typeof e == "object" || typeof e == "function" ? Object.keys(e).length : 0;
192
197
  }
193
198
  //#endregion
194
199
  //#region src/functions/_to-number.js
195
- function _(e, t = null) {
200
+ function v(e, t = null) {
196
201
  let n = typeof e == "number" ? e : typeof e == "string" && e.trim() !== "" ? Number(e) : NaN;
197
202
  if (!Number.isFinite(n)) return null;
198
203
  if (t == null) return n;
@@ -201,32 +206,32 @@ function _(e, t = null) {
201
206
  }
202
207
  //#endregion
203
208
  //#region src/functions/checks/_is-array.js
204
- function v(e) {
209
+ function y(e) {
205
210
  return Array.isArray(e);
206
211
  }
207
212
  //#endregion
208
213
  //#region src/functions/checks/_is-empty-array.js
209
- function y(e) {
210
- return v(e) && e.length === 0;
214
+ function b(e) {
215
+ return y(e) && e.length === 0;
211
216
  }
212
217
  //#endregion
213
218
  //#region src/functions/checks/_is-function.js
214
- function b(e) {
219
+ function x(e) {
215
220
  return typeof e == "function";
216
221
  }
217
222
  //#endregion
218
223
  //#region src/functions/checks/_is-number.js
219
- function x(e) {
224
+ function S(e) {
220
225
  return typeof e == "number" && Number.isFinite(e);
221
226
  }
222
227
  //#endregion
223
228
  //#region src/functions/checks/_is-positive-number.js
224
- function S(e) {
225
- return x(e) && e > 0;
229
+ function C(e) {
230
+ return S(e) && e > 0;
226
231
  }
227
232
  //#endregion
228
233
  //#region src/functions/_create-cache.js
229
- function C({ onCreate: e, onUpdate: t, onDelete: n, autoCleanup: r } = {}) {
234
+ function w({ onCreate: e, onUpdate: t, onDelete: n, autoCleanup: r } = {}) {
230
235
  let i = /* @__PURE__ */ new Map();
231
236
  async function a(t, n) {
232
237
  if (i.has(t)) return !1;
@@ -235,12 +240,12 @@ function C({ onCreate: e, onUpdate: t, onDelete: n, autoCleanup: r } = {}) {
235
240
  ...n,
236
241
  createdAt: r,
237
242
  lastUpdate: r
238
- }), b(e) && await e(t), !0;
243
+ }), x(e) && await e(t), !0;
239
244
  }
240
245
  async function o(e, n) {
241
246
  if (!i.has(e) || typeof n != "function") return !1;
242
247
  let r = i.get(e);
243
- return await n(r), r.lastUpdate = Date.now(), b(t) && await t(e), !0;
248
+ return await n(r), r.lastUpdate = Date.now(), x(t) && await t(e), !0;
244
249
  }
245
250
  function s(e) {
246
251
  return i.get(e) ?? null;
@@ -257,10 +262,10 @@ function C({ onCreate: e, onUpdate: t, onDelete: n, autoCleanup: r } = {}) {
257
262
  async function d(e) {
258
263
  if (!i.has(e)) return !1;
259
264
  let t = i.get(e);
260
- return i.delete(e), b(n) && await n(e, t), !0;
265
+ return i.delete(e), x(n) && await n(e, t), !0;
261
266
  }
262
267
  function f({ interval: e, checks: t, now: n = Date.now, setIntervalFn: r = setInterval } = {}) {
263
- S(e) && v(t) && !y(t) && t.every((e) => b(e)) && b(n) && b(r) && r(async () => {
268
+ C(e) && y(t) && !b(t) && t.every((e) => x(e)) && x(n) && x(r) && r(async () => {
264
269
  let e = n();
265
270
  for (let [n, r] of i) t.some((t) => t(r, e)) && await d(n);
266
271
  }, e)?.unref?.();
@@ -277,33 +282,33 @@ function C({ onCreate: e, onUpdate: t, onDelete: n, autoCleanup: r } = {}) {
277
282
  }
278
283
  //#endregion
279
284
  //#region src/functions/checks/_is-nil.js
280
- function w(e) {
285
+ function T(e) {
281
286
  return e == null;
282
287
  }
283
288
  //#endregion
284
289
  //#region src/functions/checks/_is-object.js
285
- function T(e) {
286
- return !w(e) && typeof e == "object" && !v(e);
290
+ function E(e) {
291
+ return !T(e) && typeof e == "object" && !y(e);
287
292
  }
288
293
  //#endregion
289
294
  //#region src/functions/checks/_is-empty-object.js
290
- function E(e) {
291
- return T(e) && Reflect.ownKeys(e).every((t) => !Object.prototype.propertyIsEnumerable.call(e, t));
295
+ function D(e) {
296
+ return E(e) && Reflect.ownKeys(e).every((t) => !Object.prototype.propertyIsEnumerable.call(e, t));
292
297
  }
293
298
  //#endregion
294
299
  //#region src/functions/checks/_is-empty-string.js
295
- function D(e) {
300
+ function O(e) {
296
301
  return r(e) && e.trim().length === 0;
297
302
  }
298
303
  //#endregion
299
304
  //#region src/functions/checks/_is-empty.js
300
- function O(e) {
305
+ function k(e) {
301
306
  return e == null ? !0 : typeof e == "function" ? !1 : typeof e == "number" ? !Number.isFinite(e) : typeof e == "string" ? e.trim().length === 0 : Array.isArray(e) ? e.length === 0 : typeof e != "object" || Object.keys(e).length === 0 && Object.getOwnPropertySymbols(e).length === 0;
302
307
  }
303
308
  //#endregion
304
309
  //#region src/functions/checks/_is-negative-number.js
305
- function k(e) {
306
- return x(e) && e < 0;
310
+ function A(e) {
311
+ return S(e) && e < 0;
307
312
  }
308
313
  //#endregion
309
- export { r as _, T as a, S as c, y as d, v as f, u as g, h, E as i, x as l, g as m, O as n, w as o, _ as p, D as r, C as s, k as t, b as u, n as v, t as y };
314
+ export { u as _, E as a, t as b, C as c, b as d, y as f, h as g, g as h, D as i, S as l, _ as m, k as n, T as o, v as p, O as r, w as s, A as t, x as u, r as v, n as y };
package/dist/functions.js CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, t as h, u as g, v as _, y as v } from "./functions-CexzzAfY.js";
2
- export { v as convertHexToRgba, m as createCache, _ as darkenHexColor, a as formatDate, i as isArray, u as isEmpty, r as isEmptyArray, s as isEmptyObject, p as isEmptyString, g as isFunction, h as isNegativeNumber, d as isNil, c as isNumber, t as isObject, n as isPositiveNumber, e as isString, o as request, l as size, f as toNumber };
1
+ import { _ as e, a as t, b as n, c as r, d as i, f as a, g as o, h as s, i as c, l, m as u, n as d, o as f, p, r as m, s as h, t as g, u as _, v, y } from "./functions-HFX7hCQR.js";
2
+ export { n as convertHexToRgba, h as createCache, y as darkenHexColor, e as formatDate, a as isArray, d as isEmpty, i as isEmptyArray, c as isEmptyObject, m as isEmptyString, _ as isFunction, g as isNegativeNumber, f as isNil, l as isNumber, t as isObject, r as isPositiveNumber, v as isString, o as kebabCaseToTitleCase, s as request, u as size, p as toNumber };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { n as e, t } from "./browser-WVsjaJ9n.js";
2
- import { r as n, v as r } from "./functions-CexzzAfY.js";
1
+ import { n as e, t } from "./browser-DEPpkjr9.js";
2
+ import { r as n, y as r } from "./functions-HFX7hCQR.js";
3
3
  import { useSignal as i } from "@preact/signals";
4
4
  import { useEffect as a, useId as o, useRef as s, useState as c } from "preact/hooks";
5
5
  import { Fragment as l, jsx as u, jsxs as d } from "preact/jsx-runtime";
@@ -1856,13 +1856,20 @@ var Lt = {
1856
1856
  };
1857
1857
  //#endregion
1858
1858
  //#region src/components/_option-group.jsx
1859
- function Rt({ label: e, items: t = [], value: n, width: r, isDisabled: s = !1, onChange: c }) {
1860
- let f = o(), p = `${f}-label`, m = i(n ?? t[0]?.value);
1859
+ function Rt({ label: e, items: t = [], value: n, width: r, isDisabled: i = !1, onChange: s }) {
1860
+ let f = o(), p = `${f}-label`, [m, h] = c(n);
1861
1861
  a(() => {
1862
- n !== void 0 && (m.value = n);
1862
+ n !== void 0 && h(n);
1863
1863
  }, [n]);
1864
- function h(e) {
1865
- m.value = e.value, c?.(e.value, e);
1864
+ function g(e) {
1865
+ let t = m === e.value ? void 0 : e.value;
1866
+ h(t), s?.(t, t === void 0 ? void 0 : e);
1867
+ }
1868
+ function _(e, t) {
1869
+ e.preventDefault(), g(t);
1870
+ }
1871
+ function v(e, t) {
1872
+ e.key === " " && m === t.value && (e.preventDefault(), g(t));
1866
1873
  }
1867
1874
  return /* @__PURE__ */ u(l, { children: /* @__PURE__ */ d("div", {
1868
1875
  className: X.base,
@@ -1876,7 +1883,7 @@ function Rt({ label: e, items: t = [], value: n, width: r, isDisabled: s = !1, o
1876
1883
  role: "radiogroup",
1877
1884
  "aria-labelledby": e ? p : void 0,
1878
1885
  children: t.map((e, t) => {
1879
- let n = `${f}-${t}`, r = s || e.isDisabled;
1886
+ let n = `${f}-${t}`, r = i || e.isDisabled;
1880
1887
  return /* @__PURE__ */ d("div", {
1881
1888
  className: X.option,
1882
1889
  children: [/* @__PURE__ */ u("input", {
@@ -1884,12 +1891,14 @@ function Rt({ label: e, items: t = [], value: n, width: r, isDisabled: s = !1, o
1884
1891
  type: "radio",
1885
1892
  name: f,
1886
1893
  className: X.input,
1887
- checked: e.value === m.value,
1894
+ checked: e.value === m,
1888
1895
  disabled: r,
1889
- onChange: () => h(e)
1896
+ onChange: () => g(e),
1897
+ onKeyDown: (t) => v(t, e)
1890
1898
  }), /* @__PURE__ */ u("label", {
1891
1899
  className: X.optionLabel,
1892
1900
  htmlFor: n,
1901
+ onClick: (t) => _(t, e),
1893
1902
  children: e.label
1894
1903
  })]
1895
1904
  }, e.value);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Vadim Hermann",
3
3
  "name": "melonykit",
4
- "version": "0.16.0",
4
+ "version": "0.16.2",
5
5
  "type": "module",
6
6
  "description": "Preact based ui and utility functions toolkit",
7
7
  "main": "./dist/index.js",