@privyid/persona 0.21.0 → 0.22.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 (118) hide show
  1. package/dist/components/accordion/Accordion.vue +1 -1
  2. package/dist/components/accordion/AccordionItem.vue +6 -6
  3. package/dist/components/badge/Badge.vue +21 -3
  4. package/dist/components/banner/Banner.vue +5 -0
  5. package/dist/components/banner/Banner.vue.d.ts +9 -0
  6. package/dist/components/button/Button.vue +18 -18
  7. package/dist/components/calendar/adapter/adapter.d.ts +1 -8
  8. package/dist/components/calendar/adapter/adapter.mjs +0 -10
  9. package/dist/components/calendar/adapter/date.mjs +2 -2
  10. package/dist/components/calendar/adapter/month.mjs +2 -2
  11. package/dist/components/card/CardSection.vue +1 -0
  12. package/dist/components/carousel/Carousel.vue.d.ts +6 -6
  13. package/dist/components/chart/ChartSet.vue.d.ts +2 -2
  14. package/dist/components/chart/ChartVal.vue.d.ts +4 -4
  15. package/dist/components/checkbox/Checkbox.vue +98 -112
  16. package/dist/components/checkbox/icon/IconCheckbox.vue +13 -0
  17. package/dist/components/checkbox/icon/IconInderteminate.vue +12 -0
  18. package/dist/components/contextual-bar/ContextualBar.vue +67 -19
  19. package/dist/components/contextual-bar/ContextualBar.vue.d.ts +3 -3
  20. package/dist/components/contextual-bar/index.d.ts +1 -1
  21. package/dist/components/cropper/Cropper.vue.d.ts +8 -8
  22. package/dist/components/datepicker/Datepicker.vue +2 -0
  23. package/dist/components/datepicker/Datepicker.vue.d.ts +1 -1
  24. package/dist/components/dialog/Dialog.vue +2 -0
  25. package/dist/components/dialog/index.d.ts +2 -0
  26. package/dist/components/divider/Divider.vue +1 -1
  27. package/dist/components/dropdown/Dropdown.vue +303 -222
  28. package/dist/components/dropzone/Dropzone.vue.d.ts +3 -3
  29. package/dist/components/filterbar/pinned/PinnedDate.vue +2 -0
  30. package/dist/components/filterbar/pinned/PinnedDate.vue.d.ts +1 -1
  31. package/dist/components/filterbar/pinned/PinnedMultiselect.vue +10 -6
  32. package/dist/components/filterbar/pinned/PinnedSelect.vue +11 -7
  33. package/dist/components/filterbar/pinned/PinnedSelect.vue.d.ts +3 -3
  34. package/dist/components/filterbar/pinned/PinnedToggle.vue.d.ts +7 -7
  35. package/dist/components/global/store.d.ts +2 -1
  36. package/dist/components/heading/Heading.vue.d.ts +1 -1
  37. package/dist/components/input/Input.vue +16 -5
  38. package/dist/components/input/Input.vue.d.ts +4 -3
  39. package/dist/components/input/index.d.ts +1 -1
  40. package/dist/components/input-file/InputFile.vue.d.ts +3 -3
  41. package/dist/components/input-pin/InputPin.vue.d.ts +2 -2
  42. package/dist/components/input-range/InputRange.vue.d.ts +6 -6
  43. package/dist/components/label/Label.vue +9 -8
  44. package/dist/components/label/Label.vue.d.ts +1 -1
  45. package/dist/components/main/Main.vue +4 -2
  46. package/dist/components/markdown/index.d.ts +6 -1
  47. package/dist/components/markdown/index.mjs +8 -2
  48. package/dist/components/meta.json +135 -0
  49. package/dist/components/modal/Modal.vue +215 -12
  50. package/dist/components/modal/Modal.vue.d.ts +55 -1
  51. package/dist/components/modal/index.d.ts +1 -1
  52. package/dist/components/nav/Nav.vue +5 -1
  53. package/dist/components/nav/NavItemDropdown.vue.d.ts +1 -1
  54. package/dist/components/nav/NavSubItem.vue +6 -6
  55. package/dist/components/navbar/Navbar.vue.d.ts +1 -1
  56. package/dist/components/navbar/NavbarBrand.vue +1 -1
  57. package/dist/components/pdf-helipad/PdfHelipad.vue +101 -85
  58. package/dist/components/pdf-helipad/utils/use-drag.d.ts +2 -7
  59. package/dist/components/pdf-helipad/utils/use-drag.mjs +1 -1
  60. package/dist/components/pdf-object/utils/use-drag.d.ts +1 -0
  61. package/dist/components/pdf-object/utils/use-drag.mjs +1 -1
  62. package/dist/components/pdf-viewer/PdfViewer.vue.d.ts +4 -4
  63. package/dist/components/progress-indicator/ProgressIndicator.vue.d.ts +2 -2
  64. package/dist/components/progressbar/Progressbar.vue.d.ts +7 -7
  65. package/dist/components/radio/Radio.vue.d.ts +4 -4
  66. package/dist/components/ringbar/Ringbar.vue.d.ts +6 -6
  67. package/dist/components/select/Select.vue +396 -214
  68. package/dist/components/select/SelectInput.vue +102 -0
  69. package/dist/components/select/SelectTags.vue +57 -0
  70. package/dist/components/select/adapter/adapter.d.ts +1 -0
  71. package/dist/components/select/adapter/async-adapter.d.ts +13 -1
  72. package/dist/components/select/adapter/async-adapter.mjs +8 -15
  73. package/dist/components/select/index.d.ts +2 -0
  74. package/dist/components/select/index.mjs +4 -1
  75. package/dist/components/sheet/Sheet.vue +2 -3
  76. package/dist/components/sidebar/Sidebar.vue +101 -116
  77. package/dist/components/sidebar/SidebarBrand.vue +1 -1
  78. package/dist/components/sidebar/SidebarContent.vue +27 -0
  79. package/dist/components/sidebar/SidebarNav.vue +60 -84
  80. package/dist/components/sidebar-menu/SidebarMenu.vue +57 -204
  81. package/dist/components/sidebar-menu/SidebarMenuItem.vue +70 -0
  82. package/dist/components/signature-text/SignatureText.vue.d.ts +4 -4
  83. package/dist/components/steps/StepSlider.vue +2 -2
  84. package/dist/components/strengthbar/Strengthbar.vue.d.ts +8 -8
  85. package/dist/components/table-flex/TableFlex.vue +3 -5
  86. package/dist/components/table-static/TableStatic.vue +118 -111
  87. package/dist/components/table-static/TableStaticRoot.vue +42 -0
  88. package/dist/components/tabs/Tab.vue +13 -15
  89. package/dist/components/tabs/TabContent.vue +64 -23
  90. package/dist/components/tabs/Tabs.vue +93 -75
  91. package/dist/components/text/Text.vue +15 -7
  92. package/dist/components/text/Text.vue.d.ts +11 -2
  93. package/dist/components/text/index.d.ts +1 -0
  94. package/dist/components/textarea/Textarea.vue.d.ts +5 -5
  95. package/dist/components/toggle/Toggle.vue +12 -1
  96. package/dist/components/toggle/Toggle.vue.d.ts +16 -7
  97. package/dist/components/tooltip/index.mjs +1 -1
  98. package/dist/components/tooltip/utils/create-handler.mjs +1 -1
  99. package/dist/components/tour/TourDialog.vue +6 -0
  100. package/dist/components/truncate/Truncate.vue +1 -1
  101. package/dist/components/truncate/Truncate.vue.d.ts +2 -2
  102. package/dist/components/utils/date.d.ts +21 -0
  103. package/dist/components/utils/date.mjs +15 -0
  104. package/dist/components/utils/vnode.mjs +1 -1
  105. package/dist/core/index.d.ts +1 -0
  106. package/dist/core/index.mjs +4 -0
  107. package/dist/module.json +1 -1
  108. package/package.json +17 -17
  109. package/dist/components/checkbox/Checkbox.vue.d.ts +0 -84
  110. package/dist/components/dropdown/Dropdown.vue.d.ts +0 -147
  111. package/dist/components/pdf-helipad/PdfHelipad.vue.d.ts +0 -45
  112. package/dist/components/select/Select.vue.d.ts +0 -157
  113. package/dist/components/sidebar/Sidebar.vue.d.ts +0 -80
  114. package/dist/components/sidebar/SidebarNav.vue.d.ts +0 -66
  115. package/dist/components/sidebar-menu/SidebarMenu.vue.d.ts +0 -91
  116. package/dist/components/tabs/Tab.vue.d.ts +0 -23
  117. package/dist/components/tabs/TabContent.vue.d.ts +0 -14
  118. package/dist/components/tabs/Tabs.vue.d.ts +0 -80
