voodoojs 0.5.0 → 0.6.1

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()],
@@ -4727,11 +4727,12 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
4727
4727
  }
4728
4728
  };
4729
4729
  var THEME_KEY = "voodoo:theme";
4730
+ var picked = null;
4730
4731
  var theme = {
4731
4732
  /** Theme chosen by the user, or `system` when never set. */
4732
4733
  get current() {
4733
- var _a2;
4734
- 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";
4735
4736
  },
4736
4737
  /** Theme effectively applied, resolving `system`. */
4737
4738
  get resolved() {
@@ -4741,6 +4742,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
4741
4742
  return matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
4742
4743
  },
4743
4744
  set(value) {
4745
+ picked = value;
4744
4746
  storage.set(THEME_KEY, value);
4745
4747
  this.apply();
4746
4748
  },
@@ -4751,7 +4753,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
4751
4753
  },
4752
4754
  /** `true` once the visitor has actually picked a theme. */
4753
4755
  get chosen() {
4754
- return storage.get(THEME_KEY) != null;
4756
+ return picked !== null || storage.get(THEME_KEY) != null;
4755
4757
  },
4756
4758
  /** Writes `data-theme` on the root element and notifies the page. */
4757
4759
  apply() {
@@ -4775,7 +4777,8 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
4775
4777
  init() {
4776
4778
  if (typeof document === "undefined") return;
4777
4779
  this.apply();
4778
- 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", () => {
4779
4782
  if (this.current === "system") this.apply();
4780
4783
  });
4781
4784
  }
@@ -5225,8 +5228,8 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
5225
5228
  defineDirective("text", ({ el, effect: effect2, evaluate: ev }) => {
5226
5229
  effect2(() => {
5227
5230
  el.textContent = stringify(ev());
5228
- const primeiro = el.firstChild;
5229
- if (primeiro && primeiro.nodeType === 3) markInitialized(primeiro);
5231
+ const first = el.firstChild;
5232
+ if (first && first.nodeType === 3) markInitialized(first);
5230
5233
  });
5231
5234
  });
5232
5235
  defineDirective("html", (ctx) => {
@@ -5432,10 +5435,10 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
5432
5435
  next.push({ key, scope: childScope, nodes, data: childScope.data });
5433
5436
  });
5434
5437
  if (batch.fragment.firstChild) (_a3 = anchor.parentNode) == null ? void 0 : _a3.insertBefore(batch.fragment, anchor);
5435
- for (const [node, escopo] of batch.pending) walk(node, escopo);
5436
- const reaproveitados = new Set(next);
5438
+ for (const [node, rowScope] of batch.pending) walk(node, rowScope);
5439
+ const reused = new Set(next);
5437
5440
  for (const block2 of blocks) {
5438
- if (used.has(block2.key) && reaproveitados.has(block2)) continue;
5441
+ if (used.has(block2.key) && reused.has(block2)) continue;
5439
5442
  for (const node of block2.nodes) {
5440
5443
  destroy(node);
5441
5444
  node.remove();
@@ -5505,7 +5508,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
5505
5508
  "novalidate",
5506
5509
  "inert"
5507
5510
  ]);
