@xy-planning-network/trees 0.4.0-rc-7 → 0.4.2
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.
- package/README.md +236 -53
- package/dist/trees.es.js +1069 -330
- package/dist/trees.umd.js +6 -6
- package/package.json +6 -4
- package/src/lib-components/forms/BaseInput.vue +83 -0
- package/src/lib-components/forms/Checkbox.vue +46 -0
- package/src/lib-components/forms/DateRangePicker.vue +65 -0
- package/src/lib-components/forms/InputHelp.vue +24 -0
- package/src/lib-components/forms/InputLabel.vue +23 -0
- package/src/lib-components/forms/MultiCheckboxes.vue +55 -0
- package/src/lib-components/forms/Radio.vue +58 -0
- package/src/lib-components/forms/Select.vue +65 -0
- package/src/lib-components/forms/TextArea.vue +50 -0
- package/src/lib-components/forms/Toggle.vue +25 -0
- package/src/lib-components/forms/YesOrNoRadio.vue +70 -0
- package/src/lib-components/layout/DateFilter.vue +54 -0
- package/src/lib-components/layout/SidebarLayout.vue +239 -0
- package/src/lib-components/layout/StackedLayout.vue +172 -0
- package/src/lib-components/lists/Cards.vue +33 -0
- package/src/lib-components/lists/DetailList.vue +114 -0
- package/src/lib-components/lists/DownloadCell.vue +12 -0
- package/src/lib-components/lists/StaticTable.vue +83 -0
- package/src/lib-components/lists/Table.vue +291 -0
- package/src/lib-components/navigation/ActionsDropdown.vue +78 -0
- package/src/lib-components/navigation/Paginator.vue +111 -0
- package/src/lib-components/navigation/Steps.vue +83 -0
- package/src/lib-components/navigation/Tabs.vue +92 -0
- package/src/lib-components/overlays/ContentModal.vue +95 -0
- package/src/lib-components/overlays/Flash.vue +131 -0
- package/src/lib-components/overlays/Modal.vue +133 -0
- package/src/lib-components/overlays/Popover/Popover.vue +229 -0
- package/src/lib-components/overlays/Popover/PopoverContent.vue +8 -0
- package/src/lib-components/overlays/Slideover.vue +87 -0
- package/src/lib-components/overlays/Spinner.vue +149 -0
- package/src/lib-components/overlays/Tooltip.vue +34 -0
- package/types/components.d.ts +6 -2
- package/types/composables/date.d.ts +4 -0
- package/types/composables/nav.d.ts +13 -0
- package/types/composables/overlay.d.ts +4 -0
- package/types/composables/table.d.ts +32 -0
- package/types/composables/user.d.ts +6 -0
- package/types/global.d.ts +5 -2
- package/types/helpers/Debounce.d.ts +1 -0
- package/types/helpers/Throttle.d.ts +1 -0
- package/types/lib-components/forms/Select.vue.d.ts +2 -2
- package/types/lib-components/index.d.ts +9 -9
- package/types/lib-components/layout/DateFilter.vue.d.ts +1 -4
- package/types/lib-components/layout/SidebarLayout.vue.d.ts +1 -1
- package/types/lib-components/layout/StackedLayout.vue.d.ts +2 -2
- package/types/lib-components/lists/StaticTable.vue.d.ts +1 -1
- package/types/lib-components/lists/Table.vue.d.ts +1 -1
- package/types/lib-components/navigation/ActionsDropdown.vue.d.ts +2 -2
- package/types/lib-components/navigation/Paginator.vue.d.ts +1 -6
- package/types/lib-components/overlays/Flash.vue.d.ts +0 -4
- package/types/lib-components/overlays/Popover/Popover.vue.d.ts +23 -0
- package/types/lib-components/overlays/Popover/PopoverContent.vue.d.ts +2 -0
- package/types/lib-components/overlays/Tooltip.vue.d.ts +23 -0
- package/types/index.d.ts +0 -3
- package/types/nav.d.ts +0 -8
- package/types/table.d.ts +0 -36
- package/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
|
-
- [
|
|
40
|
+
- [x] DateFilter input heights is not consistent. Make select match datepicker.
|
|
41
41
|
|
|
42
42
|
## Roadmap
|
|
43
43
|
|
|
44
|
-
- [
|
|
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
|
-
##
|
|
48
|
+
## Install
|
|
49
49
|
|
|
50
|
-
|
|
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
|
-
|
|
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
|
-
|
|
58
|
+
## Setup
|
|
61
59
|
|
|
62
|
-
|
|
60
|
+
### Fonts
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
// global.d.ts
|
|
62
|
+
**Include Inter Var in html template**
|
|
66
63
|
|
|
67
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
**
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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(
|
|
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
|
-
|
|
93
|
-
|
|
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
|
-
**
|
|
185
|
+
**Use Trees components as globally in your components**
|
|
103
186
|
|
|
104
|
-
```
|
|
105
|
-
|
|
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
|
-
|
|
108
|
-
@import "@xy-planning-network/trees/src/index.css";
|
|
205
|
+
### JavaScript - Cherry Pick Components As A Plugin
|
|
109
206
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
267
|
+
```ts
|
|
268
|
+
// main.ts
|
|
119
269
|
|
|
120
|
-
|
|
121
|
-
<
|
|
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
|
-
|
|
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
|
-
|
|
278
|
+
// import your project's main stylesheet
|
|
279
|
+
import "@/main.css"
|
|
129
280
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
```
|