@veritree/ui 0.12.2 → 0.15.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.
@@ -0,0 +1,96 @@
1
+ ###
2
+ # Place your Prettier ignore content here
3
+
4
+ ###
5
+ # .gitignore content is duplicated here due to https://github.com/prettier/prettier/issues/8506
6
+
7
+ # Created by .ignore support plugin (hsz.mobi)
8
+ ### Node template
9
+ # Logs
10
+ /logs
11
+ *.log
12
+ npm-debug.log*
13
+ yarn-debug.log*
14
+ yarn-error.log*
15
+
16
+ # Runtime data
17
+ pids
18
+ *.pid
19
+ *.seed
20
+ *.pid.lock
21
+
22
+ # Directory for instrumented libs generated by jscoverage/JSCover
23
+ lib-cov
24
+
25
+ # Coverage directory used by tools like istanbul
26
+ coverage
27
+
28
+ # nyc test coverage
29
+ .nyc_output
30
+
31
+ # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
32
+ .grunt
33
+
34
+ # Bower dependency directory (https://bower.io/)
35
+ bower_components
36
+
37
+ # node-waf configuration
38
+ .lock-wscript
39
+
40
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
41
+ build/Release
42
+
43
+ # Dependency directories
44
+ node_modules/
45
+ jspm_packages/
46
+
47
+ # TypeScript v1 declaration files
48
+ typings/
49
+
50
+ # Optional npm cache directory
51
+ .npm
52
+
53
+ # Optional eslint cache
54
+ .eslintcache
55
+
56
+ # Optional REPL history
57
+ .node_repl_history
58
+
59
+ # Output of 'npm pack'
60
+ *.tgz
61
+
62
+ # Yarn Integrity file
63
+ .yarn-integrity
64
+
65
+ # dotenv environment variables file
66
+ .env
67
+
68
+ # parcel-bundler cache (https://parceljs.org/)
69
+ .cache
70
+
71
+ # next.js build output
72
+ .next
73
+
74
+ # nuxt.js build output
75
+ .nuxt
76
+
77
+ # Nuxt generate
78
+ dist
79
+
80
+ # vuepress build output
81
+ .vuepress/dist
82
+
83
+ # Serverless directories
84
+ .serverless
85
+
86
+ # IDE / Editor
87
+ .idea
88
+
89
+ # Service worker
90
+ sw.*
91
+
92
+ # macOS
93
+ .DS_Store
94
+
95
+ # Vim swap files
96
+ *.swp
package/.prettierrc ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "semi": true,
3
+ "singleQuote": true
4
+ }
package/index.js CHANGED
@@ -1,6 +1,8 @@
1
+ import VTAlert from "./src/components/Alert/VTAlert.vue";
1
2
  import VTAvatar from "./src/components/Avatar/VTAvatar.vue";
2
3
  import VTAvatarImage from "./src/components/Avatar/VTAvatarImage.vue";
3
4
  import VTAvatarText from "./src/components/Avatar/VTAvatarText.vue";
5
+ import VTButton from "./src/components/Button/VTButton.vue";
4
6
  import VTImage from "./src/components/Image/VTImage.vue";
5
7
  import VTImageCounter from "./src/components/Image/VTImageCounter.vue";
6
8
  import VTImageHover from "./src/components/Image/VTImageHover.vue";
@@ -26,18 +28,12 @@ import VTListboxLabel from "./src/components/Listbox/VTListboxLabel.vue";
26
28
  import VTListboxList from "./src/components/Listbox/VTListboxList.vue";
27
29
  import VTListboxSearch from "./src/components/Listbox/VTListboxSearch.vue";
28
30
  import VTListboxTrigger from "./src/components/Listbox/VTListboxTrigger.vue";
29
-
30
- import VTAlert from "./src/components/Alerts/VTAlert.vue";
31
-
32
31
  import VTSpinner from "./src/components/Spinner/VTSpinner.vue";
33
-
34
- import VTButton from "./src/components/Button/VTButton.vue";
35
- // import VTButtonSave from './src/components/Button/VTButtonSave.vue';
36
-
37
32
  import VTInput from "./src/components/Input/VTInput.vue";
38
33
  import VTInputDate from "./src/components/Input/VTInputDate.vue";
39
34
  import VTInputFile from "./src/components/Input/VTInputFile.vue";
40
35
  import VTInputUpload from "./src/components/Input/VTInputUpload.vue";
36
+ import VTProgressBar from "./src/components/ProgressBar/VTProgressBar.vue";
41
37
 
42
38
  import VTTextarea from "./src/components/Textarea/VTTextarea.vue";
43
39
 
