@xy-planning-network/trees 0.4.0-rc-8 → 0.4.0

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 (36) hide show
  1. package/README.md +234 -41
  2. package/dist/trees.es.js +224 -217
  3. package/dist/trees.umd.js +4 -4
  4. package/package.json +4 -2
  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/Slideover.vue +87 -0
  32. package/src/lib-components/overlays/Spinner.vue +149 -0
  33. package/types/composables/nav.d.ts +2 -2
  34. package/types/composables/table.d.ts +2 -2
  35. package/types/composables/user.d.ts +1 -4
  36. package/types/lib-components/forms/Select.vue.d.ts +2 -2
package/README.md CHANGED
@@ -37,50 +37,143 @@ 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.
57
+
58
+ ## Setup
59
+
60
+ ### Fonts
61
+
62
+ **Include Inter Var in html template**
63
+
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**
73
+
74
+ ```css
75
+ /* main.css */
59
76
 
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.
77
+ /* import trees base styles */
78
+ @import "@xy-planning-network/trees/src/index.css";
61
79
 
62
- **Initialize trees components in main.ts**
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;
84
+ }
85
+ }
86
+ ```
87
+
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**
63
107
 
64
108
  ```ts
65
109
  // main.ts
66
110
 
67
- // include the type interfaces for Window and GlobalComponents
111
+ // include the type interface for the Window global - includes Window.VueBus and Window.Flashes
68
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"
117
+
118
+ // import your project's main stylesheet
119
+ import "@/main.css"
120
+
121
+ // initialize mitt on VueBus for Flashes
122
+ window.VueBus = Mitt()
123
+
124
+ // initialize the app
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
69
162
  /// <reference types="@xy-planning-network/trees/types/components" />
70
163
 
71
164
  import Vue, { createApp } from "vue"
72
165
  import Mitt from "mitt"
73
166
  import Trees from "@xy-planning-network/trees"
74
- import HelloWorld from "@/components/HelloWorld.vue"
167
+ import App from "./App.vue"
75
168
 
76
169
  // import your project's main stylesheet
77
170
  import "@/main.css"
78
171
 
79
- // initialize the app
80
- const app = createApp(HelloWorld)
172
+ // initialize mitt on VueBus for flashes support
173
+ window.VueBus = Mitt()
81
174
 
82
- // initialize mitt on VueBus
83
- window.VueBus = mitt()
175
+ // initialize the app
176
+ const app = createApp(App)
84
177
 
85
178
  // use all of Trees as a vue plugin
86
179
  app.use(Trees)
@@ -89,40 +182,140 @@ app.use(Trees)
89
182
  app.mount("#vue-app")
90
183
  ```
91
184
 
92
- **Initialize styles in main.css**
185
+ **Use Trees components as globally in your components**
93
186
 
94
- ```css
95
- /* 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
+ ```
96
204
 
97
- /* import trees base styles */
98
- @import "@xy-planning-network/trees/src/index.css";
205
+ ### JavaScript - Cherry Pick Components As A Plugin
99
206
 
100
- /* additional tailwind styles */
101
- @layer components {
102
- .xy-example {
103
- @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
104
245
  }
105
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
+ }
106
265
  ```
107
266
 
108
- **Include Inter Var in html template**
267
+ ```ts
268
+ // main.ts
109
269
 
110
- ```html
111
- <head>
112
- <link href="https://rsms.me/inter/inter.css" rel="stylesheet" />
113
- </head>
114
- ```
270
+ // include the type interface for the Window global - includes Window.VueBus and Window.Flashes
271
+ /// <reference types="@xy-planning-network/trees/types/global" />
115
272
 
116
- **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"
117
277
 
118
- 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"
119
280
 
120
- ```js
121
- /* eslint-disable */
122
- const treesConfig = require("@xy-planning-network/trees/config/tailwind.config")
123
- module.exports = {
124
- ...treesConfig,
125
- mode: "jit", // Optional
126
- purge: [...treesConfig.purge, ...["./src/**/*.vue"]],
127
- }
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>
128
321
  ```