5508
- var ATRIBUTOS_DE_URL = /* @__PURE__ */ new Set([
5511
+ var URL_ATTRIBUTES = /* @__PURE__ */ new Set([
5509
5512
  "href",
5510
5513
  "src",
5511
5514
  "action",
@@ -5514,15 +5517,15 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
5514
5517
  "ping",
5515
5518
  "poster"
5516
5519
  ]);
5517
- var RUIDO_DE_ESQUEMA = /[\s\x00-\x1f]/g;
5518
- function urlPerigosa(valor) {
5519
- const limpo = valor.replace(RUIDO_DE_ESQUEMA, "").toLowerCase();
5520
- 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");
5521
5524
  }
5522
- function applyBinding(el, name, value, asProp = false, perigoLiberado = false) {
5525
+ function applyBinding(el, name, value, asProp = false, allowDangerous = false) {
5523
5526
  if (name === "class") return applyClass(el, value);
5524
5527
  if (name === "style") return applyStyle(el, value);
5525
- if (config.sanitizeUrls && !perigoLiberado && name === "srcdoc") {
5528
+ if (config.sanitizeUrls && !allowDangerous && name === "srcdoc") {
5526
5529
  warn2(
5527
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.`
5528
5531
  );
@@ -5530,7 +5533,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
5530
5533
  return;
5531
5534
  }
5532
5535
  if (config.sanitizeUrls && !asProp) {
5533
- if (ATRIBUTOS_DE_URL.has(name) && typeof value === "string" && urlPerigosa(value)) {
5536
+ if (URL_ATTRIBUTES.has(name) && typeof value === "string" && isDangerousUrl(value)) {
5534
5537
  warn2(
5535
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.`
5536
5539
  );
@@ -5627,9 +5630,9 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
5627
5630
  }
5628
5631
  if (arg === "key") return;
5629
5632
  const asProp = !!modifiers.prop;
5630
- const perigoLiberado = !!modifiers.dangerous;
5633
+ const allowDangerous = !!modifiers.dangerous;
5631
5634
  effect2(() => {
5632
- applyBinding(el, arg, ev(), asProp, perigoLiberado);
5635
+ applyBinding(el, arg, ev(), asProp, allowDangerous);
5633
5636
  });
5634
5637
  void expression;
5635
5638
  },
@@ -6609,11 +6612,11 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
6609
6612
  Object.defineProperties(rootScope.data, Object.getOwnPropertyDescriptors(values));
6610
6613
  return rootScope.data;
6611
6614
  }
6612
- var version = "0.4.6";
6615
+ var version2 = "0.4.6";
6613
6616
  var core = {
6614
6617
  // Utilities first: Voodoo's own names can override.
6615
6618
  ...utils_exports,
6616
- version,
6619
+ version: version2,
6617
6620
  config,
6618
6621
  // Reactivity
6619
6622
  reactive,
@@ -10286,37 +10289,37 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
10286
10289
  init_registry();
10287
10290
  init_style();
10288
10291
  var messages = {
10289
- required: "Preencha este campo.",
10290
- email: "Informe um e-mail valido.",
10291
- url: "Informe uma URL valida.",
10292
- number: "Informe um numero valido.",
10293
- integer: "Informe um numero inteiro.",
10294
- decimal: "Informe um numero decimal valido.",
10295
- alpha: "Use apenas letras.",
10296
- alphanumeric: "Use apenas letras e numeros.",
10297
- minlength: "Use no minimo {param} caracteres.",
10298
- maxlength: "Use no maximo {param} caracteres.",
10299
- min: "O valor minimo e {param}.",
10300
- max: "O valor maximo e {param}.",
10301
- between: "Informe um valor entre {min} e {max}.",
10302
- match: "Os campos nao conferem.",
10303
- regex: "O formato informado nao e valido.",
10304
- date: "Informe uma data valida.",
10305
- after: "A data precisa ser posterior a {param}.",
10306
- before: "A data precisa ser anterior a {param}.",
10307
- accepted: "E preciso marcar esta opcao para continuar.",
10308
- same: "Os valores precisam ser iguais.",
10309
- different: "Os valores precisam ser diferentes.",
10310
- in: "Escolha uma das opcoes permitidas.",
10311
- notin: "Este valor nao e permitido.",
10312
- phone: "Informe um telefone valido com DDD.",
10313
- cpf: "CPF invalido.",
10314
- cnpj: "CNPJ invalido.",
10315
- cep: "CEP invalido.",
10316
- creditcard: "Numero de cartao invalido.",
10317
- strongpassword: "Use {param} caracteres ou mais, com maiuscula, minuscula, numero e simbolo.",
10318
- unique: "Este valor ja esta em uso.",
10319
- 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."
10320
10323
  };
10321
10324
  function formatMessage(template, data2) {
10322
10325
  var _a2, _b, _c, _d, _e, _f;
@@ -13316,7 +13319,7 @@ textarea.v-dialog-input{min-height:96px;resize:vertical}
13316
13319
  source.remove();
13317
13320
  }
13318
13321
  sourceAnchors.delete(source);
13319
- if (source.hasAttribute(`${config.prefix}modal-content`) || source.hasAttribute("data-v-modal-content")) {
13322
+ if (hasDirective(source, "modal-content")) {
13320
13323
  source.setAttribute("hidden", "");
13321
13324
  }
13322
13325
  }