@xy-planning-network/trees 0.4.0-rc-6 → 0.4.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.
Files changed (82) hide show
  1. package/README.md +236 -53
  2. package/dist/trees.es.js +910 -274
  3. package/dist/trees.umd.js +6 -6
  4. package/package.json +9 -6
  5. package/src/lib-components/forms/BaseInput.vue +83 -0
  6. package/src/lib-components/forms/Checkbox.vue +46 -0
  7. package/src/lib-components/forms/DateRangePicker.vue +65 -0
  8. package/src/lib-components/forms/InputHelp.vue +24 -0
  9. package/src/lib-components/forms/InputLabel.vue +23 -0
  10. package/src/lib-components/forms/MultiCheckboxes.vue +55 -0
  11. package/src/lib-components/forms/Radio.vue +58 -0
  12. package/src/lib-components/forms/Select.vue +65 -0
  13. package/src/lib-components/forms/TextArea.vue +50 -0
  14. package/src/lib-components/forms/Toggle.vue +25 -0
  15. package/src/lib-components/forms/YesOrNoRadio.vue +70 -0
  16. package/src/lib-components/layout/DateFilter.vue +54 -0
  17. package/src/lib-components/layout/SidebarLayout.vue +239 -0
  18. package/src/lib-components/layout/StackedLayout.vue +172 -0
  19. package/src/lib-components/lists/Cards.vue +33 -0
  20. package/src/lib-components/lists/DetailList.vue +114 -0
  21. package/src/lib-components/lists/DownloadCell.vue +12 -0
  22. package/src/lib-components/lists/StaticTable.vue +83 -0
  23. package/src/lib-components/lists/Table.vue +291 -0
  24. package/src/lib-components/navigation/ActionsDropdown.vue +78 -0
  25. package/src/lib-components/navigation/Paginator.vue +115 -0
  26. package/src/lib-components/navigation/Steps.vue +83 -0
  27. package/src/lib-components/navigation/Tabs.vue +92 -0
  28. package/src/lib-components/overlays/ContentModal.vue +95 -0
  29. package/src/lib-components/overlays/Flash.vue +131 -0
  30. package/src/lib-components/overlays/Modal.vue +133 -0
  31. package/src/lib-components/overlays/Popover/Popover.vue +109 -0
  32. package/src/lib-components/overlays/Popover/PopoverContent.vue +8 -0
  33. package/src/lib-components/overlays/Slideover.vue +87 -0
  34. package/src/lib-components/overlays/Spinner.vue +149 -0
  35. package/src/lib-components/overlays/Tooltip.vue +31 -0
  36. package/{dist → types}/api/base.d.ts +0 -0
  37. package/types/components.d.ts +12 -0
  38. package/types/composables/date.d.ts +4 -0
  39. package/types/composables/nav.d.ts +13 -0
  40. package/types/composables/overlay.d.ts +4 -0
  41. package/types/composables/table.d.ts +32 -0
  42. package/types/composables/user.d.ts +6 -0
  43. package/{dist → types}/entry.d.ts +0 -0
  44. package/types/global.d.ts +13 -0
  45. package/{dist → types}/helpers/Uniques.d.ts +0 -0
  46. package/{dist → types}/lib-components/forms/BaseInput.vue.d.ts +0 -0
  47. package/{dist → types}/lib-components/forms/Checkbox.vue.d.ts +0 -0
  48. package/{dist → types}/lib-components/forms/DateRangePicker.vue.d.ts +0 -0
  49. package/{dist → types}/lib-components/forms/InputHelp.vue.d.ts +0 -0
  50. package/{dist → types}/lib-components/forms/InputLabel.vue.d.ts +0 -0
  51. package/{dist → types}/lib-components/forms/MultiCheckboxes.vue.d.ts +0 -0
  52. package/{dist → types}/lib-components/forms/Radio.vue.d.ts +0 -0
  53. package/{dist → types}/lib-components/forms/Select.vue.d.ts +2 -2
  54. package/{dist → types}/lib-components/forms/TextArea.vue.d.ts +0 -0
  55. package/{dist → types}/lib-components/forms/Toggle.vue.d.ts +0 -0
  56. package/{dist → types}/lib-components/forms/YesOrNoRadio.vue.d.ts +0 -0
  57. package/{dist → types}/lib-components/index.d.ts +9 -9
  58. package/{dist → types}/lib-components/layout/DateFilter.vue.d.ts +1 -4
  59. package/{dist → types}/lib-components/layout/SidebarLayout.vue.d.ts +1 -1
  60. package/{dist → types}/lib-components/layout/StackedLayout.vue.d.ts +2 -2
  61. package/{dist → types}/lib-components/lists/Cards.vue.d.ts +0 -0
  62. package/{dist → types}/lib-components/lists/DetailList.vue.d.ts +0 -0
  63. package/{dist → types}/lib-components/lists/DownloadCell.vue.d.ts +0 -0
  64. package/{dist → types}/lib-components/lists/StaticTable.vue.d.ts +1 -1
  65. package/{dist → types}/lib-components/lists/Table.vue.d.ts +1 -1
  66. package/{dist → types}/lib-components/navigation/ActionsDropdown.vue.d.ts +2 -2
  67. package/{dist → types}/lib-components/navigation/Paginator.vue.d.ts +1 -6
  68. package/{dist → types}/lib-components/navigation/Steps.vue.d.ts +0 -0
  69. package/{dist → types}/lib-components/navigation/Tabs.vue.d.ts +0 -0
  70. package/{dist → types}/lib-components/overlays/ContentModal.vue.d.ts +0 -0
  71. package/{dist/lib-components/overlays/Spinner.vue.d.ts → types/lib-components/overlays/Flash.vue.d.ts} +0 -0
  72. package/{dist → types}/lib-components/overlays/Modal.vue.d.ts +0 -0
  73. package/types/lib-components/overlays/Popover/Popover.vue.d.ts +15 -0
  74. package/types/lib-components/overlays/Popover/PopoverContent.vue.d.ts +2 -0
  75. package/{dist → types}/lib-components/overlays/Slideover.vue.d.ts +0 -0
  76. package/{dist/lib-components/overlays/Flash.vue.d.ts → types/lib-components/overlays/Spinner.vue.d.ts} +0 -4
  77. package/types/lib-components/overlays/Tooltip.vue.d.ts +16 -0
  78. package/dist/types/components.d.ts +0 -6
  79. package/dist/types/global.d.ts +0 -10
  80. package/dist/types/nav.d.ts +0 -8
  81. package/dist/types/table.d.ts +0 -36
  82. package/dist/types/users.d.ts +0 -10
