@dataloop-ai/components 0.17.11 → 0.17.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataloop-ai/components",
3
- "version": "0.17.11",
3
+ "version": "0.17.13",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -151,8 +151,8 @@
151
151
  >
152
152
  <dl-list
153
153
  class="select-list"
154
- :style="dropdownCSSVars"
155
154
  :padding="false"
155
+ :max-height="dropdownMaxHeight"
156
156
  >
157
157
  <dl-list-item v-if="noOptions">
158
158
  <dl-item-section color="dl-color-medium">
@@ -551,11 +551,6 @@ export default defineComponent({
551
551
  : '28px'
552
552
  }
553
553
  },
554
- dropdownCSSVars(): Record<string, string> {
555
- return {
556
- '--dl-select-dropdown-max-height': this.dropdownMaxHeight
557
- }
558
- },
559
554
  asteriskClasses(): string[] {
560
555
  const classes = ['required-asterisk']
561
556
  if (this.redAsterisk) {
@@ -965,6 +960,7 @@ export default defineComponent({
965
960
  background-color: var(--dl-color-fill);
966
961
  }
967
962
 
963
+ //todo: This doesnt work because of portal.
968
964
  .select-list {
969
965
  padding: 5px 0;
970
966
  max-height: var(--dl-select-dropdown-max-height);
@@ -2,6 +2,7 @@ import { isVue3 } from 'vue-demi'
2
2
  import toastComponent from '../components/ToastComponent.vue'
3
3
  import { createComponent } from '../utils/render'
4
4
  import { v4 } from 'uuid'
5
+ import { DlToastProps, DlToastTypes } from '../types'
5
6
 
6
7
  const state: { prevToastId: any; toasts: { [key: string]: any } } = {
7
8
  prevToastId: null,
@@ -10,7 +11,7 @@ const state: { prevToastId: any; toasts: { [key: string]: any } } = {
10
11
 
11
12
  export const useToast = (globalProps = {}) => {
12
13
  return {
13
- open(options: Object | string) {
14
+ open(options: DlToastProps | string) {
14
15
  let message = null
15
16
  if (typeof options === 'string') message = options
16
17
 
@@ -55,6 +56,46 @@ export const useToast = (globalProps = {}) => {
55
56
  propsData,
56
57
  document.body
57
58
  )
59
+ },
60
+ success(options: DlToastProps | string) {
61
+ let props: Partial<DlToastProps> = {}
62
+ if (typeof options === 'string') {
63
+ props.message = options
64
+ } else {
65
+ props = options
66
+ }
67
+
68
+ this.open({ ...props, type: DlToastTypes.SUCCESS } as DlToastProps)
69
+ },
70
+ error(options: DlToastProps | string) {
71
+ let props: Partial<DlToastProps> = {}
72
+ if (typeof options === 'string') {
73
+ props.message = options
74
+ } else {
75
+ props = options
76
+ }
77
+
78
+ this.open({ ...props, type: DlToastTypes.ERROR } as DlToastProps)
79
+ },
80
+ info(options: DlToastProps | string) {
81
+ let props: Partial<DlToastProps> = {}
82
+ if (typeof options === 'string') {
83
+ props.message = options
84
+ } else {
85
+ props = options
86
+ }
87
+
88
+ this.open({ ...props, type: DlToastTypes.INFO } as DlToastProps)
89
+ },
90
+ warn(options: DlToastProps | string) {
91
+ let props: Partial<DlToastProps> = {}
92
+ if (typeof options === 'string') {
93
+ props.message = options
94
+ } else {
95
+ props = options
96
+ }
97
+
98
+ this.open({ ...props, type: DlToastTypes.WARNING } as DlToastProps)
58
99
  }
59
100
  }
60
101
  }
@@ -8,11 +8,7 @@
8
8
  :id="`DlToastContainer-${uuid}`"
9
9
  ref="root"
10
10
  class="toast-item DlToastContainer"
11
- :class="[
12
- `toast-item--${type}`,
13
- `toast-item--${position}`,
14
- classItem
15
- ]"
11
+ :class="[`toast-item--${type}`, `toast-item--${position}`]"
16
12
  :style="{ width }"
17
13
  >
18
14
  <dl-alert
@@ -64,7 +60,7 @@ import {
64
60
  ref
65
61
  } from 'vue-demi'
66
62
  import { DlAlert, DlBadge } from '../../../'
67
- import { Positions, Types } from '../utils/config'
63
+ import { DlToastTypes, DlToastPositions } from '../types'
68
64
  import { removeElement } from '../utils/render'
69
65
  import { Animation } from '../types'
70
66
  import { v4 } from 'uuid'
@@ -79,15 +75,11 @@ export default defineComponent({
79
75
  },
80
76
  type: {
81
77
  type: String,
82
- default: 'success',
83
- validator(value: string): boolean {
84
- return Object.values(Types as unknown).includes(value)
78
+ required: true,
79
+ validator(value: DlToastTypes): boolean {
80
+ return Object.values(DlToastTypes).includes(value)
85
81
  }
86
82
  },
87
- classItem: {
88
- type: String,
89
- default: ''
90
- },
91
83
  width: {
92
84
  type: String,
93
85
  default: 'auto'
@@ -98,9 +90,9 @@ export default defineComponent({
98
90
  },
99
91
  position: {
100
92
  type: String,
101
- default: Positions.bottom,
102
- validator(value: string): boolean {
103
- return Object.values(Positions as unknown).includes(value)
93
+ default: DlToastPositions.BOTTOM,
94
+ validator(value: DlToastPositions): boolean {
95
+ return Object.values(DlToastPositions).includes(value)
104
96
  }
105
97
  },
106
98
  closable: {
@@ -151,14 +143,14 @@ export default defineComponent({
151
143
 
152
144
  const correctParent = computed(() => {
153
145
  switch (position) {
154
- case Positions.top:
155
- case Positions.top_right:
156
- case Positions.top_left:
146
+ case DlToastPositions.TOP:
147
+ case DlToastPositions.TOP_RIGHT:
148
+ case DlToastPositions.TOP_LEFT:
157
149
  toastParentPosition.value = 'top'
158
150
  return parentTop
159
- case Positions.bottom:
160
- case Positions.bottom_right:
161
- case Positions.bottom_left:
151
+ case DlToastPositions.BOTTOM:
152
+ case DlToastPositions.BOTTOM_RIGHT:
153
+ case DlToastPositions.BOTTOM_LEFT:
162
154
  toastParentPosition.value = 'bottom'
163
155
  return parentBottom
164
156
  }
@@ -166,16 +158,16 @@ export default defineComponent({
166
158
 
167
159
  const transition = computed((): Animation => {
168
160
  switch (position) {
169
- case Positions.top:
170
- case Positions.top_right:
171
- case Positions.top_left:
161
+ case DlToastPositions.TOP:
162
+ case DlToastPositions.TOP_RIGHT:
163
+ case DlToastPositions.TOP_LEFT:
172
164
  return {
173
165
  enter: 'dl-toast--fade-in-down',
174
166
  leave: 'dl-toast--fade-out'
175
167
  }
176
- case Positions.bottom:
177
- case Positions.bottom_right:
178
- case Positions.bottom_left:
168
+ case DlToastPositions.BOTTOM:
169
+ case DlToastPositions.BOTTOM_RIGHT:
170
+ case DlToastPositions.BOTTOM_LEFT:
179
171
  return {
180
172
  enter: 'dl-toast--fade-in-up',
181
173
  leave: 'dl-toast--fade-out'
@@ -231,13 +223,13 @@ export default defineComponent({
231
223
 
232
224
  const badgeColor = computed(() => {
233
225
  switch (props.type) {
234
- case Types.success:
226
+ case DlToastTypes.SUCCESS:
235
227
  return 'var(--dl-color-alert-success)'
236
- case Types.warning:
228
+ case DlToastTypes.WARNING:
237
229
  return 'var(--dl-color-alert-warn)'
238
- case Types.error:
230
+ case DlToastTypes.ERROR:
239
231
  return 'var(--dl-color-alert-error)'
240
- case Types.info:
232
+ case DlToastTypes.INFO:
241
233
  return 'var(--dl-color-alert-info)'
242
234
  }
243
235
  })
@@ -2,3 +2,55 @@ export interface Animation {
2
2
  enter: string
3
3
  leave: string
4
4
  }
5
+
6
+ export enum DlToastPositions {
7
+ TOP_RIGHT = 'top-right',
8
+ TOP = 'top',
9
+ TOP_LEFT = 'top-left',
10
+ BOTTOM_RIGHT = 'bottom-right',
11
+ BOTTOM = 'bottom',
12
+ BOTTOM_LEFT = 'bottom-left'
13
+ }
14
+
15
+ export enum DlToastTypes {
16
+ SUCCESS = 'success',
17
+ WARNING = 'warning',
18
+ ERROR = 'error',
19
+ INFO = 'info'
20
+ }
21
+
22
+ export interface DlToastProps {
23
+ /**
24
+ * The message to display in the toast
25
+ */
26
+ message: string
27
+ /**
28
+ * The type of the toast
29
+ */
30
+ type: DlToastTypes
31
+ /**
32
+ * The width of the toast
33
+ * @default 'auto'
34
+ */
35
+ width?: string
36
+ /**
37
+ * The duration of the toast in seconds
38
+ * @default 10
39
+ */
40
+ duration?: number
41
+ /**
42
+ * The position of the toast
43
+ * @default DlToastPositions.BOTTOM
44
+ */
45
+ position?: DlToastPositions
46
+ /**
47
+ * Whether the toast is closable
48
+ * @default true
49
+ */
50
+ closable?: boolean
51
+ /**
52
+ * The number of toasts to collapse after
53
+ * @default 5
54
+ */
55
+ collapseCount?: number
56
+ }
@@ -3,6 +3,7 @@
3
3
  :is="tag"
4
4
  :id="uuid"
5
5
  :class="classes"
6
+ :style="cssVars"
6
7
  >
7
8
  <slot :clickable="clickable" />
8
9
  </component>
@@ -21,6 +22,10 @@ export default defineComponent({
21
22
  tag: {
22
23
  type: String,
23
24
  default: 'div'
25
+ },
26
+ maxHeight: {
27
+ type: String,
28
+ default: '30vh'
24
29
  }
25
30
  },
26
31
  data() {
@@ -36,6 +41,11 @@ export default defineComponent({
36
41
  (this.separator ? ' dl-list--separator' : '') +
37
42
  (this.padding ? ' dl-list--padding' : '')
38
43
  )
44
+ },
45
+ cssVars(): Record<string, string> {
46
+ return {
47
+ '--dl-list-calculated-max-height': this.maxHeight
48
+ }
39
49
  }
40
50
  }
41
51
  })
@@ -62,5 +72,6 @@ export default defineComponent({
62
72
  &--padding {
63
73
  padding: 8px 0;
64
74
  }
75
+ max-height: var(--dl-list-max-height, --dl-list-calculated-max-height);
65
76
  }
66
77
  </style>
@@ -16,10 +16,6 @@
16
16
  type="number"
17
17
  title="Collapse count"
18
18
  />
19
- <dl-input
20
- v-model="classItem"
21
- title="Custom class for toast item"
22
- />
23
19
  <dl-input
24
20
  v-model="width"
25
21
  title="Custom width for toast item"
@@ -106,6 +102,7 @@ import {
106
102
  DlTextArea,
107
103
  DlToast
108
104
  } from '../components'
105
+ import { DlToastPositions, DlToastTypes } from '../components/types'
109
106
 
110
107
  export default defineComponent({
111
108
  name: 'DlToast',
@@ -124,16 +121,14 @@ export default defineComponent({
124
121
  const type = ref('success')
125
122
  const position = ref('bottom')
126
123
  const closable = ref(true)
127
- const classItem = ref('demo-toast')
128
124
  const width = ref('auto')
129
125
  const collapseCount = ref(null)
130
126
  function showToastMessage() {
131
127
  DlToast.open({
132
128
  message: message.value,
133
- position: position.value,
134
- type: type.value,
129
+ position: position.value as DlToastPositions,
130
+ type: type.value as DlToastTypes,
135
131
  duration: Number(duration.value) || 1000,
136
- classItem: classItem.value,
137
132
  closable: closable.value,
138
133
  width: width.value,
139
134
  collapseCount: collapseCount.value
@@ -145,7 +140,6 @@ export default defineComponent({
145
140
  duration,
146
141
  type,
147
142
  position,
148
- classItem,
149
143
  closable,
150
144
  width,
151
145
  collapseCount
@@ -1,17 +0,0 @@
1
- const Positions = Object.freeze({
2
- top_right: 'top-right',
3
- top: 'top',
4
- top_left: 'top-left',
5
- bottom_right: 'bottom-right',
6
- bottom: 'bottom',
7
- bottom_left: 'bottom-left'
8
- })
9
-
10
- const Types = Object.freeze({
11
- success: 'success',
12
- warning: 'warning',
13
- error: 'error',
14
- info: 'info'
15
- })
16
-
17
- export { Positions, Types }