@sprawlify/vue 0.0.65 → 0.0.66

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.
Files changed (51) hide show
  1. package/dist/clean-props-ChPEW0vT.js +9 -0
  2. package/dist/collapsible-BBV8R9Wm.js +259 -0
  3. package/dist/collection-DR2kMzrX.js +218 -0
  4. package/dist/components/accordion/index.d.ts +195 -0
  5. package/dist/components/accordion/index.js +361 -0
  6. package/dist/components/angle-slider/index.d.ts +230 -0
  7. package/dist/components/angle-slider/index.js +371 -0
  8. package/dist/components/avatar/index.d.ts +116 -0
  9. package/dist/components/avatar/index.js +177 -0
  10. package/dist/components/bottom-sheet/index.d.ts +241 -0
  11. package/dist/components/bottom-sheet/index.js +429 -0
  12. package/dist/components/carousel/index.d.ts +306 -0
  13. package/dist/components/carousel/index.js +500 -0
  14. package/dist/components/checkbox/index.d.ts +273 -0
  15. package/dist/components/checkbox/index.js +500 -0
  16. package/dist/components/client-only/index.d.ts +20 -0
  17. package/dist/components/client-only/index.js +22 -0
  18. package/dist/components/clipboard/index.d.ts +204 -0
  19. package/dist/components/clipboard/index.js +297 -0
  20. package/dist/components/collapsible/index.d.ts +18 -26
  21. package/dist/components/collapsible/index.js +5 -325
  22. package/dist/components/collection/index.d.ts +2 -0
  23. package/dist/components/collection/index.js +4 -0
  24. package/dist/components/field/index.d.ts +326 -0
  25. package/dist/components/field/index.js +7 -0
  26. package/dist/components/fieldset/index.d.ts +161 -0
  27. package/dist/components/fieldset/index.js +7 -0
  28. package/dist/components/presence/index.d.ts +3 -0
  29. package/dist/components/presence/index.js +6 -0
  30. package/dist/components/select/index.d.ts +429 -0
  31. package/dist/components/select/index.js +769 -0
  32. package/dist/{use-forward-expose-BIk4OI3R.js → core-DNndr38p.js} +2 -170
  33. package/dist/create-split-props-YZ3qgXe_.js +11 -0
  34. package/dist/factory-BH3WrWd2.js +68 -0
  35. package/dist/factory-D_ge_w76.d.ts +8 -0
  36. package/dist/field-DnHnX3Tf.js +501 -0
  37. package/dist/fieldset-DzhN7Zrg.js +278 -0
  38. package/dist/{types-BQfkZGpL.d.ts → index-B66Om_3U.d.ts} +1 -9
  39. package/dist/index-DqRk-Yea.d.ts +199 -0
  40. package/dist/index-rHf4D8np.d.ts +57 -0
  41. package/dist/index.d.ts +2 -1
  42. package/dist/index.js +4 -50
  43. package/dist/presence-CvUnYMZQ.js +105 -0
  44. package/dist/presence-types-Bv1E60Cw.d.ts +13 -0
  45. package/dist/providers-B2CNPFg1.js +108 -0
  46. package/dist/types-Bj-dS2Hc.d.ts +9 -0
  47. package/dist/use-forward-expose-4p5AGAI3.js +67 -0
  48. package/dist/use-render-strategy-BkxoN6ll.js +7 -0
  49. package/dist/use-render-strategy-CHj_pCfT.d.ts +9 -0
  50. package/dist/utils-B4FuOOE-.js +51 -0
  51. package/package.json +54 -2
@@ -1,9 +1,7 @@
1
1
  import { INIT_STATE, MachineStatus, createScope, mergeProps as mergeProps$1 } from "@sprawlify/primitives/core";
2
2
  import { createNormalizer } from "@sprawlify/primitives/types";
3
3
  import { compact, ensure, isEqual, isFunction, isString, toArray, warn } from "@sprawlify/primitives/utils";
4
- import { Fragment, computed, createCommentVNode, createElementBlock, defineComponent, getCurrentInstance, inject, nextTick, onBeforeUnmount, onMounted, onUnmounted, openBlock, provide, ref, renderSlot, shallowRef, toValue, watch } from "vue";
5
- import { getDocument, getWindow } from "@sprawlify/primitives/dom-query";
6
- import { createCollator, createFilter, isRTL } from "@sprawlify/primitives/i18n-utils";
4
+ import { computed, nextTick, onBeforeUnmount, onMounted, onUnmounted, shallowRef, toValue, watch } from "vue";
7
5
 
8
6
  //#region src/core/normalize-props.ts