package/README.md CHANGED
@@ -37,102 +37,285 @@ Trees is our attempt at unifying the frontend code we've written to power a smal
37
37
  - [ ] Make sure components have names in devtools
38
38
  - [ ] Look into forcing tables to dropdown when actions open up in hidden area
39
39
  - [ ] Fix select placeholder only showing up in dropdown
40
- - [ ] DateFilter input heights is not consistent. Make select match datepicker.
40
+ - [x] DateFilter input heights is not consistent. Make select match datepicker.
41
41
 
42
42
  ## Roadmap
43
43
 
44
- - [ ] move to vite for building the dev site, library, and possible storybook
44
+ - [x] move to vite for building the dev site, library, and possible storybook
45
+ - [x] refactor componentes away from class decorators to setup sugar
45
46
  - [ ] consider implementing storybook using vite as the bundler
46
- - [ ] refactor componentes away from class decorators to setup sugar
47
47
 
48
- ## Usage
48
+ ## Install
49
49
 
50
- ### Installation
51
-
52
- Install trees and mitt
50
+ Install trees and mitt into an existing Vue project - assumes npm version >= 7
53
51
 
54
52
  ```sh
55
53
  npm i @xy-planning-network/trees mitt
56
54
  ```
57
55
 
58
- ### Enable as a Vue plugin
56
+ Additional peer dependecies will be installed by NPM. If you are using NPM < 7 you may need to explicitly install peer dependencies.
59
57
 
60
- This example installs all components of Trees, which may not be necessary for all projects. Assumes you have a vue 3 project with tailwind created.
58
+ ## Setup
61
59
 
62
- **Establish global types for VueBus and Flashes in global.d.ts**
60
+ ### Fonts
63
61
 
64
- ```ts
65
- // global.d.ts
62
+ **Include Inter Var in html template**
66
63
 
67
- import { Emitter } from "mitt";
64
+ ```html
65
+ <head>
66
+ <link href="https://rsms.me/inter/inter.css" rel="stylesheet" />
67
+ </head>
68
+ ```
69
+
70
+ ### Styles
71
+
72
+ **Initialize styles in main.css**
68
73
 
69
- declare global {
70
- interface Window {
71
- Flashes: Array<{ message: string }>;
72
- VueBus: Emitter;
74
+ ```css
75
+ /* main.css */
76
+
77
+ /* import trees base styles */
78
+ @import "@xy-planning-network/trees/src/index.css";
79
+
80
+ /* additional tailwind styles */
81
+ @layer components {
82
+ .xy-example {
83
+ @apply inline-flex justify-center items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 text-gray-800;
73
84
  }
74
85
  }
