@xy-planning-network/trees 0.3.4 → 0.4.0-rc-3

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 (73) hide show
  1. package/dist/style.css +1 -0
  2. package/dist/trees.es.js +8399 -0
  3. package/dist/trees.umd.js +10 -0
  4. package/dist/types/api/base.d.ts +12 -0
  5. package/dist/types/entry.d.ts +8 -0
  6. package/dist/types/helpers/Uniques.d.ts +4 -0
  7. package/dist/types/lib-components/forms/BaseInput.vue.d.ts +38 -0
  8. package/dist/types/lib-components/forms/Checkbox.vue.d.ts +22 -0
  9. package/dist/types/lib-components/forms/DateRangePicker.vue.d.ts +45 -0
  10. package/dist/types/lib-components/forms/InputHelp.vue.d.ts +22 -0
  11. package/dist/types/lib-components/forms/InputLabel.vue.d.ts +22 -0
  12. package/dist/types/lib-components/forms/MultiCheckboxes.vue.d.ts +34 -0
  13. package/dist/types/lib-components/forms/Radio.vue.d.ts +44 -0
  14. package/dist/types/lib-components/forms/Select.vue.d.ts +58 -0
  15. package/dist/types/lib-components/forms/TextArea.vue.d.ts +32 -0
  16. package/dist/types/lib-components/forms/Toggle.vue.d.ts +17 -0
  17. package/dist/types/lib-components/forms/YesOrNoRadio.vue.d.ts +33 -0
  18. package/dist/types/lib-components/index.d.ts +64 -0
  19. package/dist/types/lib-components/layout/DateFilter.vue.d.ts +34 -0
  20. package/dist/types/lib-components/layout/SidebarLayout.vue.d.ts +33 -0
  21. package/dist/types/lib-components/layout/StackedLayout.vue.d.ts +40 -0
  22. package/dist/types/lib-components/lists/Cards.vue.d.ts +23 -0
  23. package/dist/types/lib-components/lists/DetailList.vue.d.ts +34 -0
  24. package/dist/types/lib-components/lists/DownloadCell.vue.d.ts +20 -0
  25. package/dist/types/lib-components/lists/StaticTable.vue.d.ts +18 -0
  26. package/dist/types/lib-components/lists/Table.vue.d.ts +29 -0
  27. package/dist/types/lib-components/navigation/ActionsDropdown.vue.d.ts +26 -0
  28. package/dist/types/lib-components/navigation/Paginator.vue.d.ts +27 -0
  29. package/dist/types/lib-components/navigation/Steps.vue.d.ts +53 -0
  30. package/dist/types/lib-components/navigation/Tabs.vue.d.ts +36 -0
  31. package/dist/types/lib-components/overlays/ContentModal.vue.d.ts +24 -0
  32. package/dist/types/lib-components/overlays/Flash.vue.d.ts +6 -0
  33. package/dist/types/lib-components/overlays/Modal.vue.d.ts +51 -0
  34. package/dist/types/lib-components/overlays/Slideover.vue.d.ts +30 -0
  35. package/dist/types/lib-components/overlays/Spinner.vue.d.ts +2 -0
  36. package/dist/types/types/nav.d.ts +7 -0
  37. package/dist/types/types/table.d.ts +32 -0
  38. package/dist/types/types/users.d.ts +9 -0
  39. package/package.json +47 -66
  40. package/src/lib-components/forms/BaseInput.vue +51 -45
  41. package/src/lib-components/forms/Checkbox.vue +31 -22
  42. package/src/lib-components/forms/DateRangePicker.vue +56 -56
  43. package/src/lib-components/forms/InputHelp.vue +12 -9
  44. package/src/lib-components/forms/InputLabel.vue +12 -9
  45. package/src/lib-components/forms/MultiCheckboxes.vue +48 -44
  46. package/src/lib-components/forms/Radio.vue +34 -24
  47. package/src/lib-components/forms/Select.vue +40 -46
  48. package/src/lib-components/forms/TextArea.vue +23 -17
  49. package/src/lib-components/forms/Toggle.vue +7 -11
  50. package/src/lib-components/forms/YesOrNoRadio.vue +31 -27
  51. package/src/lib-components/layout/DateFilter.vue +31 -30
  52. package/src/lib-components/layout/SidebarLayout.vue +36 -51
  53. package/src/lib-components/layout/StackedLayout.vue +32 -55
  54. package/src/lib-components/lists/Cards.vue +8 -12
  55. package/src/lib-components/lists/DetailList.vue +83 -83
  56. package/src/lib-components/lists/DownloadCell.vue +8 -12
  57. package/src/lib-components/lists/StaticTable.vue +30 -23
  58. package/src/lib-components/lists/Table.vue +146 -122
  59. package/src/lib-components/navigation/ActionsDropdown.vue +39 -43
  60. package/src/lib-components/navigation/Paginator.vue +65 -80
  61. package/src/lib-components/navigation/Steps.vue +38 -27
  62. package/src/lib-components/navigation/Tabs.vue +64 -60
  63. package/src/lib-components/overlays/ContentModal.vue +27 -31
  64. package/src/lib-components/overlays/Flash.vue +85 -70
  65. package/src/lib-components/overlays/Modal.vue +39 -42
  66. package/src/lib-components/overlays/Slideover.vue +30 -35
  67. package/src/lib-components/overlays/Spinner.vue +51 -51
  68. package/src/types/env.d.ts +18 -0
  69. package/src/types/global.d.ts +10 -0
  70. package/dist/trees.esm.js +0 -10994
  71. package/dist/trees.min.js +0 -7
  72. package/dist/trees.ssr.js +0 -11669
  73. package/trees.d.ts +0 -43
