@ulu/frontend-vue 0.1.0-beta.2 → 0.1.0-beta.21

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 (148) hide show
  1. package/README.md +113 -2
  2. package/dist/{breakpoints-ClT9bfZm.js → breakpoints-DOXmgVoG.js} +1 -1
  3. package/dist/frontend-vue.css +1 -1
  4. package/dist/frontend-vue.js +75 -73
  5. package/dist/index-BpmkfeZb.js +6671 -0
  6. package/lib/components/collapsible/UluAccordion.vue +1 -1
  7. package/lib/components/collapsible/UluModal.vue +4 -5
  8. package/lib/components/collapsible/UluOverflowPopover.vue +1 -1
  9. package/lib/components/elements/UluAlert.vue +1 -2
  10. package/lib/components/elements/UluBadge.vue +27 -28
  11. package/lib/components/elements/UluBadgeStack.vue +8 -13
  12. package/lib/components/elements/UluButton.vue +2 -2
  13. package/lib/components/elements/UluButtonVerbose.vue +119 -0
  14. package/lib/components/elements/UluCard.vue +1 -1
  15. package/lib/components/elements/UluDefinitionList.vue +14 -17
  16. package/lib/components/elements/UluExternalLink.vue +22 -29
  17. package/lib/components/elements/UluIcon.vue +22 -17
  18. package/lib/components/elements/UluList.vue +53 -55
  19. package/lib/components/elements/UluSpokeSpinner.vue +12 -18
  20. package/lib/components/elements/UluTag.vue +35 -35
  21. package/lib/components/forms/UluCheckboxMenu.vue +32 -31
  22. package/lib/components/forms/UluFileDisplay.vue +40 -31
  23. package/lib/components/forms/UluFormFile.vue +22 -24
  24. package/lib/components/forms/UluFormMessage.vue +7 -10
  25. package/lib/components/forms/UluFormSelect.vue +16 -16
  26. package/lib/components/forms/UluFormText.vue +15 -15
  27. package/lib/components/forms/UluSearchForm.vue +8 -10
  28. package/lib/components/index.js +1 -1
  29. package/lib/components/layout/UluAdaptiveLayout.vue +3 -5
  30. package/lib/components/layout/UluTitleRail.vue +9 -5
  31. package/lib/components/layout/UluWhenBreakpoint.vue +71 -77
  32. package/lib/components/navigation/UluBreadcrumb.vue +1 -2
  33. package/lib/components/navigation/UluMenu.vue +3 -3
  34. package/lib/components/navigation/UluPager.vue +102 -0
  35. package/lib/components/systems/facets/ExampleFacetsWithPagination.vue +119 -0
  36. package/lib/components/systems/facets/UluFacetsFilters.vue +73 -0
  37. package/lib/components/systems/facets/UluFacetsList.vue +13 -14
  38. package/lib/components/systems/facets/UluFacetsResults.vue +57 -0
  39. package/lib/components/systems/facets/UluFacetsSearch.vue +26 -49
  40. package/lib/components/systems/facets/UluFacetsSidebarLayout.vue +31 -0
  41. package/lib/components/systems/facets/UluFacetsSort.vue +45 -0
  42. package/lib/components/systems/facets/_facets.scss +2 -3
  43. package/lib/components/systems/facets/_mock-data.js +40 -0
  44. package/lib/components/systems/facets/useFacets.js +221 -0
  45. package/lib/components/systems/index.js +10 -2
  46. package/lib/components/systems/scroll-anchors/UluScrollAnchors.vue +2 -1
  47. package/lib/components/systems/skeleton/UluShowSkeleton.vue +9 -8
  48. package/lib/components/systems/skeleton/UluSkeletonContent.vue +39 -43
  49. package/lib/components/systems/skeleton/UluSkeletonMedia.vue +4 -6
  50. package/lib/components/systems/skeleton/UluSkeletonText.vue +27 -0
  51. package/lib/components/systems/slider/UluImageSlideShow.vue +1 -1
  52. package/lib/components/systems/slider/UluSlideShow.vue +8 -3
  53. package/lib/components/systems/table-sticky/UluTableSticky.vue +8 -8
  54. package/lib/components/systems/table-sticky/UluTableStickyTable.vue +3 -3
  55. package/lib/composables/index.js +3 -1
  56. package/lib/composables/useDocumentTitle.js +47 -0
  57. package/lib/composables/usePageTitle.js +37 -0
  58. package/lib/composables/usePagination.js +122 -0
  59. package/lib/composables/useRequiredInject.js +26 -0
  60. package/lib/index.js +1 -1
  61. package/lib/meta.js +14 -0
  62. package/lib/plugins/core/index.js +91 -0
  63. package/lib/plugins/index.js +1 -0
  64. package/lib/plugins/toast/UluToast.vue +2 -2
  65. package/lib/utils/index.js +2 -0
  66. package/lib/utils/{vue-router.js → router.js} +106 -11
  67. package/package.json +37 -14
  68. package/types/components/index.d.ts +2 -0
  69. package/types/components/index.d.ts.map +1 -0
  70. package/types/components/systems/facets/_mock-data.d.ts +18 -0
  71. package/types/components/systems/facets/_mock-data.d.ts.map +1 -0
  72. package/types/components/systems/facets/useFacets.d.ts +39 -0
  73. package/types/components/systems/facets/useFacets.d.ts.map +1 -0
  74. package/types/components/systems/index.d.ts +2 -0
  75. package/types/components/systems/index.d.ts.map +1 -0
  76. package/types/components/systems/scroll-anchors/symbols.d.ts +7 -0
  77. package/types/components/systems/scroll-anchors/symbols.d.ts.map +1 -0
  78. package/types/composables/index.d.ts +7 -0
  79. package/types/composables/index.d.ts.map +1 -0
  80. package/types/composables/useBreakpointManager.d.ts +8 -0
  81. package/types/composables/useBreakpointManager.d.ts.map +1 -0
  82. package/types/composables/useDocumentTitle.d.ts +18 -0
  83. package/types/composables/useDocumentTitle.d.ts.map +1 -0
  84. package/types/composables/useIcon.d.ts +6 -0
  85. package/types/composables/useIcon.d.ts.map +1 -0
  86. package/types/composables/useModifiers.d.ts +69 -0
  87. package/types/composables/useModifiers.d.ts.map +1 -0
  88. package/types/composables/usePageTitle.d.ts +19 -0
  89. package/types/composables/usePageTitle.d.ts.map +1 -0
  90. package/types/composables/usePagination.d.ts +25 -0
  91. package/types/composables/usePagination.d.ts.map +1 -0
  92. package/types/composables/useRequiredInject.d.ts +8 -0
  93. package/types/composables/useRequiredInject.d.ts.map +1 -0
  94. package/types/composables/useWindowResize.d.ts +6 -0
  95. package/types/composables/useWindowResize.d.ts.map +1 -0
  96. package/types/index.d.ts +5 -0
  97. package/types/index.d.ts.map +1 -0
  98. package/types/meta.d.ts +10 -0
  99. package/types/meta.d.ts.map +1 -0
  100. package/types/plugins/breakpoints/index.d.ts +2 -0
  101. package/types/plugins/breakpoints/index.d.ts.map +1 -0
  102. package/types/plugins/core/index.d.ts +3 -0
  103. package/types/plugins/core/index.d.ts.map +1 -0
  104. package/types/plugins/index.d.ts +6 -0
  105. package/types/plugins/index.d.ts.map +1 -0
  106. package/types/plugins/modals/api.d.ts +34 -0
  107. package/types/plugins/modals/api.d.ts.map +1 -0
  108. package/types/plugins/modals/index.d.ts +28 -0
  109. package/types/plugins/modals/index.d.ts.map +1 -0
  110. package/types/plugins/modals/useModals.d.ts +2 -0
  111. package/types/plugins/modals/useModals.d.ts.map +1 -0
  112. package/types/plugins/popovers/defaults.d.ts +14 -0
  113. package/types/plugins/popovers/defaults.d.ts.map +1 -0
  114. package/types/plugins/popovers/directive.d.ts +8 -0
  115. package/types/plugins/popovers/directive.d.ts.map +1 -0
  116. package/types/plugins/popovers/index.d.ts +7 -0
  117. package/types/plugins/popovers/index.d.ts.map +1 -0
  118. package/types/plugins/popovers/manager.d.ts +52 -0
  119. package/types/plugins/popovers/manager.d.ts.map +1 -0
  120. package/types/plugins/popovers/useFollow.d.ts +31 -0
  121. package/types/plugins/popovers/useFollow.d.ts.map +1 -0
  122. package/types/plugins/popovers/utils.d.ts +2 -0
  123. package/types/plugins/popovers/utils.d.ts.map +1 -0
  124. package/types/plugins/toast/defaults.d.ts +15 -0
  125. package/types/plugins/toast/defaults.d.ts.map +1 -0
  126. package/types/plugins/toast/index.d.ts +5 -0
  127. package/types/plugins/toast/index.d.ts.map +1 -0
  128. package/types/plugins/toast/store.d.ts +22 -0
  129. package/types/plugins/toast/store.d.ts.map +1 -0
  130. package/types/plugins/toast/useToast.d.ts +2 -0
  131. package/types/plugins/toast/useToast.d.ts.map +1 -0
  132. package/types/utils/dom.d.ts +8 -0
  133. package/types/utils/dom.d.ts.map +1 -0
  134. package/types/utils/index.d.ts +3 -0
  135. package/types/utils/index.d.ts.map +1 -0
  136. package/types/utils/placeholder.d.ts +8 -0
  137. package/types/utils/placeholder.d.ts.map +1 -0
  138. package/types/utils/router.d.ts +141 -0
  139. package/types/utils/router.d.ts.map +1 -0
  140. package/types/utils/vue-router.d.ts +122 -0
  141. package/types/utils/vue-router.d.ts.map +1 -0
  142. package/dist/frontend-vue.umd.cjs +0 -561
  143. package/dist/index-P5Rwl_Dl.js +0 -7263
  144. package/lib/components/forms/UluFormDropzone.vue +0 -62
  145. package/lib/components/systems/facets/UluFacets.vue +0 -380
  146. package/lib/components/systems/skeleton/UluSkeletonTextInline.vue +0 -9
  147. package/lib/settings.js +0 -119
  148. package/lib/utils/placeholder.js +0 -6