75
86
  ```
76
87
 
77
- **Initialize trees components in main.ts**
88
+ **Merge with the trees tailwind.cofig.js**
89
+
90
+ Note you may need a deep merge utility depending on the depth of properties you plan to override.
91
+
92
+ ```js
93
+ /* eslint-disable */
94
+ const treesConfig = require("@xy-planning-network/trees/config/tailwind.config")
95
+ module.exports = {
96
+ ...treesConfig,
97
+ mode: "jit", // Optional
98
+ purge: [...treesConfig.purge, ...["./src/**/*.vue"]],
99
+ }
100
+ ```
101
+
102
+ ### JavaScript - Only What You Need
103
+
104
+ This is the best option when tree shaking and final bundle size is important to you.
105
+
106
+ **Initialize trees dependencies in your application root**
78
107
 
79
108
  ```ts
80
109
  // main.ts
81
- import Vue, { createApp } from "vue";
82
- import Mitt from "mitt";
83
- import Trees from "@xy-planning-network/trees";
84
- import HelloWorld from "@/components/HelloWorld.vue";
110
+
111
+ // include the type interface for the Window global - includes Window.VueBus and Window.Flashes
112
+ /// <reference types="@xy-planning-network/trees/types/global" />
113
+
114
+ import Vue, { createApp } from "vue"
115
+ import Mitt from "mitt"
116
+ import App from "./App.vue"
85
117
 
86
118
  // import your project's main stylesheet
87
- import "@/main.css";
119
+ import "@/main.css"
120
+
121
+ // initialize mitt on VueBus for Flashes
122
+ window.VueBus = Mitt()
88
123
 
89
124
  // initialize the app
90
- const app = createApp(HelloWorld);
125
+ const app = createApp(App)
126
+ app.mount("#vue-app")
127
+ ```
128
+
129
+ **Use Trees components as needed in your components**
130
+
131
+ ```ts
132
+ <script setup lang="ts">
133
+ import { ref } from "vue"
134
+ import { BaseInput} from "@xy-planning-network/trees"
135
+
136
+ const myInputVal = ref("")
137
+ </script>
138
+ <template>
139
+ <form>
140
+ <BaseInput
141
+ v-model="myInputVal"
142
+ type="text"
143
+ label="What's on your mind"
144
+ help="Don't over think it!"
145
+ />
146
+ </form>
147
+ </template>
148
+ ```
149
+
150
+ ### JavaScript - Give Me The Kitchen Sink
151
+
152
+ This example installs all components of Trees globally so you don't need to import them in your components. Useful for hitting the ground running with as little friction as possible. Bundles size will suffer as tree shaking optimizations will be limited.
153
+
154
+ **Install all Trees components as a Vue plugin in your project root**
155
+
156
+ ```ts
157
+ // main.ts
158
+
159
+ // include the type interface for the Window global - includes Window.VueBus and Window.Flashes
160
+ /// <reference types="@xy-planning-network/trees/types/global" />
161
+ // include the type interfaces for Trees components installed globally on the Vue instance
162
+ /// <reference types="@xy-planning-network/trees/types/components" />
91
163
 
92
- // initialize mitt on VueBus
93
- window.VueBus = mitt();
164
+ import Vue, { createApp } from "vue"
165
+ import Mitt from "mitt"
166
+ import Trees from "@xy-planning-network/trees"
167
+ import App from "./App.vue"
168
+
169
+ // import your project's main stylesheet
170
+ import "@/main.css"
171
+
172
+ // initialize mitt on VueBus for flashes support
173
+ window.VueBus = Mitt()
174
+
175
+ // initialize the app
176
+ const app = createApp(App)
94
177
 
95
178
  // use all of Trees as a vue plugin
96
- app.use(Trees);
179
+ app.use(Trees)
97
180
 
98
181
  // mount the application
99
- app.mount("#vue-app");
182
+ app.mount("#vue-app")
100
183
  ```
101
184
 
102
- **Initialize styles in main.css**
185
+ **Use Trees components as globally in your components**
103
186
 
104
- ```css
105
- /* main.css */
187
+ ```ts
188
+ <script setup lang="ts">
189
+ import { ref } from "vue"
190
+ const myInputVal = ref("")
191
+ </script>
192
+ <template>
193
+ <form>
194
+ <!-- BaseInput is globally available -->
195
+ <BaseInput
196
+ v-model="myInputVal"
197
+ type="text"
198
+ label="What's on your mind"
199
+ help="Don't over think it!"
200
+ />
201
+ </form>
202
+ </template>
203
+ ```
106
204
 
107
- /* import trees base styles */
108
- @import "@xy-planning-network/trees/src/index.css";
205
+ ### JavaScript - Cherry Pick Components As A Plugin
109
206
 