9
7
  function toCase(txt) {
@@ -336,170 +334,4 @@ const flush = (fn) => {
336
334
  };
337
335
 
338
336
  //#endregion
339
- //#region src/utils/run-if-fn.ts
340
- const isFunction$1 = (value) => typeof value === "function";
341
- const runIfFn = (valueOrFn, ...args) => isFunction$1(valueOrFn) ? valueOrFn(...args) : valueOrFn;
342
-
343
- //#endregion
344
- //#region src/utils/create-context.ts
345
- const createContext = (id) => {
346
- const contextId = Symbol(id);
347
- const provider = (value) => provide(contextId, value);
348
- const consumer = (fallback) => inject(contextId, fallback);
349
- return [
350
- provider,
351
- consumer,
352
- contextId
353
- ];
354
- };
355
-
356
- //#endregion
357
- //#region src/providers/environment/use-environment-context.ts
358
- const [EnvironmentContextProvider, useEnvironmentContext] = createContext("EnvironmentContext");
359
- const DEFAULT_ENVIRONMENT = computed(() => ({
360
- getRootNode: () => document,
361
- getDocument: () => document,
362
- getWindow: () => window
363
- }));
364
-
365
- //#endregion
366
- //#region src/providers/environment/environment-provider.vue?vue&type=script&setup=true&lang.ts
367
- var environment_provider_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
368
- __name: "environment-provider",
369
- props: { value: {
370
- type: Function,
371
- required: false,
372
- skipCheck: true
373
- } },
374
- setup(__props) {
375
- const props = __props;
376
- const spanRef = ref(null);
377
- const getRootNode = () => runIfFn(props.value) ?? spanRef.value?.getRootNode() ?? document;
378
- EnvironmentContextProvider(computed(() => ({
379
- getRootNode,
380
- getDocument: () => getDocument(getRootNode()),
381
- getWindow: () => getWindow(getRootNode())
382
- })));
383
- return (_ctx, _cache) => {
384
- return openBlock(), createElementBlock(Fragment, null, [renderSlot(_ctx.$slots, "default"), !props.value ? (openBlock(), createElementBlock("span", {
385
- key: 0,
386
- hidden: "",
387
- ref_key: "spanRef",
388
- ref: spanRef
389
- }, null, 512)) : createCommentVNode("v-if", true)], 64);
390
- };
391
- }
392
- });
393
-
394
- //#endregion
395
- //#region src/providers/environment/environment-provider.vue
396
- var environment_provider_default = environment_provider_vue_vue_type_script_setup_true_lang_default;
397
-
398
- //#endregion
399
- //#region src/providers/locale/use-locale-context.ts
400
- const DEFAULT_LOCALE = computed(() => ({
401
- dir: "ltr",
402
- locale: "en-US"
403
- }));
404
- const [LocaleContextProvider, useLocaleContext] = createContext("LocaleContext");
405
-
406
- //#endregion
407
- //#region src/providers/locale/locale-provider.vue?vue&type=script&setup=true&lang.ts
408
- var locale_provider_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
409
- __name: "locale-provider",
410
- props: { locale: {
411
- type: String,
412
- required: true
413
- } },
414
- setup(__props) {
415
- const props = __props;
416
- LocaleContextProvider(computed(() => ({
417
- locale: props.locale,
418
- dir: isRTL(props.locale) ? "rtl" : "ltr"
419
- })));
420
- return (_ctx, _cache) => {
421
- return renderSlot(_ctx.$slots, "default");
422
- };
423
- }
424
- });
425
-
426
- //#endregion
427
- //#region src/providers/locale/locale-provider.vue
428
- var locale_provider_default = locale_provider_vue_vue_type_script_setup_true_lang_default;
429
-
430
- //#endregion
431
- //#region src/providers/locale/use-collator.ts
432
- function useCollator(propsOrFn = {}) {
433
- const env = useLocaleContext();
434
- return computed(() => {
435
- const props = toValue(propsOrFn);
436
- const locale = props.locale ?? env.value.locale;
437
- const { locale: _, ...options } = props;
438
- return createCollator(locale, options);
439
- });
440
- }
441
-
442
- //#endregion
443
- //#region src/providers/locale/use-filter.ts
444
- function useFilter(props) {
445
- const env = useLocaleContext(DEFAULT_LOCALE);
446
- const locale = computed(() => props.locale ?? env.value.locale);
447
- return computed(() => createFilter({
448
- ...props,
449
- locale: locale.value
450
- }));
451
- }
452
-
453
- //#endregion
454
- //#region src/utils/unref-element.ts
455
- function unrefElement(elRef) {
456
- const plain = toValue(elRef);
457
- return plain?.$el ?? plain;
458
- }
459
-
460
- //#endregion
461
- //#region src/utils/use-forward-expose.ts
462
- const isElement = (el) => Object.prototype.hasOwnProperty.call(el, "nodeName") && typeof el.nodeName === "string";
463
- function useForwardExpose() {
464
- const instance = getCurrentInstance();
465
- const currentRef = ref();
466
- const currentElement = computed(() => {
467
- return ["#text", "#comment"].includes(currentRef.value?.$el.nodeName) ? currentRef.value?.$el.nextElementSibling : unrefElement(currentRef);
468
- });
469
- const localExpose = Object.assign({}, instance.exposed);
470
- const ret = {};
471
- for (const key in instance.props) Object.defineProperty(ret, key, {
472
- enumerable: true,
473
- configurable: true,
474
- get: () => instance.props[key]
475
- });
476
- if (Object.keys(localExpose).length > 0) for (const key in localExpose) Object.defineProperty(ret, key, {
477
- enumerable: true,
478
- configurable: true,
479
- get: () => localExpose[key]
480
- });
481
- Object.defineProperty(ret, "$el", {
482
- enumerable: true,
483
- configurable: true,
484
- get: () => instance.vnode.el
485
- });
486
- instance.exposed = ret;
487
- function forwardRef(ref) {
488
- currentRef.value = ref;
489
- if (isElement(ref) || !ref) return;
490
- Object.defineProperty(ret, "$el", {
491
- enumerable: true,
492
- configurable: true,
493
- get: () => ref.$el
494
- });
495
- instance.exposed = ret;
496
- }
497
- return {
498
- forwardRef,
499
- currentRef,
500
- currentElement
501
- };
502
- }
503
-
504
- //#endregion
505
- export { DEFAULT_LOCALE as a, DEFAULT_ENVIRONMENT as c, mergeProps$1 as d, useMachine as f, locale_provider_default as i, useEnvironmentContext as l, useFilter as n, useLocaleContext as o, normalizeProps$1 as p, useCollator as r, environment_provider_default as s, useForwardExpose as t, createContext as u };
337
+ export { useMachine as n, normalizeProps$1 as r, mergeProps$1 as t };
@@ -0,0 +1,11 @@
1
+ //#region src/components/create-split-props.ts
2
+ const createSplitProps = () => (props, keys) => keys.reduce((previousValue, currentValue) => {
3
+ const [target, source] = previousValue;
4
+ const key = currentValue;
5
+ if (source[key] !== void 0) target[key] = source[key];
6
+ delete source[key];
7
+ return [target, source];
8
+ }, [{}, { ...props }]);
9
+
10
+ //#endregion
11
+ export { createSplitProps as t };
@@ -0,0 +1,68 @@
1
+ import { t as mergeProps$1 } from "./core-DNndr38p.js";
2
+ import { Fragment, cloneVNode, defineComponent, h } from "vue";
3
+
4
+ //#region src/utils/dynamic.ts
5
+ const Dynamic = defineComponent({
6
+ name: "Dynamic",
7
+ inheritAttrs: false,
8
+ setup(_, { attrs, slots }) {
9
+ return () => {
10
+ if (!slots.default) return null;
11
+ const children = renderSlotFragments(slots.default());
12
+ const [firstChildren, ...otherChildren] = children;
13
+ if (Object.keys(attrs).length > 0) {
14
+ delete firstChildren.props?.ref;
15
+ const mergedProps = mergeProps$1(attrs, firstChildren.props ?? {});
16
+ const cloned = cloneVNode(firstChildren, mergedProps);
17
+ for (const prop in mergedProps) if (prop.startsWith("on")) {
18
+ cloned.props ||= {};
19
+ cloned.props[prop] = mergedProps[prop];
20
+ }
21
+ return children.length === 1 ? cloned : [cloned, ...otherChildren];
22
+ }
23
+ return children;
24
+ };
25
+ }
26
+ });
27
+ function renderSlotFragments(children) {
28
+ if (!children) return [];
29
+ return children.flatMap((child) => {
30
+ if (child.type === Fragment) return renderSlotFragments(child.children);
31
+ return [child];
32
+ });
33
+ }
34
+
35
+ //#endregion
36
+ //#region src/components/factory.ts
37
+ const SELF_CLOSING_TAGS = "br, hr, img, input, area, textarea".split(", ");
38
+ const isSelfClosingTag = (tag) => typeof tag === "string" && SELF_CLOSING_TAGS.includes(tag);
39
+ const withAsChild = (component) => {
40
+ return defineComponent({
41
+ name: "Polymorphic",
42
+ inheritAttrs: false,
43
+ props: { asChild: {
44
+ type: Boolean,
45
+ default: false
46
+ } },
47
+ setup(props, { attrs, slots }) {
48
+ if (!props.asChild) return () => h(component, attrs, isSelfClosingTag(component) ? void 0 : slots.default?.());
49
+ return () => h(Dynamic, attrs, slots);
50
+ }
51
+ });
52
+ };
53
+ function jsxFactory() {
54
+ const cache = /* @__PURE__ */ new Map();
55
+ return new Proxy(withAsChild, {
56
+ apply(_target, _thisArg, argArray) {
57
+ return withAsChild(argArray[0]);
58
+ },
59
+ get(_, element) {
60
+ if (!cache.has(element)) cache.set(element, withAsChild(element));
61
+ return cache.get(element);
62
+ }
63
+ });
64
+ }
65
+ const sprawlify = jsxFactory();
66
+
67
+ //#endregion
68
+ export { sprawlify as t };
@@ -0,0 +1,8 @@
1
+ import { h } from "vue";
2
+
3
+ //#region src/components/factory.d.ts
4
+ interface PolymorphicProps {
5
+ asChild?: boolean;
6
+ }
7
+ //#endregion
8
+ export { PolymorphicProps as t };