voodoojs 0.4.6 → 0.6.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/dist/voodoo.js CHANGED
@@ -3378,7 +3378,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
3378
3378
  // src/store/index.ts
3379
3379
  init_reactivity();
3380
3380
  var stores = /* @__PURE__ */ new Map();
3381
- var versao = ref(0);
3381
+ var version = ref(0);
3382
3382
  var persistHandles = /* @__PURE__ */ new Map();
3383
3383
  function store(name, definition, options = {}) {
3384
3384
  const existing = stores.get(name);
@@ -3395,30 +3395,30 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
3395
3395
  return existing;
3396
3396
  }
3397
3397
  const key = typeof options.persist === "string" ? options.persist : `voodoo:store:${name}`;
3398
- const descritores = Object.getOwnPropertyDescriptors(definition);
3399
- const initial = Object.defineProperties({}, descritores);
3398
+ const descriptors = Object.getOwnPropertyDescriptors(definition);
3399
+ const initial = Object.defineProperties({}, descriptors);
3400
3400
  if (options.persist && typeof localStorage !== "undefined") {
3401
3401
  try {
3402
3402
  const saved = localStorage.getItem(key);
3403
3403
  if (saved) {
3404
- const salvo = JSON.parse(saved);
3405
- for (const [chave, valor] of Object.entries(salvo)) {
3406
- if (descritores[chave] && !("value" in descritores[chave])) continue;
3407
- initial[chave] = valor;
3404
+ const parsed = JSON.parse(saved);
3405
+ for (const [field, value] of Object.entries(parsed)) {
3406
+ if (descriptors[field] && !("value" in descriptors[field])) continue;
3407
+ initial[field] = value;
3408
3408
  }
3409
3409
  }
3410
3410
  } catch (e) {
3411
3411
  }
3412
3412
  }
3413
3413
  const created = reactive(initial);
3414
- for (const [prop, descritor] of Object.entries(descritores)) {
3415
- const value = descritor.value;
3414
+ for (const [prop, descriptor] of Object.entries(descriptors)) {
3415
+ const value = descriptor.value;
3416
3416
  if (typeof value === "function") {
3417
3417
  created[prop] = (...args) => value.apply(created, args);
3418
3418
  }
3419
3419
  }
3420
3420
  stores.set(name, created);
3421
- versao.value++;
3421
+ version.value++;
3422
3422
  if (options.persist && typeof localStorage !== "undefined") {
3423
3423
  const stop2 = watch(
3424
3424
  created,
@@ -3436,10 +3436,10 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
3436
3436
  }
3437
3437
  function stripFunctions(source) {
3438
3438
  const out = {};
3439
- const descritores = Object.getOwnPropertyDescriptors(toRaw(source));
3439
+ const descriptors = Object.getOwnPropertyDescriptors(toRaw(source));
3440
3440
  for (const [key, value] of Object.entries(source)) {
3441
3441
  if (typeof value === "function") continue;
3442
- if (descritores[key] && !("value" in descritores[key])) continue;
3442
+ if (descriptors[key] && !("value" in descriptors[key])) continue;
3443
3443
  out[key] = value;
3444
3444
  }
3445
3445
  return out;
@@ -3448,11 +3448,11 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
3448
3448
  {},
3449
3449
  {
3450
3450
  get: (_t, key) => {
3451
- void versao.value;
3451
+ void version.value;
3452
3452
  return stores.get(key);
3453
3453
  },
3454
3454
  has: (_t, key) => {
3455
- void versao.value;
3455
+ void version.value;
3456
3456
  return stores.has(key);
3457
3457
  },
3458
3458
  ownKeys: () => [...stores.keys()],
@@ -4395,6 +4395,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
4395
4395
  element.setAttribute("data-type", type);
4396
4396
  element.setAttribute("role", type === "error" ? "alert" : "status");
4397
4397
  element.setAttribute("aria-live", type === "error" ? "assertive" : "polite");
4398
+ element.setAttribute("aria-atomic", "true");
4398
4399
  let closed = false;
4399
4400
  let timer = null;
4400
4401
  const close = () => {
@@ -4726,11 +4727,12 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
4726
4727
  }
4727
4728
  };
4728
4729
  var THEME_KEY = "voodoo:theme";
4730
+ var picked = null;
4729
4731
  var theme = {
4730
4732
  /** Theme chosen by the user, or `system` when never set. */
4731
4733
  get current() {
4732
- var _a2;
4733
- return (_a2 = storage.get(THEME_KEY)) != null ? _a2 : "system";
4734
+ var _a2, _b;
4735
+ return (_b = (_a2 = storage.get(THEME_KEY)) != null ? _a2 : picked) != null ? _b : "system";
4734
4736
  },
4735
4737
  /** Theme effectively applied, resolving `system`. */
4736
4738
  get resolved() {
@@ -4740,6 +4742,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
4740
4742
  return matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
4741
4743
  },
4742
4744
  set(value) {
4745
+ picked = value;
4743
4746
  storage.set(THEME_KEY, value);
4744
4747
  this.apply();
4745
4748
  },
@@ -4750,7 +4753,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
4750
4753
  },
4751
4754
  /** `true` once the visitor has actually picked a theme. */
4752
4755
  get chosen() {
4753
- return storage.get(THEME_KEY) != null;
4756
+ return picked !== null || storage.get(THEME_KEY) != null;
4754
4757
  },
4755
4758
  /** Writes `data-theme` on the root element and notifies the page. */
4756
4759
  apply() {
@@ -4774,7 +4777,8 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
4774
4777
  init() {
4775
4778
  if (typeof document === "undefined") return;
4776
4779
  this.apply();
4777
- matchMedia == null ? void 0 : matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => {
4780
+ if (typeof matchMedia === "undefined") return;
4781
+ matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => {
4778
4782
  if (this.current === "system") this.apply();
4779
4783
  });
4780
4784
  }
@@ -5224,8 +5228,8 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
5224
5228
  defineDirective("text", ({ el, effect: effect2, evaluate: ev }) => {
5225
5229
  effect2(() => {
5226
5230
  el.textContent = stringify(ev());
5227
- const primeiro = el.firstChild;
5228
- if (primeiro && primeiro.nodeType === 3) markInitialized(primeiro);
5231
+ const first = el.firstChild;
5232
+ if (first && first.nodeType === 3) markInitialized(first);
5229
5233
  });
5230
5234
  });
5231
5235
  defineDirective("html", (ctx) => {
@@ -5431,10 +5435,10 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
5431
5435
  next.push({ key, scope: childScope, nodes, data: childScope.data });
5432
5436
  });
5433
5437
  if (batch.fragment.firstChild) (_a3 = anchor.parentNode) == null ? void 0 : _a3.insertBefore(batch.fragment, anchor);
5434
- for (const [node, escopo] of batch.pending) walk(node, escopo);
5435
- const reaproveitados = new Set(next);
5438
+ for (const [node, rowScope] of batch.pending) walk(node, rowScope);
5439
+ const reused = new Set(next);
5436
5440
  for (const block2 of blocks) {
5437
- if (used.has(block2.key) && reaproveitados.has(block2)) continue;
5441
+ if (used.has(block2.key) && reused.has(block2)) continue;
5438
5442
  for (const node of block2.nodes) {
5439
5443
  destroy(node);
5440
5444
  node.remove();
@@ -5504,7 +5508,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
5504
5508
  "novalidate",
5505
5509
  "inert"
5506
5510
  ]);
5507
- var ATRIBUTOS_DE_URL = /* @__PURE__ */ new Set([
5511
+ var URL_ATTRIBUTES = /* @__PURE__ */ new Set([
5508
5512
  "href",
5509
5513
  "src",
5510
5514
  "action",
@@ -5513,15 +5517,15 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
5513
5517
  "ping",
5514
5518
  "poster"
5515
5519
  ]);
5516
- var RUIDO_DE_ESQUEMA = /[\s\x00-\x1f]/g;
5517
- function urlPerigosa(valor) {
5518
- const limpo = valor.replace(RUIDO_DE_ESQUEMA, "").toLowerCase();
5519
- return limpo.startsWith("javascript:") || limpo.startsWith("vbscript:") || limpo.startsWith("data:text/html") || limpo.startsWith("data:application/xhtml");
5520
+ var SCHEME_NOISE = /[\s\x00-\x1f]/g;
5521
+ function isDangerousUrl(value) {
5522
+ const clean = value.replace(SCHEME_NOISE, "").toLowerCase();
5523
+ return clean.startsWith("javascript:") || clean.startsWith("vbscript:") || clean.startsWith("data:text/html") || clean.startsWith("data:application/xhtml");
5520
5524
  }
5521
- function applyBinding(el, name, value, asProp = false, perigoLiberado = false) {
5525
+ function applyBinding(el, name, value, asProp = false, allowDangerous = false) {
5522
5526
  if (name === "class") return applyClass(el, value);
5523
5527
  if (name === "style") return applyStyle(el, value);
5524
- if (config.sanitizeUrls && !perigoLiberado && name === "srcdoc") {
5528
+ if (config.sanitizeUrls && !allowDangerous && name === "srcdoc") {
5525
5529
  warn2(
5526
5530
  `:srcdoc refused in ${describeElement(el)}: the value becomes a document with active script inside the iframe, the same way v-html becomes markup. If the content is trusted, write :srcdoc.dangerous="..."; to turn off this protection on the entire application, set V.config.sanitizeUrls = false.`
5527
5531
  );
@@ -5529,7 +5533,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
5529
5533
  return;
5530
5534
  }
5531
5535
  if (config.sanitizeUrls && !asProp) {
5532
- if (ATRIBUTOS_DE_URL.has(name) && typeof value === "string" && urlPerigosa(value)) {
5536
+ if (URL_ATTRIBUTES.has(name) && typeof value === "string" && isDangerousUrl(value)) {
5533
5537
  warn2(
5534
5538
  `value refused in :${name} of ${describeElement(el)}: "${value.slice(0, 60)}" uses a scheme that executes code. Use an http(s) or relative address. To turn off this protection, set V.config.sanitizeUrls = false.`
5535
5539
  );
@@ -5626,9 +5630,9 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
5626
5630
  }
5627
5631
  if (arg === "key") return;
5628
5632
  const asProp = !!modifiers.prop;
5629
- const perigoLiberado = !!modifiers.dangerous;
5633
+ const allowDangerous = !!modifiers.dangerous;
5630
5634
  effect2(() => {
5631
- applyBinding(el, arg, ev(), asProp, perigoLiberado);
5635
+ applyBinding(el, arg, ev(), asProp, allowDangerous);
5632
5636
  });
5633
5637
  void expression;
5634
5638
  },
@@ -6608,11 +6612,11 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
6608
6612
  Object.defineProperties(rootScope.data, Object.getOwnPropertyDescriptors(values));
6609
6613
  return rootScope.data;
6610
6614
  }
6611
- var version = "0.4.6";
6615
+ var version2 = "0.4.6";
6612
6616
  var core = {
6613
6617
  // Utilities first: Voodoo's own names can override.
6614
6618
  ...utils_exports,
6615
- version,
6619
+ version: version2,
6616
6620
  config,
6617
6621
  // Reactivity
6618
6622
  reactive,
@@ -10285,37 +10289,37 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
10285
10289
  init_registry();
10286
10290
  init_style();
10287
10291
  var messages = {
10288
- required: "Preencha este campo.",
10289
- email: "Informe um e-mail valido.",
10290
- url: "Informe uma URL valida.",
10291
- number: "Informe um numero valido.",
10292
- integer: "Informe um numero inteiro.",
10293
- decimal: "Informe um numero decimal valido.",
10294
- alpha: "Use apenas letras.",
10295
- alphanumeric: "Use apenas letras e numeros.",
10296
- minlength: "Use no minimo {param} caracteres.",
10297
- maxlength: "Use no maximo {param} caracteres.",
10298
- min: "O valor minimo e {param}.",
10299
- max: "O valor maximo e {param}.",
10300
- between: "Informe um valor entre {min} e {max}.",
10301
- match: "Os campos nao conferem.",
10302
- regex: "O formato informado nao e valido.",
10303
- date: "Informe uma data valida.",
10304
- after: "A data precisa ser posterior a {param}.",
10305
- before: "A data precisa ser anterior a {param}.",
10306
- accepted: "E preciso marcar esta opcao para continuar.",
10307
- same: "Os valores precisam ser iguais.",
10308
- different: "Os valores precisam ser diferentes.",
10309
- in: "Escolha uma das opcoes permitidas.",
10310
- notin: "Este valor nao e permitido.",
10311
- phone: "Informe um telefone valido com DDD.",
10312
- cpf: "CPF invalido.",
10313
- cnpj: "CNPJ invalido.",
10314
- cep: "CEP invalido.",
10315
- creditcard: "Numero de cartao invalido.",
10316
- strongpassword: "Use {param} caracteres ou mais, com maiuscula, minuscula, numero e simbolo.",
10317
- unique: "Este valor ja esta em uso.",
10318
- invalid: "Valor invalido."
10292
+ required: "Please fill in this field.",
10293
+ email: "Enter a valid email address.",
10294
+ url: "Enter a valid URL.",
10295
+ number: "Enter a valid number.",
10296
+ integer: "Enter a whole number.",
10297
+ decimal: "Enter a valid decimal number.",
10298
+ alpha: "Use letters only.",
10299
+ alphanumeric: "Use letters and numbers only.",
10300
+ minlength: "Use at least {param} characters.",
10301
+ maxlength: "Use at most {param} characters.",
10302
+ min: "The smallest allowed value is {param}.",
10303
+ max: "The largest allowed value is {param}.",
10304
+ between: "Enter a value between {min} and {max}.",
10305
+ match: "The fields do not match.",
10306
+ regex: "That format is not valid.",
10307
+ date: "Enter a valid date.",
10308
+ after: "The date has to be later than {param}.",
10309
+ before: "The date has to be earlier than {param}.",
10310
+ accepted: "You have to tick this to continue.",
10311
+ same: "The values have to be the same.",
10312
+ different: "The values have to be different.",
10313
+ in: "Choose one of the allowed options.",
10314
+ notin: "That value is not allowed.",
10315
+ phone: "Enter a valid phone number, including the area code.",
10316
+ cpf: "Invalid CPF.",
10317
+ cnpj: "Invalid CNPJ.",
10318
+ cep: "Invalid postcode.",
10319
+ creditcard: "Invalid card number.",
10320
+ strongpassword: "Use {param} characters or more, with an upper case letter, a lower case letter, a number and a symbol.",
10321
+ unique: "That value is already taken.",
10322
+ invalid: "Invalid value."
10319
10323
  };
10320
10324
  function formatMessage(template, data2) {
10321
10325
  var _a2, _b, _c, _d, _e, _f;
@@ -13315,7 +13319,7 @@ textarea.v-dialog-input{min-height:96px;resize:vertical}
13315
13319
  source.remove();
13316
13320
  }
13317
13321
  sourceAnchors.delete(source);
13318
- if (source.hasAttribute(`${config.prefix}modal-content`) || source.hasAttribute("data-v-modal-content")) {
13322
+ if (hasDirective(source, "modal-content")) {
13319
13323
  source.setAttribute("hidden", "");
13320
13324
  }
13321
13325
  }