@@ -3,51 +3,51 @@
3
3
  class="tag"
4
4
  :class="[
5
5
  {
6
- 'tag--small' : small,
7
- 'type-small' : small,
6
+ 'tag--counter' : counter,
7
+ [`tag--${ size }`] : size,
8
8
  [`tag--${ type }`] : type
9
9
  },
10
10
  resolvedModifiers
11
11
  ]"
12
12
  >
13
- <UluIcon v-if="icon" :definition="icon" />
13
+ <UluIcon v-if="icon" :icon="icon" spaced />
14
14
  <slot>
15
- {{ text }}
15
+ <span>{{ text }}</span>
16
16
  </slot>
17
17
  </span>
18
18
  </template>
19
19
 
20
- <script>
20
+ <script setup>
21
21
  import UluIcon from "./UluIcon.vue";
22
22
  import { useModifiers } from "../../composables/useModifiers.js";
23
- export default {
24
- name: "UluTag",
25
- components: {
26
- UluIcon
27
- },
28
- props: {
29
- type: [String],
30
- /**
31
- * Preset to set small modifier and small type size
32
- */
33
- small: Boolean,
34
- /**
35
- * Text for tag, or use slot
36
- */
37
- text: [String, Number],
38
- /**
39
- * Icon prop, if used will set the icon for the button, will use UluIcon (which uses font-awesome icons conditionally)
40
- * - If using custom icons use slot instead
41
- */
42
- icon: [String, Array],
43
- /**
44
- * Modifiers for tag class
45
- */
46
- modifiers: [String, Array]
47
- },
48
- setup(props) {
49
- const { resolvedModifiers } = useModifiers({ props, baseClass: "tag" });
50
- return { resolvedModifiers };
51
- }
52
- };
23
+
24
+ const props = defineProps({
25
+ /**
26
+ * Type (corresponds with styles setup for tag in scss module)
27
+ */
28
+ type: [String],
29
+ /**
30
+ * Size (corresponds with sizes setup for tag in scss module)
31
+ */
32
+ size: String,
33
+ /**
34
+ * Use counter style (for numbers, etc)
35
+ */
36
+ counter: Boolean,
37
+ /**
38
+ * Text for tag, or use slot
39
+ */
40
+ text: [String, Number],
41
+ /**
42
+ * Icon prop, if used will set the icon for the button, will use UluIcon (which uses font-awesome icons conditionally)
43
+ * - If using custom icons use slot instead
44
+ */
45
+ icon: [String, Array],
46
+ /**
47
+ * Modifiers for tag class
48
+ */
49
+ modifiers: [String, Array]
50
+ });
51
+
52
+ const { resolvedModifiers } = useModifiers({ props, baseClass: "tag" });
53
53
  </script>