@@ -13,21 +13,33 @@
13
13
  mode="out-in">
14
14
  <div
15
15
  v-show="model"
16
- class="modal__dialog">
16
+ class="modal__dialog"
17
+ :class="dialogClass"
18
+ data-testid="modal-dialog">
19
+ <span
20
+ v-if="dismissable && (size === 'full' && freeDistraction)"
21
+ data-testid="modal-free-distraction-dismiss"
22
+ class="modal__dismiss"
23
+ @click="close">
24
+ <IconCloseFull class="text-state-emphasis dark:text-dark-state-emphasis" />
25
+ </span>
17
26
  <div
18
27
  class="modal__content"
28
+ :class="contentClass"
29
+ data-testid="modal-content"
19
30
  @click.stop>
20
31
  <span
21
- v-if="dismissable"
32
+ v-if="dismissable && size !== 'full'"
22
33
  data-testid="modal-dismiss"
23
34
  class="modal__dismiss"
24
35
  @click="close">
25
36
  <IconClose />
26
37
  </span>
27
38
  <div
28
- v-if="$slots.header || title"
39
+ v-if="($slots.header || title) && (size !== 'full' || freeDistraction)"
29
40
  data-testid="modal-header"
30
- class="modal__header">
41
+ class="modal__header"
42
+ :class="headerClass">
31
43
  <slot name="header">