@@ -1,3 +1,39 @@
1
+ <script setup lang="ts">
2
+ import Flash from "../overlays/Flash.vue"
3
+ import Spinner from "../overlays/Spinner.vue"
4
+ import {
5
+ Dialog,
6
+ DialogOverlay,
7
+ Menu,
8
+ MenuButton,
9
+ MenuItem,
10
+ MenuItems,
11
+ TransitionChild,
12
+ TransitionRoot,
13
+ } from "@headlessui/vue"
14
+ import { MenuAlt2Icon, XIcon } from "@heroicons/vue/outline"
15
+ import { CogIcon } from "@heroicons/vue/solid"
16
+ import * as NavTypes from "../../types/nav"
17
+ import { ref } from "vue"
18
+
19
+ const props = withDefaults(
20
+ defineProps<{
21
+ activeURL?: string
22
+ iconURL: string
23
+ navigation: NavTypes.Item[]
24
+ userNavigation: NavTypes.Item[]
25
+ }>(),
26
+ {
27
+ activeURL: "",
28
+ }
29
+ )
30
+
31
+ const sidebarOpen = ref<boolean>(true)
32
+
33
+ const isActive = (url: string): boolean => {
34
+ return props.activeURL === url
35
+ }
36
+ </script>
1
37
  <template>
2
38
  <div class="h-screen flex overflow-hidden bg-gray-100">
3
39
  <TransitionRoot as="template" :show="sidebarOpen">
@@ -201,54 +237,3 @@
201
237
  <Flash />
202
238
  <Spinner />
203
239
  </template>
204
-
205
- <script lang="ts">
206
- import { Options, Prop, Vue } from "vue-property-decorator";
207
- import Flash from "../overlays/Flash.vue";
208
- import Spinner from "../overlays/Spinner.vue";
209
- import {
210
- Dialog,
211
- DialogOverlay,
212
- Menu,
213
- MenuButton,
214
- MenuItem,
215
- MenuItems,
216
- TransitionChild,
217
- TransitionRoot,
218
- } from "@headlessui/vue";
219
- import { MenuAlt2Icon, UserCircleIcon, XIcon } from "@heroicons/vue/outline";
220
- import { CogIcon } from "@heroicons/vue/solid";
221
- import NavTypes from "../../types/nav";
222
-
223
- @Options({
224
- components: {
225
- Flash,
226
- Spinner,
227
- Dialog,
228
- DialogOverlay,
229
- Menu,
230
- MenuButton,
231
- MenuItem,
232
- MenuItems,
233
- TransitionChild,
234
- TransitionRoot,
235
- CogIcon,
236
- MenuAlt2Icon,
237
- UserCircleIcon,
238
- XIcon,
239
- },
240
- name: "SidebarLayout",
241
- })
242
- export default class SidebarLayout extends Vue {
243
- @Prop({ type: String, required: false }) activeURL?: string;
244
- @Prop({ type: String, required: true }) iconURL!: string;
245
- @Prop({ type: Array, required: true }) navigation!: NavTypes.Item[];
246
- @Prop({ type: Array, required: true }) userNavigation!: NavTypes.Item[];
247
-
248
- sidebarOpen = false;
249
-
250
- isActive(url: string): boolean {
251
- return this.activeURL === url;
252
- }
253
- }
254
- </script>
@@ -1,3 +1,35 @@
1
+ <script setup lang="ts">
2
+ import Flash from "../overlays/Flash.vue"
3
+ import Spinner from "../overlays/Spinner.vue"
4
+ import {
5
+ Disclosure,
6
+ DisclosureButton,
7
+ DisclosurePanel,
8
+ Menu,
9
+ MenuButton,
10
+ MenuItem,
11
+ MenuItems,
12
+ } from "@headlessui/vue"
13
+ import { MenuIcon, UserCircleIcon, XIcon } from "@heroicons/vue/outline"
14
+ import * as NavTypes from "../../types/nav"
15
+ import User from "../../types/users"
16
+
17
+ const props = withDefaults(
18
+ defineProps<{
19
+ activeURL?: string
20
+ currentUser: User
21
+ iconURL: string
22
+ navigation: NavTypes.Item[]
23
+ userNavigation: NavTypes.Item[]
24
+ }>(),
25
+ {
26
+ activeURL: "",
27
+ }
28
+ )
29
+ const isActive = (url: string): boolean => {
30
+ return props.activeURL === url
31
+ }
32
+ </script>
1
33
  <template>