110
- /* additional tailwind styles */
111
- @layer components {
112
- .xy-example {
113
- @apply inline-flex justify-center items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 text-gray-800;
207
+ This example selectively installs the Form components of Trees globally so you don't need to import them in your components. All other Trees components need to be explicitly imported.
208
+
209
+ **Create a project based plugin for just the Trees form components**
210
+
211
+ ```ts
212
+ // plugins/trees.ts
213
+ // plugins/trees.ts
214
+ import { App } from "vue"
215
+ import {
216
+ BaseInput,
217
+ Checkbox,
218
+ DateRangePicker,
219
+ InputHelp,
220
+ InputLabel,
221
+ MultiCheckboxes,
222
+ Radio,
223
+ Select,
224
+ TextArea,
225
+ YesOrNoRadio,
226
+ } from "@xy-planning-network/trees"
227
+
228
+ /**
229
+ * declare the global component types
230
+ * should provide code completiong support in your editor - milage may vary
231
+ * provides proper type checking on the components declared props
232
+ */
233
+ declare module "@vue/runtime-core" {
234
+ interface GlobalComponents {
235
+ BaseInput: typeof BaseInput
236
+ Checkbox: typeof Checkbox
237
+ DateRangePicker: typeof DateRangePicker
238
+ InputHelp: typeof InputHelp
239
+ InputLabel: typeof InputLabel
240
+ MultiCheckboxes: typeof MultiCheckboxes
241
+ Radio: typeof Radio
242
+ Select: typeof Select
243
+ TextArea: typeof TextArea
244
+ YesOrNoRadio: typeof YesOrNoRadio
114
245
  }
115
246
  }
247
+
248
+ /**
249
+ * export a plugin object with an install method
250
+ */
251
+ export default {
252
+ install(app: App) {
253
+ app.component("BaseInput", BaseInput)
254
+ app.component("Checkbox", Checkbox)
255
+ app.component("DateRangePicker", DateRangePicker)
256
+ app.component("InputHelp", InputHelp)
257
+ app.component("InputLabel", InputLabel)
258
+ app.component("MultiCheckboxes", MultiCheckboxes)
259
+ app.component("Radio", Radio)
260
+ app.component("Select", Select)
261
+ app.component("TextArea", TextArea)
262
+ app.component("YesOrNoRadio", YesOrNoRadio)
263
+ },
264
+ }
116
265
  ```
117
266
 
118
- **Include Inter Var in html template**
267
+ ```ts
268
+ // main.ts
119
269
 
120
- ```html
121
- <head>
122
- <link href="https://rsms.me/inter/inter.css" rel="stylesheet" />
123
- </head>
124
- ```
270
+ // include the type interface for the Window global - includes Window.VueBus and Window.Flashes
271
+ /// <reference types="@xy-planning-network/trees/types/global" />
125
272
 
126
- **Merge with the trees tailwind.cofig.js**
273
+ import Vue, { createApp } from "vue"
274
+ import Mitt from "mitt"
275
+ import App from "./App.vue"
276
+ import TreesFormComponents from "./plugins/trees"
127
277
 
128
- Note you may need a deep merge utility depending on the depth of properties you plan to override.
278
+ // import your project's main stylesheet
279
+ import "@/main.css"
129
280
 
130
- ```js
131
- /* eslint-disable */
132
- const treesConfig = require("@xy-planning-network/trees/config/tailwind.config");
133
- module.exports = {
134
- ...treesConfig,
135
- mode: "jit", // Optional
136
- purge: [...treesConfig.purge, ...["./src/**/*.vue"]],
137
- };
281
+ // initialize mitt on VueBus for flashes support
282
+ window.VueBus = Mitt()
283
+
284
+ // initialize the app
285
+ const app = createApp(App)
286
+
287
+ // use cherry picked Form components of Trees globally
288
+ app.use(TreesFormComponents)
289
+
290
+ // mount the application
291
+ app.mount("#vue-app")
292
+ ```
293
+
294
+ **Use Trees components as globally in your components**
295
+
296
+ ```ts
297
+ <script setup lang="ts">
298
+ import { ref } from "vue"
299
+ import { Cards } from "@xy-planning-network/trees"
300
+ const myInputVal = ref("")
301
+ const cardsList = [
302
+ { primary: "Get Some", secondary: "You are gonna do well." },
303
+ { primary: "Try It", secondary: "I'm proud of how far you've come." },
304
+ { primary: "Nice Info", secondary: "Never stop trying." },
305
+ ]
306
+
307
+ </script>
308
+ <template>
309
+ <!--Cards needed to be imported -->
310
+ <Cards :cards="cardsList" />
311
+ <form>
312
+ <!-- BaseInput is globally available -->
313
+ <BaseInput
314
+ v-model="myInputVal"
315
+ type="text"
316
+ label="What's on your mind"
317
+ help="Don't over think it!"
318
+ />
319
+ </form>
320
+ </template>
138
321
  ```