32
44
  <Heading
33
45
  v-if="title"
@@ -39,15 +51,51 @@
39
51
  </div>
40
52
  <div
41
53
  data-testid="modal-body"
42
- :class="[ { 'modal__body--scroll' : modalBodyScrollable }, 'modal__body' ]">
43
- <slot>
54
+ :class="[ { 'modal__body--scroll' : modalBodyScrollable}, (size !== 'full' || freeDistraction) ? bodyClass : '', 'modal__body' ]">
55
+ <div
56
+ v-if="size === 'full' && !freeDistraction"
57
+ class="modal--full__content">
58
+ <div
59
+ class="modal--full__header">
60
+ <span
61
+ v-if="dismissable"
62
+ class="modal--full__header__dismiss">
63
+ <Button
64
+ variant="link"
65
+ data-testid="modal-full-dismiss"
66
+ @click="close">
67
+ <IconCloseFull />
68
+ </Button>
69
+ </span>
70
+ <div
71
+ data-testid="modal-full-header"
72
+ class="modal--full__header__title"
73
+ :class="headerClass">
74
+ <slot name="header">
75
+ <Heading
76
+ v-if="title"
77
+ class="modal__title"
78
+ element="h6">
79
+ {{ title }}
80
+ </Heading>
81
+ </slot>
82
+ </div>
83
+ </div><!-- /header -->
84
+ <div :class="bodyClass">
85
+ <slot name="body">
86
+ {{ text }}
87
+ </slot>
88
+ </div><!-- /body -->
89
+ </div><!-- /content -->
90
+ <slot v-else>
44
91
  {{ text }}