2
34
  <div class="min-h-screen bg-gray-100">
3
35
  <Disclosure as="nav" class="bg-white shadow-sm" v-slot="{ open }">
@@ -137,58 +169,3 @@
137
169
  <Flash />
138
170
  <Spinner />
139
171
  </template>
140
-
141
- <script lang="ts">
142
- import { Options, Prop, Vue } from "vue-property-decorator";
143
- import Flash from "../overlays/Flash.vue";
144
- import Spinner from "../overlays/Spinner.vue";
145
- import {
146
- Disclosure,
147
- DisclosureButton,
148
- DisclosurePanel,
149
- Menu,
150
- MenuButton,
151
- MenuItem,
152
- MenuItems,
153
- } from "@headlessui/vue";
154
- import {
155
- BellIcon,
156
- MenuIcon,
157
- UserCircleIcon,
158
- XIcon,
159
- } from "@heroicons/vue/outline";
160
- import NavTypes from "../../types/nav";
161
- import UserTypes from "../../types/users";
162
-
163
- @Options({
164
- components: {
165
- Flash,
166
- Spinner,
167
- Disclosure,
168
- DisclosureButton,
169
- DisclosurePanel,
170
- Menu,
171
- MenuButton,
172
- MenuItem,
173
- MenuItems,
174
- BellIcon,
175
- MenuIcon,
176
- UserCircleIcon,
177
- XIcon,
178
- },
179
- name: "StackedLayout",
180
- })
181
- export default class StackedLayout extends Vue {
182
- @Prop({ type: String, required: false }) activeURL?: string;
183
- @Prop({ type: Object, required: true }) currentUser!: UserTypes.User;
184
- @Prop({ type: String, required: true }) iconURL!: string;
185
- @Prop({ type: Array, required: true }) navigation!: NavTypes.Item[];
186
- @Prop({ type: Array, required: true }) userNavigation!: NavTypes.Item[];
187
-
188
- sidebarOpen = false;
189
-
190
- isActive(url: string): boolean {
191
- return this.activeURL === url;
192
- }
193
- }
194
- </script>
@@ -1,3 +1,11 @@
1
+ <script setup lang="ts">
2
+ defineProps<{
3
+ cards: {
4
+ primary: string
5
+ secondary: string
6
+ }[]
7
+ }>()
8
+ </script>
1
9
  <template>
2
10
  <div
3
11
  class="mt-5 grid grid-cols-1 gap-5"
@@ -23,15 +31,3 @@
23
31
  </div>
24
32
  </div>
25
33
  </template>