@@ -1,36 +1,37 @@
1
1
  <template>
2
- <ul class="site-menu site-form">
3
- <li
4
- class="site-menu__item"
5
- v-for="(option, index) in options"
6
- :key="index"
7
- >
8
- <div class="site-menu__checkbox">
9
- <input
10
- type="checkbox"
11
- :id="getId(index)"
12
- v-model="option.checked"
13
- >
14
- <label :for="getId(index)">
15
- <slot>
16
- {{ option?.title || option?.text }}
17
- </slot>
18
- </label>
19
- </div>
20
- </li>
21
- </ul>
2
+ <div class="menu-stack form-theme">
3
+ <ul class="menu-stack__list">
4
+ <li
5
+ class="menu-stack__item"
6
+ v-for="(option, index) in options"
7
+ :key="index"
8
+ >
9
+ <div class="menu-stack__selectable">
10
+ <input
11
+ type="checkbox"
12
+ :id="getId(index)"
13
+ v-model="option.checked"
14
+ >
15
+ <label :for="getId(index)">
16
+ <slot>
17
+ {{ option?.title || option?.text }}
18
+ </slot>
19
+ </label>
20
+ </div>
21
+ </li>
22
+ </ul>
23
+ </div>
22
24
  </template>
23
25
 
24
- <script>
25
- export default {
26
- name: "UluCheckboxMenu",
27
- props: {
28
- options: Array
29
- },
30
- methods: {
31
- getId(index) {
32
- return `checkbox-menu-opt-${ index }`;
33
- }
34
- }
26
+ <script setup>
27
+ defineProps({
28
+ /**
29
+ * Checkbox items in [{ title|text, checked }, ...]
30
+ */
31
+ options: Array
32
+ });
33
+
34
+ const getId = (index) => {
35
+ return `checkbox-menu-opt-${ index }`;
35
36
  };
36
37
  </script>
@@ -1,39 +1,48 @@
1
1
  <template>
2
2
  <a class="layout-flex-baseline" :href="fileUrl" :download="file.name">
3
- <FaIcon class="ui-icon" :icon="['far', $site.getIcon('file')]"/>
4
- <span class="margin-left-small-x">
5
- {{ file.name }}
6
- <span class="tag tag--small tag--outline type-small-x">{{ fileSize }}</span>
7
- </span>
3
+ <slot :fileName="file.name" :fileSize="fileSize">
4
+ <UluIcon class="ui-icon" :icon="icon"/>
5
+ <span class="margin-left-small-x">
6
+ {{ file.name }}
7
+ <UluTag v-if="!noFileSize" :text="fileSize" small outline />
8
+ </span>
9
+ </slot>
8
10
  </a>
9
11
  </template>
10
12
 
11
- <script>
12
- export default {
13
- name: "FileDisplay",
14
- props: {
15
- file: {
16
- required: true,
17
- type: Object
18
- }
13
+ <script setup>
14
+ import { computed } from "vue";
15
+ import UluIcon from "../elements/UluIcon.vue";
16
+ import UluTag from "../elements/UluTag.vue";
17
+
18
+ const props = defineProps({
19
+ file: {
20
+ required: true,
21
+ type: Object,
19
22
  },
20
- computed: {
21
- fileUrl() {
22
- return window.URL.createObjectURL(this.file);
23
- },
24
- fileSize() {
25
- const { size } = this.file;
26
- const Mbs = size / 1000000;
27
- const Kbs = size / 1000;
28
- const format = n => parseFloat(n.toFixed(2));
29
- // Either display Mbs or Kbs if less than 1 Mb
30
- /* eslint-disable */
31
- return Mbs > 1 ?
32
- `${ format(Mbs) }Mb` : Kbs > 1 ?
33
- `${ format(Kbs) }Kb` :
34
- `${ format(size) }B`;
35
- /* eslint-enable */
36
- }
23
+ icon: {
24
+ type: String,
25
+ default: "type:file"
37
26
  },
38
- };
27
+ noFileSize: Boolean
28
+ });
29
+
30
+ const fileUrl = computed(() => {
31
+ if (typeof window === 'undefined') return '';
32
+ return window.URL.createObjectURL(props.file);
33
+ });
34
+
35
+ const fileSize = computed(() => {
36
+ const { size } = props.file;
37
+ const Mbs = size / 1000000;
38
+ const Kbs = size / 1000;
39
+ const format = n => parseFloat(n.toFixed(2));
40
+ // Either display Mbs or Kbs if less than 1 Mb
41
+ /* eslint-disable */
42
+ return Mbs > 1 ?
43
+ `${ format(Mbs) }Mb` : Kbs > 1 ?
44
+ `${ format(Kbs) }Kb` :
45
+ `${ format(size) }B`;
46
+ /* eslint-enable */
47
+ });
39
48
  </script>
@@ -18,30 +18,28 @@
18
18
  </div>
19
19
  </template>
20
20
 
21
- <script>
22
- let count = 0;
23
- export default {
24
- name: "FormFile",
25
- props: {
26
- label: {
27
- type: String,
28
- default: "Select File"
29
- },
30
- labelHidden: Boolean,
31
- noClasses: Boolean,
32
- multiple: Boolean,
33
- inputAttrs: Object
34
- },
35
- emits: ["filesChange"],
36
- data() {
37
- return {
38
- id: `file-input-id-${ ++count }`
39
- };
21
+ <script setup>
22
+ const getNextId = (() => {
23
+ let count = 0;
24
+ return () => `file-input-id-${++count}`;
25
+ })();
26
+
27
+ defineProps({
28
+ label: {
29
+ type: String,
30
+ default: "Select File"
40
31
  },
41
- methods: {
42
- onChangeFile(event) {
43
- this.$emit("filesChange", event.target.files);
44
- }
45
- }
32
+ labelHidden: Boolean,
33
+ noClasses: Boolean,
34
+ multiple: Boolean,
35
+ inputAttrs: Object
36
+ });
37
+
38
+ const emit = defineEmits(["file-change"]);
39
+
40
+ const id = getNextId();
41
+
42
+ const onChangeFile = (event) => {
43
+ emit("file-change", event.target.files);
46
44
  };
47
45
  </script>
@@ -3,18 +3,15 @@
3
3
  'site-form__error' : error,
4
4
  'site-form__warning' : warning
5
5
  }">
6
- <FaIcon v-if="error" :icon="$site.getIcon('error')"/>
7
- <FaIcon v-if="warning" :icon="$site.getIcon('warning')"/>
6
+ <UluIcon v-if="error || warning" :icon="`type:${ error ? 'error' : 'warning' }`" />
8
7
  <slot/>
9
8
  </p>
10
9
  </template>
11
10
 
12
- <script>
13
- export default {
14
- name: "FormMessage",
15
- props: {
16
- warning: Boolean,
17
- error: Boolean,
18
- }
19
- };
11
+ <script setup>
12
+ import UluIcon from "../elements/UluIcon.vue";
13
+ defineProps({
14
+ warning: Boolean,
15
+ error: Boolean,
16
+ });
20
17
  </script>
@@ -18,20 +18,20 @@
18
18
  </div>
19
19
  </template>
20
20
 
21
- <script>
22
- let count = 0;
23
- export default {
24
- name: "FormSelect",
25
- props: {
26
- label: String,
27
- modelValue: String,
28
- options: Array,
29
- labelHidden: Boolean
30
- },
31
- data() {
32
- return {
33
- id: `select-id-${ ++count }`
34
- };
35
- }
36
- };
21
+ <script setup>
22
+ const getNextId = (() => {
23
+ let count = 0;
24
+ return () => `select-id-${++count}`;
25
+ })();
26
+
27
+ defineProps({
28
+ label: String,
29
+ modelValue: String,
30
+ options: Array,
31
+ labelHidden: Boolean
32
+ });
33
+
34
+ defineEmits(['update:modelValue']);
35
+
36
+ const id = getNextId();
37
37
  </script>
@@ -14,19 +14,19 @@
14
14
  </div>
15
15
  </template>
16
16
 
17
- <script>
18
- let count = 0;
19
- export default {
20
- name: "FormText",
21
- props: {
22
- label: String,
23
- modelValue: String,
24
- labelHidden: Boolean
25
- },
26
- data() {
27
- return {
28
- id: `text-input-id-${ ++count }`
29
- };
30
- }
31
- };
17
+ <script setup>
18
+ const getNextId = (() => {
19
+ let count = 0;
20
+ return () => `text-input-id-${++count}`;
21
+ })();
22
+
23
+ defineProps({
24
+ label: String,
25
+ modelValue: String,
26
+ labelHidden: Boolean
27
+ });
28
+
29
+ defineEmits(['update:modelValue']);
30
+
31
+ const id = getNextId();
32
32
  </script>
@@ -13,19 +13,17 @@
13
13
  class="search-form__submit button button--primary"
14
14
  aria-label="Submit Search"
15
15
  >
16
- <FaIcon :icon="$site.getIcon('search')"/>
16
+ <UluIcon icon="type:search" />
17
17
  </button>
18
18
  </div>
19
19
  </template>
20
20
 
21
- <script>
22
- export default {
23
- name: "SearchForm",
24
- props: {
25
- placeholder: {
26
- type: String,
27
- default: "Titles, keyword…"
28
- }
21
+ <script setup>
22
+ import UluIcon from "../elements/UluIcon.vue";
23
+ defineProps({
24
+ placeholder: {
25
+ type: String,
26
+ default: "Titles, keyword…"
29
27
  }
30
- };
28
+ });
31
29
  </script>
@@ -17,6 +17,7 @@ export { default as UluAlert } from './elements/UluAlert.vue';
17
17
  export { default as UluBadge } from './elements/UluBadge.vue';
18
18
  export { default as UluBadgeStack } from './elements/UluBadgeStack.vue';
19
19
  export { default as UluButton } from './elements/UluButton.vue';
20
+ export { default as UluButtonVerbose } from './elements/UluButtonVerbose.vue';
20
21
  export { default as UluCallout } from './elements/UluCallout.vue';
21
22
  export { default as UluCard } from './elements/UluCard.vue';
22
23
  export { default as UluDefinitionList } from './elements/UluDefinitionList.vue';
@@ -28,7 +29,6 @@ export { default as UluSpokeSpinner } from './elements/UluSpokeSpinner.vue';
28
29
  export { default as UluTag } from './elements/UluTag.vue';
29
30
  export { default as UluCheckboxMenu } from './forms/UluCheckboxMenu.vue';
30
31
  export { default as UluFileDisplay } from './forms/UluFileDisplay.vue';
31
- export { default as UluFormDropzone } from './forms/UluFormDropzone.vue';
32
32
  export { default as UluFormFile } from './forms/UluFormFile.vue';
33
33
  export { default as UluFormMessage } from './forms/UluFormMessage.vue';
34
34
  export { default as UluFormSelect } from './forms/UluFormSelect.vue';
@@ -3,9 +3,7 @@
3
3
  <slot v-else name="mobile" />
4
4
  </template>
5
5
 
6
- <script>
7
- export default {
8
- name: "AdaptiveLayout",
9
- inject: ["uluIsMobile"],
10
- };
6
+ <script setup>
7
+ import { useRequiredInject } from '../../composables/useRequiredInject.js';
8
+ const uluIsMobile = useRequiredInject('uluIsMobile');
11
9
  </script>
@@ -1,5 +1,10 @@
1
1
  <template>
2
- <div class="rail rail--title-rail">
2
+ <div
3
+ class="rail rail--title-rail"
4
+ :class="{
5
+ 'rail--rule' : rule
6
+ }"
7
+ >
3
8
  <div class="rail__item rail__item--title" :class="classes.itemTitle">
4
9
  <component
5
10
  class="layout-flex type-max-width-small no-margin"
@@ -8,10 +13,9 @@
8
13
  :style="{ alignItems: iconAlign }"
9
14
  >
10
15
  <UluIcon
11
- v-if="icon || iconType"
16
+ v-if="icon"
12
17
  :class="classes.icon"
13
- :type="iconType"
14
- :definition="icon"
18
+ :icon="icon"
15
19
  />
16
20
  <slot>
17
21
  {{ title }}
@@ -38,7 +42,6 @@
38
42
  type: String,
39
43
  default: "baseline"
40
44
  },
41
- iconType: String,
42
45
  classes: {
43
46
  type: Object,
44
47
  default: () => ({
@@ -51,6 +54,7 @@
51
54
  type: String,
52
55
  default: "h2"
53
56
  },
57
+ rule: Boolean
54
58
  }
55
59
  }
56
60
  </script>
@@ -2,85 +2,79 @@
2
2
  <slot v-if="shouldShow" />
3
3
  </template>
4
4
 
5
- <script>
6
- export default {
7
- name: "UluWhenBreakpoint",
8
- inject: ["uluBreakpointManager"],
9
- props: {
10
- max: String,
11
- min: String,
12
- only: String,
13
- },
14
- data() {
15
- return {
16
- conditions: {},
17
- handlers: [],
18
- handlersSetup: false,
19
- };
20
- },
21
- computed: {
22
- shouldShow() {
23
- if (!this.handlersSetup) return false;
24
- const props = ['max', 'min', 'only'].filter(p => this[p]);
25
- if (props.length === 0) {
26
- return false;
27
- }
28
- return Object.values(this.conditions).every(c => c);
29
- },
30
- propsIdentifier() {
31
- return `${this.max || ''}-${this.min || ''}-${this.only || ''}`;
32
- }
33
- },
34
- watch: {
35
- uluBreakpointManager: {
36
- handler(manager) {
37
- if (manager && !this.handlersSetup) {
38
- this.setupHandlers(manager);
39
- }
40
- },
41
- immediate: true
42
- },
43
- propsIdentifier() {
44
- if (this.uluBreakpointManager && this.handlersSetup) {
45
- this.tearDownHandlers();
46
- this.setupHandlers(this.uluBreakpointManager);
47
- }
48
- }
49
- },
50
- methods: {
51
- setupHandlers(manager) {
52
- const setupCondition = (direction) => {
53
- const breakpointName = this[direction];
54
- if (breakpointName) {
55
- this.conditions[direction] = false;
56
- const handler = {
57
- on: () => { this.conditions[direction] = true; },
58
- off: () => { this.conditions[direction] = false; },
59
- };
60
- manager.at(breakpointName)[direction](handler);
61
- this.handlers.push({ name: breakpointName, direction, handler });
62
- }
63
- };
5
+ <script setup>
6
+ import { ref, computed, watch, onBeforeUnmount } from 'vue';
7
+ import { useRequiredInject } from '../../composables/useRequiredInject.js';
8
+
9
+ const props = defineProps({
10
+ max: String,
11
+ min: String,
12
+ only: String,
13
+ });
64
14
 
65
- setupCondition('max');
66
- setupCondition('min');
67
- setupCondition('only');
15
+ const uluBreakpointManager = useRequiredInject('uluBreakpointManager');
68
16
 
69
- this.handlersSetup = true;
70
- },
71
- tearDownHandlers() {
72
- if (this.uluBreakpointManager) {
73
- this.handlers.forEach(({ name, direction, handler }) => {
74
- this.uluBreakpointManager.at(name).remove(handler, direction);
75
- });
76
- }
77
- this.handlers = [];
78
- this.conditions = {};
79
- this.handlersSetup = false;
17
+ const conditions = ref({});
18
+ const handlers = ref([]);
19
+ const handlersSetup = ref(false);
20
+
21
+ const shouldShow = computed(() => {
22
+ if (!handlersSetup.value) return false;
23
+ const activeProps = ['max', 'min', 'only'].filter(p => props[p]);
24
+ if (activeProps.length === 0) {
25
+ return false;
26
+ }
27
+ return Object.values(conditions.value).every(c => c);
28
+ });
29
+
30
+ const setupHandlers = (manager) => {
31
+ const setupCondition = (direction) => {
32
+ const breakpointName = props[direction];
33
+ if (breakpointName) {
34
+ conditions.value[direction] = false;
35
+ const handler = {
36
+ on: () => { conditions.value[direction] = true; },
37
+ off: () => { conditions.value[direction] = false; },
38
+ };
39
+ manager.at(breakpointName)[direction](handler);
40
+ handlers.value.push({ name: breakpointName, direction, handler });
80
41
  }
81
- },
82
- beforeUnmount() {
83
- this.tearDownHandlers();
84
- },
42
+ };
43
+
44
+ setupCondition('max');
45
+ setupCondition('min');
46
+ setupCondition('only');
47
+
48
+ handlersSetup.value = true;
49
+ };
50
+
51
+ const tearDownHandlers = () => {
52
+ if (uluBreakpointManager) {
53
+ handlers.value.forEach(({ name, direction, handler }) => {
54
+ uluBreakpointManager.at(name).remove(handler, direction);
55
+ });
56
+ }
57
+ handlers.value = [];
58
+ conditions.value = {};
59
+ handlersSetup.value = false;
85
60
  };
61
+
62
+ watch(uluBreakpointManager, (manager) => {
63
+ if (manager && !handlersSetup.value) {
64
+ setupHandlers(manager);
65
+ }
66
+ }, { immediate: true });
67
+
68
+ // Watch all the props and update if they change
69
+ // - Using array syntax to avoid "deep" flag
70
+ watch([() => props.max, () => props.min, () => props.only], () => {
71
+ if (uluBreakpointManager && handlersSetup.value) {
72
+ tearDownHandlers();
73
+ setupHandlers(uluBreakpointManager);
74
+ }
75
+ });
76
+
77
+ onBeforeUnmount(() => {
78
+ tearDownHandlers();
79
+ });
86
80
  </script>
@@ -19,8 +19,7 @@
19
19
  <slot name="separator">
20
20
  <UluIcon
21
21
  :class="classes.separator"
22
- type="pathSeparator"
23
- :definition="separatorIcon"
22
+ :icon="separatorIcon || 'type:pathSeparator'"
24
23
  />
25
24
  </slot>
26
25
  </template>