@@ -104,11 +100,11 @@ export {
104
100
  VTListboxSearch,
105
101
  VTListboxTrigger,
106
102
  VTButton,
107
- // VTButtonSave,
108
103
  VTInput,
109
104
  VTInputDate,
110
105
  VTInputFile,
111
106
  VTInputUpload,
107
+ VTProgressBar,
112
108
  VTTextarea,
113
109
  VTModal,
114
110
  VTAccordion,
package/nuxt.js CHANGED
@@ -1,13 +1,17 @@
1
1
  import { join } from 'path';
2
2
 
3
3
  const components = [
4
+ 'src/components/Alert',
4
5
  'src/components/Avatar',
6
+ 'src/components/Button',
5
7
  'src/components/Drawer',
6
8
  'src/components/Dialog',
7
9
  'src/components/DropdownMenu',
8
10
  'src/components/Form',
9
11
  'src/components/Listbox',
10
12
  'src/components/Image',
13
+ 'src/components/Popover',
14
+ 'src/components/ProgressBar',
11
15
  'src/components/Tabs',
12
16
  ]
13
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/ui",
3
- "version": "0.12.2",
3
+ "version": "0.15.0",
4
4
  "description": "veritree ui library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -11,6 +11,8 @@
11
11
  "access": "public"
12
12
  },
13
13
  "dependencies": {
14
+ "@linusborg/vue-simple-portal": "^0.1.5",
14
15
  "@veritree/icons": "^0.19.0"
15
- }
16
+ },
17
+ "devDependencies": {}
16
18
  }
@@ -0,0 +1,83 @@
1
+ <template>
2
+ <div
3
+ v-if="show"
4
+ :class="[
5
+ // default styles
6
+ headless
7
+ ? 'alert'
8
+ : 'flex items-start gap-3 rounded border border-solid p-3',
9
+ // variant styles
10
+ headless
11
+ ? `alert--${variant}`
12
+ : isSuccess
13
+ ? 'border-success-300 bg-success-200 text-success-700'
14
+ : isError
15
+ ? 'border-error-300 bg-error-200 text-error-700'
16
+ : isWarning
17
+ ? 'border-warning-300 bg-warning-200 text-warning-700'
18
+ : null,
19
+ ]"
20
+ role="alert"
21
+ >
22
+ <slot></slot>
23
+ <button
24
+ v-if="dismissable"
25
+ :class="[
26
+ !headless
27
+ ? 'ml-auto mt-1 h-4 w-4 shrink-0 text-current'
28
+ : 'alert-close',
29
+ ]"
30
+ @click="hide"
31
+ >
32
+ <IconClose />
33
+ </button>
34
+ </div>
35
+ </template>
36
+
37
+ <script>
38
+ export default {
39
+ name: 'VTAlert',
40
+
41
+ props: {
42
+ variant: {
43
+ type: String,
44
+ default: 'success',
45
+ },
46
+ headless: {
47
+ type: Boolean,
48
+ default: false,
49
+ },
50
+ dismissable: {
51
+ type: Boolean,
52
+ default: false,
53
+ },
54
+ },
55
+
56
+ data() {
57
+ return {
58
+ show: true,
59
+ };
60
+ },
61
+
62
+ computed: {
63
+ isSuccess() {
64
+ return this.variant === 'success';
65
+ },
66
+
67
+ isError() {
68
+ return this.variant === 'error';
69
+ },
70
+
71
+ isWarning() {
72
+ return this.variant === 'warning';
73
+ },
74
+ },
75
+
76
+ methods: {
77
+ hide() {
78
+ this.$emit('dismiss');
79
+ this.show = false;
80
+ },
81
+ },
82
+ };
83
+ </script>
@@ -1,85 +1,125 @@
1
1
  <template>
2
2
  <component
3
3
  :is="tag"
4
- :class="classes"
5
- :data-theme="theme"
6
4
  :to="to"
7
- class="Button"
8
- type="button"
5
+ :type="type"
6
+ :disabled="isDisabled"
7
+ :class="[
8
+ // default styles
9
+ headless
10
+ ? 'button'
11
+ : isIcon
12
+ ? 'inline-flex items-center justify-center rounded-full [&_svg]:max-h-full [&_svg]:max-w-full'
13
+ : 'relative inline-flex rounded border border-solid px-4 text-sm font-semibold leading-none no-underline transition-all',
14
+ // variant styles
15
+ headless
16
+ ? `button--${variant}`
17
+ : isPrimary
18
+ ? 'border-transparent bg-secondary-400 text-white hover:bg-secondary-500 active:bg-secondary-600 disabled:bg-gray-200 disabled:text-gray-400'
19
+ : isSecondary
20
+ ? 'border-gray-400 bg-white text-gray-700 hover:bg-gray-100 active:bg-gray-200 disabled:border-gray-300 disabled:text-gray-400'
21
+ : isTertiary
22
+ ? 'border-transparent text-secondary-400 hover:text-secondary-500 active:text-secondary-500 disabled:text-gray-400'
23
+ : isIcon
24
+ ? 'text-primary-100 focus-within:bg-gray-200 hover:bg-gray-200 active:bg-gray-300'
25
+ : null,
26
+ // sizes styles
27
+ headless
28
+ ? `button--${size}`
29
+ : isLarge
30
+ ? isIcon
31
+ ? 'h-8 w-8'
32
+ : 'h-10'
33
+ : isSmall
34
+ ? isIcon
35
+ ? 'h-6 w-6 p-1'
36
+ : 'h-8'
37
+ : null,
38
+ ]"
9
39
  v-on="$listeners"