26
-
27
- <script lang="ts">
28
- import { Options, Prop, Vue } from "vue-property-decorator";
29
-
30
- @Options({ name: "Cards" })
31
- export default class Cards extends Vue {
32
- @Prop({ type: Array, required: true }) cards!: {
33
- primary: string;
34
- secondary: string;
35
- }[];
36
- }
37
- </script>
@@ -1,3 +1,86 @@
1
+ <script setup lang="ts">
2
+ import { ref, watch } from "vue"
3
+ import BaseAPI from "../../api/base"
4
+ import DateFilter from "../layout/DateFilter.vue"
5
+ import Paginator from "../navigation/Paginator.vue"
6
+
7
+ const props = withDefaults(
8
+ defineProps<{
9
+ refreshTrigger?: number
10
+ reloadTrigger?: number
11
+ title: string
12
+ url: string
13
+ }>(),
14
+ {
15
+ refreshTrigger: 0,
16
+ reloadTrigger: 0,
17
+ }
18
+ )
19
+
20
+ const dateRange = ref<{ minDate: number; maxDate: number }>({
21
+ minDate: 0,
22
+ maxDate: 0,
23
+ })
24
+ const hasContent = ref(true)
25
+ const items = ref<any[]>([])
26
+ const pagination = ref({
27
+ page: 1,
28
+ perPage: 10,
29
+ totalItems: 0,
30
+ totalPages: 0,
31
+ })
32
+ const sortDir = ref("DESC")
33
+
34
+ const loadAndRender = (checkForContent: boolean): void => {
35
+ const params = {
36
+ page: pagination.value.page,
37
+ perPage: pagination.value.perPage,
38
+ sortDir: sortDir.value,
39
+ }
40
+
41
+ BaseAPI.get(props.url, {}, Object.assign(params, dateRange.value)).then(
42
+ (success: any) => {
43
+ pagination.value = {
44
+ page: success.data.page,
45
+ perPage: success.data.perPage,
46
+ totalItems: success.data.totalItems,
47
+ totalPages: success.data.totalPages,
48
+ }
49
+ items.value = success.data.items
50
+ if (checkForContent) hasContent.value = items.value.length != 0
51
+ },
52
+ () => {
53
+ // TODO: let's make this really generic or configurable
54
+ window.VueBus.emit(
55
+ "Flash-show-generic-error",
56
+ "archive@xyplanningnetwork.com"
57
+ )
58
+ }
59
+ )
60
+ }
61
+
62
+ watch([sortDir, dateRange], () => {
63
+ loadAndRender(false)
64
+ })
65
+
66
+ watch(
67
+ () => props.refreshTrigger,
68
+ () => {
69
+ loadAndRender(false)
70
+ }
71
+ )
72
+
73
+ watch(
74
+ () => props.reloadTrigger,
75
+ () => {
76
+ // This lets parent components trigger a refresh of the current page depending on external actions.
77
+ pagination.value.page = 1
78
+ loadAndRender(true)
79
+ }
80
+ )
81
+
82
+ loadAndRender(true)
83
+ </script>
1
84
  <template>
2
85
  <div>
3
86
  <DateFilter
@@ -29,86 +112,3 @@
29
112
  />
30
113
  </div>
31
114
  </template>
32
-
33
- <script lang="ts">
34
- import { Options, Prop, Vue, Watch } from "vue-property-decorator";
35
- import BaseAPI from "../../api/base";
36
- import DateFilter from "../layout/DateFilter.vue";
37
- import Paginator from "../navigation/Paginator.vue";
38
-
39
- @Options({ components: { DateFilter, Paginator }, name: "DetailList" })
40
- export default class DetailList extends Vue {
41
- @Prop({ type: Number, required: false }) refreshTrigger?: number;
42
- @Prop({ type: Number, required: false }) reloadTrigger?: number;
43
- @Prop({ type: String, required: true }) title!: string;
44
- @Prop({ type: String, required: true }) url!: string;
45
-
46
- @Watch("sortDir")
47
- onSortDir(): void {
48
- this.loadAndRender(false);
49
- }
50
-
51
- @Watch("dateRange")
52
- onDateRange(): void {
53
- this.loadAndRender(false);
54
- }
55
-
56
- @Watch("refreshTrigger")
57
- onRefreshTrigger(): void {
58
- // This lets parent components trigger a refresh of the current page depending on external actions.
59
- this.loadAndRender(false);
60
- }
61
-
62
- @Watch("reloadTrigger")
63
- onReloadTrigger(): void {
64
- // This lets parent components trigger a refresh of the current page depending on external actions.
65
- this.pagination.page = 1;
66
- this.loadAndRender(true);
67
- }
68
-
69
- dateRange: { minDate: number; maxDate: number } = {
70
- minDate: 0,
71
- maxDate: 0,
72
- };
73
- hasContent = true;
74
- items: any[] = [];
75
- pagination = {
76
- page: 1,
77
- perPage: 10,
78
- totalItems: 0,
79
- totalPages: 0,
80
- };
81
- sortDir = "DESC";
82
-
83
- created() {
84
- this.loadAndRender(true);
85
- }
86
-
87
- loadAndRender(checkForContent: boolean): void {
88
- const params = {
89
- page: this.pagination.page,
90
- perPage: this.pagination.perPage,
91
- sortDir: this.sortDir,
92
- };
93
-
94
- BaseAPI.get(this.url, {}, Object.assign(params, this.dateRange)).then(
95
- (success: any) => {
96
- this.pagination = {
97
- page: success.data.page,
98
- perPage: success.data.perPage,
99
- totalItems: success.data.totalItems,
100
- totalPages: success.data.totalPages,
101
- };
102
- this.items = success.data.items;
103
- if (checkForContent) this.hasContent = this.items.length != 0;
104
- },
105
- () => {
106
- window.VueBus.emit(
107
- "Flash-show-generic-error",
108
- "archive@xyplanningnetwork.com"
109
- );
110
- }
111
- );
112
- }
113
- }
114
- </script>
@@ -1,16 +1,12 @@
1
+ <script setup lang="ts">
2
+ import { DownloadIcon } from "@heroicons/vue/solid"
3
+ defineProps<{
4
+ propsData: Record<string, unknown>
5
+ attribute: string
6
+ }>()
7
+ </script>
1
8
  <template>