45
92
  </slot>
46
93
  </div>
47
94
  <div
48
- v-if="$slots.footer"
95
+ v-if="$slots.footer && (size !== 'full' || freeDistraction)"
49
96
  data-testid="modal-footer"
50
- class="modal__footer">
97
+ class="modal__footer"
98
+ :class="footerClass">
51
99
  <slot
52
100
  name="footer"
53
101
  :close="close" />
@@ -68,10 +116,17 @@ import {
68
116
  } from "vue-demi";
69
117
  import { onKeyStroke } from "@vueuse/core";
70
118
  import Heading from "../heading/Heading.vue";
119
+ import Button from "../button/Button.vue";
71
120
  import IconClose from "@privyid/persona-icon/vue/close/16.vue";
121
+ import IconCloseFull from "@privyid/persona-icon/vue/close/24.vue";
72
122
  import { useVModel } from "../input";
73
123
  export default defineComponent({
74
- components: { Heading, IconClose },
124
+ components: {
125
+ Heading,
126
+ Button,
127
+ IconClose,
128
+ IconCloseFull
129
+ },
75
130
  props: {
76
131
  title: {
77
132
  type: String,
@@ -112,6 +167,50 @@ export default defineComponent({
112
167
  centered: {
113
168
  type: Boolean,
114
169
  default: false
170
+ },
171
+ freeDistraction: {
172
+ type: Boolean,
173
+ default: false
174
+ },
175
+ headerClass: {
176
+ type: [
177
+ String,
178
+ Array,
179
+ Object
180
+ ],
181
+ default: void 0
182
+ },
183
+ dialogClass: {
184
+ type: [
185
+ String,
186
+ Array,
187
+ Object
188
+ ],
189
+ default: void 0
190
+ },
191
+ contentClass: {
192
+ type: [
193
+ String,
194
+ Array,
195
+ Object
196
+ ],
197
+ default: void 0
198
+ },
199
+ bodyClass: {
200
+ type: [
201
+ String,
202
+ Array,
203
+ Object
204
+ ],
205
+ default: void 0
206
+ },
207
+ footerClass: {
208
+ type: [
209
+ String,
210
+ Array,
211
+ Object
212
+ ],
213
+ default: void 0
115
214
  }
116
215
  },
117
216
  models: {
@@ -129,6 +228,8 @@ export default defineComponent({
129
228
  result.push("modal--centered");
130
229
  if (props.banner)
131
230
  result.push("modal--banner");
231
+ if (props.freeDistraction && props.size === "full")
232
+ result.push("modal--free-distraction");
132
233
  return result;
133
234
  });
134
235
  function close(event) {
@@ -172,6 +273,7 @@ export default defineComponent({
172
273
  /**
173
274
  * modal sizing variables
174
275
  */
276
+ --p-modal-size-full: 1022px;
175
277
  --p-modal-size-xl: 960px;
176
278
  --p-modal-size-lg: 800px;
177
279
  --p-modal-size-md: 600px;
@@ -234,11 +336,20 @@ export default defineComponent({
234
336
  }
235
337
  }
236
338
 
339
+ /**
340
+ * Set padding
341
+ * in body and footer
342
+ * of modal
343
+ */
237
344
  &__body,
238
345
  &__footer {
239
346
  @apply p-6;
240
347
  }
241
348
 
349
+ /**
350
+ * Modal variant
351
+ * Scroll
352
+ */
242
353
  &__body {
243
354
  &&--scroll {
244
355
  @apply max-h-[var(--p-modal-body-scrollable-max-height)] min-h-[var(--p-modal-body-scrollable-min-height)] overflow-y-auto overscroll-contain;
@@ -256,9 +367,9 @@ export default defineComponent({
256
367
  }
257
368
 
258
369
  /**
259
- * Modal has 4 different size
260
- * eg: small, medium, large
261
- * and extra large. default
370
+ * Modal has 5 different size
371
+ * eg: small, medium, large,
372
+ * extra large and full. default
262
373
  * size are medium
263
374
  */
264
375
  &&--xl {
@@ -285,6 +396,98 @@ export default defineComponent({
285
396
  }
286
397
  }
287
398
 
399
+ /**
400
+ * Modal has 2 types of
401
+ * full size, eg: full and
402
+ * free-distraction
403
+ */
404
+ &&--full {
405
+ /**
406
+ * Style of Modal full
407
+ * except free distraction type
408
+ */
409
+ &:not(.modal--free-distraction) {
410
+ /**
411
+ * Make modal dialog and
412
+ * modal content full height
413
+ */
414
+ .modal__dialog {
415
+ @apply h-full min-h-full;
416
+ }
417
+ .modal__content {
418
+ @apply w-full max-w-full my-0 rounded-none;
419
+ }
420
+
421
+ /**
422
+ * Reset modal body
423
+ */
424
+ .modal__body {
425
+ @apply p-0 h-full;
426
+ }
427
+
428
+ /**
429
+ * Custom modal content
430
+ * in full size
431
+ */
432
+ .modal--full__content {
433
+ @apply flex flex-col justify-items-stretch h-full;
434
+ }
435
+
436
+ /**
437
+ * Custom modal header
438
+ * in full size
439
+ */
440
+ .modal--full__header {
441
+ @apply flex h-[60px] border-b border-b-default shrink-0;
442
+ @apply dark:border-b-dark-default;
443
+
444
+ &__dismiss {
445
+ @apply flex items-center border-r shrink-0 border-r-default bg-default;
446
+ @apply dark:border-r-dark-default dark:bg-dark-default;
447
+ }
448
+
449
+ &__title {
450
+ @apply flex grow items-stretch;
451
+
452
+ .modal__title {
453
+ @apply items-center flex;
454
+ }
455
+ }
456
+
457
+ &__content {
458
+ @apply grow flex items-stretch;
459
+ }
460
+
461
+ &__navigation {
462
+ @apply shrink-0 flex items-center border-l border-l-default px-3 space-x-1 bg-default;
463
+ @apply dark:border-l-dark-default dark:bg-dark-default;
464
+ }
465
+ }
466
+ }
467
+
468
+ /**
469
+ * Styling modal full
470
+ * with free distraction type
471
+ */
472
+ &:is(.modal--free-distraction) {
473
+ @apply bg-inverse/80;
474
+ @apply dark:bg-dark-inverse/80;
475
+
476
+ .modal__content {
477
+ @apply w-[var(--p-modal-size-full)];
478
+ }
479
+
480
+ .modal__dismiss {
481
+ @apply absolute right-5 top-5 p-[10px] rounded bg-default-alpha cursor-pointer;
482
+ @apply dark:bg-dark-default-alpha;
483
+ }
484
+
485
+ .modal__title {
486
+ @apply pr-0;
487
+ }
488
+ }
489
+ }
490
+
288
491
  /**
289
492
  * Modal vertically center
290
493
  * in the viewport
@@ -41,6 +41,30 @@ declare const _default: import("vue-demi").DefineComponent<{
41
41
  type: BooleanConstructor;
42
42
  default: boolean;
43
43
  };
44
+ freeDistraction: {
45
+ type: BooleanConstructor;
46
+ default: boolean;
47
+ };
48
+ headerClass: {
49
+ type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
50
+ default: undefined;
51
+ };
52
+ dialogClass: {
53
+ type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
54
+ default: undefined;
55
+ };
56
+ contentClass: {
57
+ type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
58
+ default: undefined;
59
+ };
60
+ bodyClass: {
61
+ type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
62
+ default: undefined;
63
+ };
64
+ footerClass: {
65
+ type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
66
+ default: undefined;
67
+ };
44
68
  }, {
45
69
  model: import("vue-demi").Ref<boolean>;
46
70
  classNames: import("vue-demi").ComputedRef<string[]>;
@@ -87,6 +111,30 @@ declare const _default: import("vue-demi").DefineComponent<{
87
111
  type: BooleanConstructor;
88
112
  default: boolean;
89
113
  };
114
+ freeDistraction: {
115
+ type: BooleanConstructor;
116
+ default: boolean;
117
+ };
118
+ headerClass: {
119
+ type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
120
+ default: undefined;
121
+ };
122
+ dialogClass: {
123
+ type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
124
+ default: undefined;
125
+ };
126
+ contentClass: {
127
+ type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
128
+ default: undefined;
129
+ };
130
+ bodyClass: {
131
+ type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
132
+ default: undefined;
133
+ };
134
+ footerClass: {
135
+ type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
136
+ default: undefined;
137
+ };
90
138
  }>> & {
91
139
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
92
140
  onClose?: ((...args: any[]) => any) | undefined;
@@ -97,9 +145,15 @@ declare const _default: import("vue-demi").DefineComponent<{
97
145
  text: string;
98
146
  title: string;
99
147
  centered: boolean;
148
+ noCloseOnBackdrop: boolean;
100
149
  modelValue: boolean;
150
+ bodyClass: string | Record<string, any> | unknown[];
101
151
  noCloseOnEsc: boolean;
102
- noCloseOnBackdrop: boolean;
103
152
  modalBodyScrollable: boolean;
153
+ freeDistraction: boolean;
154
+ headerClass: string | Record<string, any> | unknown[];
155
+ dialogClass: string | Record<string, any> | unknown[];
156
+ contentClass: string | Record<string, any> | unknown[];
157
+ footerClass: string | Record<string, any> | unknown[];
104
158
  }, {}>;
105
159
  export default _default;
@@ -1 +1 @@
1
- export type SizeVariant = 'sm' | 'md' | 'lg' | 'xl';
1
+ export type SizeVariant = 'sm' | 'md' | 'lg' | 'xl' | 'full';
@@ -115,6 +115,10 @@ export default defineComponent({
115
115
  @apply first:ml-2 mr-2 last:mr-0;
116
116
  }
117
117
 
118
+ &__item > &__link {
119
+ @apply no-underline transition-colors duration-150 ease-out;
120
+ }
121
+
118
122
  & > &__item {
119
123
  .nav__link {
120
124
  @apply text-subtle;
@@ -357,7 +361,7 @@ export default defineComponent({
357
361
  }
358
362
 
359
363
  &__link {
360
- @apply mb-0 -mr-[1px];
364
+ @apply mb-0;
361
365
  }
362
366
 
363
367
  &__title {
@@ -95,8 +95,8 @@ declare const _default: import("vue-demi").DefineComponent<{
95
95
  divider: boolean;
96
96
  text: string;
97
97
  modelValue: boolean;
98
- placement: Placement;
99
98
  noCaret: boolean;
99
+ placement: Placement;
100
100
  menuClass: string | Record<string, any> | unknown[];
101
101
  menuSize: MenuSizeVariant;
102
102
  }, {}>;
@@ -127,14 +127,10 @@ export default defineComponent({
127
127
  }
128
128
 
129
129
  .nav {
130
- @apply pt-0 ml-5 select-none;
130
+ @apply pt-3 select-none;
131
131
  }
132
132
 
133
133
  &&--icon {
134
- .nav {
135
- @apply ml-5;
136
- }
137
-
138
134
  .nav__link__icon {
139
135
  @apply grow-0;
140
136
 
@@ -144,7 +140,7 @@ export default defineComponent({
144
140
  }
145
141
 
146
142
  .nav__link__label {
147
- @apply shrink ml-3 w-full select-none;
143
+ @apply shrink pl-3 w-full select-none;
148
144
 
149
145
  .badge {
150
146
  @apply ml-auto;
@@ -176,6 +172,10 @@ export default defineComponent({
176
172
  @apply dark:text-dark-subtle hover:dark:text-dark-default;
177
173
  }
178
174
  }
175
+
176
+ .sidebar__nav .nav__link__label {
177
+ @apply pl-8;
178
+ }
179
179
  }
180
180
 
181
181
  &&--condensed {
@@ -48,8 +48,8 @@ declare const _default: import("vue-demi").DefineComponent<{
48
48
  default: boolean;
49
49
  };
50
50
  }>>, {
51
- fixed: boolean;
52
51
  variant: StyleVariant;
52
+ fixed: boolean;
53
53
  toggleable: ToggleableVariant | undefined;
54
54
  condensed: boolean;
55
55
  sticky: boolean;
@@ -20,7 +20,7 @@ export default defineComponent({
20
20
  </script>
21
21
 
22
22
  <style lang="postcss">
23
- .navbar {
23
+ a.navbar {
24
24
  &__brand {
25
25
  @apply inline-block mr-4 text-xl py-1 font-medium text-default no-underline cursor-pointer hover:no-underline;
26
26
  @apply dark:text-dark-default;
@@ -22,99 +22,115 @@
22
22
  </div>
23
23
  </template>
24
24
 
25
- <script>
26
- import { templateRef } from "@vueuse/core";
25
+ <script lang="ts" setup>
26
+ import '../pdf-object/PdfObject.vue'
27
+ import { templateRef } from '@vueuse/core'
27
28
  import {
28
29
  computed,
29
- defineComponent,
30
30
  ref,
31
31
  toRef,
32
32
  watch,
33
- watchEffect
34
- } from "vue-demi";
35
- import { getPosition } from "../pdf-object/utils/position";
36
- import useDrag from "./utils/use-drag";
37
- export default defineComponent({
38
- props: {
39
- scale: {
40
- type: Number,
41
- default: 1
42
- },
43
- width: {
44
- type: Number,
45
- default: 198
46
- },
47
- height: {
48
- type: Number,
49
- default: 106
50
- },
51
- disabled: {
52
- type: Boolean,
53
- default: false
33
+ watchEffect,
34
+ } from 'vue-demi'
35
+ import { getPosition } from '../pdf-object/utils/position'
36
+ import useDrag from './utils/use-drag'
37
+ import type { PdfHelipadResult } from '.'
38
+ import type { InteractEvent } from '@interactjs/types'
39
+
40
+ const props = defineProps({
41
+ scale: {
42
+ type : Number,
43
+ default: 1,
44
+ },
45
+ width: {
46
+ type : Number,
47
+ default: 198,
48
+ },
49
+ height: {
50
+ type : Number,
51
+ default: 106,
52
+ },
53
+ disabled: {
54
+ type : Boolean,
55
+ default: false,
56
+ },
57
+ })
58
+
59
+ const emit = defineEmits<{
60
+ 'landed': [PdfHelipadResult],
61
+ 'click': [InteractEvent],
62
+ }>()
63
+
64
+ const object = templateRef<HTMLDivElement>('object')
65
+ const scale = toRef(props, 'scale')
66
+ const width = toRef(props, 'width')
67
+ const height = toRef(props, 'height')
68
+
69
+ const isDragged = ref(false)
70
+ const x = ref(0)
71
+ const y = ref(0)
72
+
73
+ const classNames = computed(() => {
74
+ const result: string[] = []
75
+
76
+ if (props.disabled)
77
+ result.push('pdf-helipad--disabled')
78
+
79
+ return result
80
+ })
81
+
82
+ const draggable = useDrag(object, {
83
+ onstart () {
84
+ const { left, top } = object.value.getBoundingClientRect()
85
+
86
+ isDragged.value = true
87
+ x.value = left
88
+ y.value = top
89
+ },
90
+ onmove (event) {
91
+ x.value = event.clientX - (event.rect.width * scale.value / 2)
92
+ y.value = event.clientY - (event.rect.height * scale.value / 2)
93
+ },
94
+ onend (event) {
95
+ if (event.relatedTarget) {
96
+ const reference = event.relatedTarget
97
+ const result = getPosition({
98
+ reference: reference as HTMLDivElement,
99
+ object : object.value,
100
+ scale : scale.value,
101
+ })
102
+
103
+ emit('landed', {
104
+ ...result,
105
+ width : width.value,
106
+ height: height.value,
107
+ })
54
108
  }
109
+
110
+ isDragged.value = false
111
+ },
112
+ ontap (event) {
113
+ emit('click', event)
55
114
  },
56
- emits: ["landed"],
57
- setup(props, { emit }) {
58
- const object = templateRef("object");
59
- const scale = toRef(props, "scale");
60
- const width = toRef(props, "width");
61
- const height = toRef(props, "height");
62
- const isDragged = ref(false);
63
- const x = ref(0);
64
- const y = ref(0);
65
- const classNames = computed(() => {
66
- const result = [];
67
- if (props.disabled)
68
- result.push("pdf-helipad--disabled");
69
- return result;
70
- });
71
- const draggable = useDrag(object, {
72
- onstart() {
73
- const { left, top } = object.value.getBoundingClientRect();
74
- isDragged.value = true;
75
- x.value = left;
76
- y.value = top;
77
- },
78
- onmove(event) {
79
- x.value = event.clientX - event.rect.width * scale.value / 2;
80
- y.value = event.clientY - event.rect.height * scale.value / 2;
81
- },
82
- onend(event) {
83
- if (event.relatedTarget) {
84
- const reference = event.relatedTarget;
85
- const result = getPosition({
86
- reference,
87
- object: object.value,
88
- scale: scale.value
89
- });
90
- emit("landed", {
91
- ...result,
92
- width: width.value,
93
- height: height.value
94
- });
95
- }
96
- isDragged.value = false;
97
- }
98
- });
99
- watchEffect(() => {
100
- if (object.value) {
101
- if (isDragged.value) {
102
- object.value.style.position = "fixed";
103
- object.value.style.transform = `translate(${x.value}px, ${y.value}px) scale(${scale.value})`;
104
- object.value.style.zIndex = "50";
105
- } else {
106
- object.value.style.position = "absolute";
107
- object.value.style.transform = "translate(0px, 0px)";
108
- object.value.style.zIndex = "2";
109
- }
110
- }
111
- });
112
- watch(() => props.disabled, (isDisabled) => {
113
- draggable.value = !isDisabled;
114
- }, { immediate: true });
115
- return { classNames };
115
+ })
116
+
117
+ watchEffect(() => {
118
+ if (object.value) {
119
+ if (isDragged.value) {
120
+ object.value.style.position = 'fixed'
121
+ object.value.style.transform = `translate(${x.value}px, ${y.value}px) scale(${scale.value})`
122
+ object.value.style.zIndex = '50'
123
+ } else {
124
+ object.value.style.position = 'absolute'
125
+ object.value.style.transform = 'translate(0px, 0px)'
126
+ object.value.style.zIndex = '2'
127
+ }
116
128
  }
117
- });
129
+ })
130
+
131
+ watch(() => props.disabled, (isDisabled) => {
132
+ draggable.value = !isDisabled
133
+ }, { immediate: true })
118
134
  </script>
119
135
 
120
136
  <style lang="postcss">
@@ -1,8 +1,3 @@
1
- import type { InteractEvent } from '@interactjs/types';
2
1
  import { Ref } from 'vue-demi';
3
- export interface DragOptions {
4
- onstart?: (event: InteractEvent) => void;
5
- onmove?: (event: InteractEvent) => void;
6
- onend?: (event: InteractEvent) => void;
7
- }
8
- export default function useDrag(target: Ref<HTMLElement>, options?: DragOptions): import("vue-demi").ShallowRef<boolean>;
2
+ import { DragHooks } from '../../pdf-object/utils/use-drag';
3
+ export default function useDrag(target: Ref<HTMLElement>, options?: DragHooks): import("vue-demi").ShallowRef<boolean>;