10
40
  >
11
- <slot></slot>
41
+ <VTSpinner v-if="busy" class="absolute inset-0 m-auto" />
42
+ <span
43
+ :class="[
44
+ headless ? null : 'inline-flex items-center gap-2 self-center mx-auto',
45
+ headless && busy ? 'button--busy' : busy ? 'invisible' : null,
46
+ ]"
47
+ >
48
+ <slot></slot>
49
+ </span>
12
50
  </component>
13
51
  </template>
14
52
 
15
53
  <script>
54
+ import VTSpinner from '../Spinner/VTSpinner.vue';
55
+
16
56
  export default {
17
57
  name: 'VTButton',
18
58
 
59
+ components: { VTSpinner },
60
+
19
61
  props: {
20
62
  variant: {
21
63
  type: String,
22
64
  default: 'primary',
23
- validator(value) {
24
- return [
25
- 'primary',
26
- 'secondary',
27
- 'tertiary',
28
- 'danger',
29
- 'custom',
30
- 'icon',
31
- ].includes(value);
32
- },
33
65
  },
34
66
  size: {
35
67
  type: String,
36
68
  default: 'large',
37
- validator(value) {
38
- return ['large', 'small'].includes(value);
39
- },
40
69
  },
41
- pill: {
70
+ to: {
71
+ type: [String, Object],
72
+ default: null,
73
+ },
74
+ headless: {
42
75
  type: Boolean,
43
76
  default: false,
44
77
  },
45
- theme: {
46
- type: String,
47
- default: null,
48
- validator(value) {
49
- return ['dark'].includes(value);
50
- },
78
+ busy: {
79
+ type: Boolean,
80
+ default: false,
51
81
  },
52
- to: {
53
- type: [String, Object],
54
- default: null,
82
+ disabled: {
83
+ type: Boolean,
84
+ default: false,
55
85
  },
56
86
  },
57
87
 
58
88
  computed: {
59
- classes() {
60
- const classes = {};
89
+ isPrimary() {
90
+ return this.variant === 'primary';
91
+ },
92
+
93
+ isSecondary() {
94
+ return this.variant === 'secondary';
95
+ },
61
96
 
62
- if (this.variant) {
63
- classes[`Button--${this.variant}`] = true;
64
- }
97
+ isTertiary() {
98
+ return this.variant === 'tertiary';
99
+ },
100
+
101
+ isIcon() {
102
+ return this.variant === 'icon';
103
+ },
65
104
 
66
- if (this.size) {
67
- classes[`Button--${this.size}`] = true;
68
- }
105
+ isLarge() {
106
+ return this.size === 'large';
107
+ },
69
108
 
70
- if (this.pill) {
71
- classes['Button--pill'] = true;
72
- }
109
+ isSmall() {
110
+ return this.size === 'small';
111
+ },
73
112
 
74
- return classes;
113
+ isDisabled() {
114
+ return this.disabled || this.busy;
75
115
  },
76
116
 
77
117
  tag() {
78
- if (this.to) {
79
- return 'NuxtLink';
80
- }
118
+ return this.to ? 'NuxtLink' : 'button';
119
+ },
81
120
 
82
- return 'button';
121
+ type() {
122
+ return this.to ? null : 'button';
83
123
  },
84
124
  },
85
125
  };
@@ -1,23 +1,30 @@
1
1
  <template>
2
- <div
3
- v-if="visible"
4
- :id="id"
5
- :class="{
6
- Dialog: headless,
7
- 'fixed inset-0 z-50 grid grid-cols-1 grid-rows-1 p-4 md:p-8': !headless,
8
- }"
9
- aria-modal="true"
10
- @click="onClick"
11
- >
12
- <slot></slot>
13
- </div>
2
+ <Portal>
3
+ <div
4
+ v-if="visible"
5
+ :id="id"
6
+ :class="{
7
+ Dialog: headless,
8
+ 'fixed inset-0 z-50 grid grid-cols-1 grid-rows-1 p-4 md:p-8': !headless,
9
+ }"
10
+ aria-modal="true"
11
+ @click="onClick"
12
+ >
13
+ <slot></slot>
14
+ </div>
15
+ </Portal>
14
16
  </template>
15
17
 
16
18
  <script>
17
- import { genId } from "../../utils/ids";
19
+ import { Portal } from '@linusborg/vue-simple-portal';
20
+ import { genId } from '../../utils/ids';
18
21
 
19
22
  export default {
20
- name: "VTDialog",
23
+ name: 'VTDialog',
24
+
25
+ components: {
26
+ Portal,
27
+ },
21
28
 
22
29
  provide() {
23
30
  return {
@@ -56,7 +63,7 @@ export default {
56
63
  },
57
64
 
58
65
  model: {
59
- prop: "visible",
66
+ prop: 'visible',
60
67
  },
61
68
 
62
69
  props: {
@@ -115,8 +122,8 @@ export default {
115
122
 
116
123
  emit() {
117
124
  this.$nextTick(() => {
118
- this.$emit("input", false);
119
- this.$emit("hidden");
125
+ this.$emit('input', false);
126
+ this.$emit('hidden');
120
127
  });
121
128
  },
122
129
 
@@ -0,0 +1,42 @@
1
+ <template>
2
+ <div
3
+ :class="[
4
+ headless
5
+ ? 'progress-bar'
6
+ : 'relative min-h-[10px] w-full overflow-hidden rounded-full bg-gray-200',
7
+ ]"
8
+ role="progressbar"
9
+ aria-valuemin="0"
10
+ aria-valuemax="100"
11
+ :aria-valuenow="value"
12
+ :aria-label="label"
13
+ >
14
+ <div
15
+ :class="[
16
+ headless
17
+ ? 'progress-bar__indicator'
18
+ : 'absolute left-0 h-full bg-secondary-300',
19
+ ]"
20
+ :style="{ width: `${value}%` }"
21
+ ></div>
22
+ </div>
23
+ </template>
24
+
25
+ <script>
26
+ export default {
27
+ props: {
28
+ headless: {
29
+ type: Boolean,
30
+ default: false,
31
+ },
32
+ label: {
33
+ type: String,
34
+ default: null,
35
+ },
36
+ value: {
37
+ type: [String, Number],
38
+ default: 0,
39
+ },
40
+ },
41
+ };
42
+ </script>
@@ -1,72 +0,0 @@
1
- <template>
2
- <div v-if="isVisible" class="Alert" :class="classes" role="alert">
3
- <slot></slot>
4
- <button v-if="dismissable" class="Alert-close" @click="dismiss">
5
- <IconClose />
6
- </button>
7
- </div>
8
- </template>
9
-
10
- <script>
11
- import { IconClose } from '@veritree/icons';
12
-
13
- export default {
14
- name: 'VTAlert',
15
-
16
- components: { IconClose },
17
-
18
- model: {
19
- prop: 'value',
20
- },
21
-
22
- props: {
23
- dismissable: {
24
- type: Boolean,
25
- default: false,
26
- },
27
- variant: {
28
- type: String,
29
- default: '',
30
- validate(value) {
31
- if (value === '') return true;
32
- return ['success', 'warning', 'error'].includes(value);
33
- },
34
- },
35
- value: {
36
- type: Boolean,
37
- default: false,
38
- },
39
- },
40
-
41
- data() {
42
- return {
43
- destroy: false,
44
- };
45
- },
46
-
47
- computed: {
48
- classes() {
49
- return {
50
- [`Alert--${this.variant}`]: this.variant,
51
- };
52
- },
53
-
54
- isVisible() {
55
- return this.value && !this.destroy;
56
- },
57
- },
58
-
59
- watch: {
60
- isVisible(newVal) {
61
- if (newVal === false) this.destroy = false;
62
- },
63
- },
64
-
65
- methods: {
66
- dismiss() {
67
- this.destroy = true;
68
- this.$emit('input', false);
69
- },
70
- },
71
- };
72
- </script>
@@ -1,27 +0,0 @@
1
- <template>
2
- <VTButton
3
- class="relative"
4
- :disabled="saving"
5
- v-bind="$attrs"
6
- v-on="$listeners"
7
- >
8
- <VTSpinner v-if="saving" class="absolute m-auto" />
9
- <span :class="{ invisible: saving }"><slot></slot></span>
10
- </VTButton>
11
- </template>
12
-
13
- <script>
14
- import VTButton from '../Button/VTButton.vue';
15
- import VTSpinner from '../Spinner/VTSpinner.vue';
16
-
17
- export default {
18
- components: { VTButton, VTSpinner },
19
-
20
- props: {
21
- saving: {
22
- type: Boolean,
23
- default: false,
24
- },
25
- },
26
- };
27
- </script>