2
- <a :href="propsData[attribute]">
9
+ <a :href="propsData[attribute] as string">
3
10
  <DownloadIcon class="h-6 w-6 group-hover:text-gray-500 transition" />
4
11
  </a>
5
12
  </template>
6
-
7
- <script lang="ts">
8
- import { Options, Prop, Vue } from "vue-property-decorator";
9
- import { DownloadIcon } from "@heroicons/vue/solid";
10
-
11
- @Options({ name: "DownloadCell", components: { DownloadIcon } })
12
- export default class DownloadCell extends Vue {
13
- @Prop({ type: Object, required: true }) propsData!: Record<string, unknown>;
14
- @Prop({ type: String, required: true }) attribute!: string;
15
- }
16
- </script>
@@ -1,3 +1,32 @@
1
+ <script setup lang="ts">
2
+ import { ComponentPublicInstance, getCurrentInstance } from "vue"
3
+ import * as TableTypes from "../../types/table"
4
+
5
+ defineProps<{
6
+ tableData: TableTypes.Static
7
+ }>()
8
+
9
+ const cellValue = (
10
+ item: Record<string, any>,
11
+ col: TableTypes.Column
12
+ ): string => {
13
+ if (col.key) {
14
+ return item[col.key]
15
+ }
16
+
17
+ if (col.presenter) {
18
+ // TODO: discuss this pattern. Current usage can be replaced with modules.
19
+ // https://v3.vuejs.org/api/composition-api.html#getcurrentinstance
20
+ const internalInstance = getCurrentInstance()
21
+ return col.presenter(
22
+ item,
23
+ internalInstance?.proxy as ComponentPublicInstance
24
+ )
25
+ }
26
+
27
+ return ""
28
+ }
29
+ </script>
1
30
  <template>
2
31
  <div class="flex flex-col">
3
32
  <div class="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
@@ -19,7 +48,7 @@
19
48
  <tbody class="bg-white divide-y divide-gray-200">
20
49
  <tr
21
50
  v-for="(item, rowIdx) in tableData.items"
22
- :key="item.id ? item.id : rowIdx"
51
+ :key="item.id ? (item.id as string) : rowIdx"
23
52
  >
24
53
  <td
25
54
  class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap leading-5"
@@ -52,25 +81,3 @@
52
81
  </div>
53
82
  </div>
54
83
  </template>
55
-
56
- <script lang="ts">
57
- import { Options, Prop, Vue } from "vue-property-decorator";
58
- import TableTypes from "../../types/table";
59
-
60
- @Options({ name: "StaticTable" })
61
- export default class StaticTable extends Vue {
62
- @Prop({ type: Object, required: true }) tableData!: TableTypes.Static;
63
-
64
- cellValue(item: Record<string, any>, col: TableTypes.Column): string {
65
- if (col.key) {
66
- return item[col.key];
67
- }
68
-
69
- if (col.presenter) {
70
- return col.presenter(item, this);
71
- }
72
-
73
- return "";
74
- }
75
- }
76
- </script>