@radio-garden/ditojs-admin 2.85.2-0.5067ad799

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 (153) hide show
  1. package/README.md +180 -0
  2. package/dist/dito-admin.css +1 -0
  3. package/dist/dito-admin.es.js +12106 -0
  4. package/dist/dito-admin.umd.js +7 -0
  5. package/package.json +96 -0
  6. package/src/DitoAdmin.js +293 -0
  7. package/src/DitoComponent.js +34 -0
  8. package/src/DitoContext.js +318 -0
  9. package/src/DitoTypeComponent.js +42 -0
  10. package/src/DitoUser.js +12 -0
  11. package/src/appState.js +12 -0
  12. package/src/components/DitoAccount.vue +60 -0
  13. package/src/components/DitoAffix.vue +68 -0
  14. package/src/components/DitoAffixes.vue +200 -0
  15. package/src/components/DitoButtons.vue +80 -0
  16. package/src/components/DitoClipboard.vue +186 -0
  17. package/src/components/DitoContainer.vue +374 -0
  18. package/src/components/DitoCreateButton.vue +146 -0
  19. package/src/components/DitoDialog.vue +242 -0
  20. package/src/components/DitoDraggable.vue +117 -0
  21. package/src/components/DitoEditButtons.vue +135 -0
  22. package/src/components/DitoErrors.vue +83 -0
  23. package/src/components/DitoForm.vue +521 -0
  24. package/src/components/DitoFormInner.vue +26 -0
  25. package/src/components/DitoFormNested.vue +17 -0
  26. package/src/components/DitoHeader.vue +84 -0
  27. package/src/components/DitoLabel.vue +200 -0
  28. package/src/components/DitoMenu.vue +186 -0
  29. package/src/components/DitoNavigation.vue +40 -0
  30. package/src/components/DitoNotifications.vue +170 -0
  31. package/src/components/DitoPagination.vue +42 -0
  32. package/src/components/DitoPane.vue +334 -0
  33. package/src/components/DitoPanel.vue +256 -0
  34. package/src/components/DitoPanels.vue +61 -0
  35. package/src/components/DitoRoot.vue +524 -0
  36. package/src/components/DitoSchema.vue +846 -0
  37. package/src/components/DitoSchemaInlined.vue +97 -0
  38. package/src/components/DitoScopes.vue +76 -0
  39. package/src/components/DitoSidebar.vue +50 -0
  40. package/src/components/DitoSpinner.vue +95 -0
  41. package/src/components/DitoTableCell.vue +64 -0
  42. package/src/components/DitoTableHead.vue +121 -0
  43. package/src/components/DitoTabs.vue +103 -0
  44. package/src/components/DitoTrail.vue +124 -0
  45. package/src/components/DitoTreeItem.vue +420 -0
  46. package/src/components/DitoUploadFile.vue +199 -0
  47. package/src/components/DitoVNode.vue +14 -0
  48. package/src/components/DitoView.vue +143 -0
  49. package/src/components/index.js +42 -0
  50. package/src/directives/resize.js +83 -0
  51. package/src/index.js +1 -0
  52. package/src/mixins/ContextMixin.js +68 -0
  53. package/src/mixins/DataMixin.js +131 -0
  54. package/src/mixins/DitoMixin.js +591 -0
  55. package/src/mixins/DomMixin.js +29 -0
  56. package/src/mixins/EmitterMixin.js +158 -0
  57. package/src/mixins/ItemMixin.js +144 -0
  58. package/src/mixins/LoadingMixin.js +23 -0
  59. package/src/mixins/NumberMixin.js +118 -0
  60. package/src/mixins/OptionsMixin.js +304 -0
  61. package/src/mixins/PulldownMixin.js +63 -0
  62. package/src/mixins/ResourceMixin.js +398 -0
  63. package/src/mixins/RouteMixin.js +190 -0
  64. package/src/mixins/SchemaParentMixin.js +33 -0
  65. package/src/mixins/SortableMixin.js +49 -0
  66. package/src/mixins/SourceMixin.js +734 -0
  67. package/src/mixins/TextMixin.js +26 -0
  68. package/src/mixins/TypeMixin.js +280 -0
  69. package/src/mixins/ValidationMixin.js +119 -0
  70. package/src/mixins/ValidatorMixin.js +57 -0
  71. package/src/mixins/ValueMixin.js +31 -0
  72. package/src/styles/_base.scss +17 -0
  73. package/src/styles/_button.scss +191 -0
  74. package/src/styles/_imports.scss +3 -0
  75. package/src/styles/_info.scss +19 -0
  76. package/src/styles/_layout.scss +19 -0
  77. package/src/styles/_pulldown.scss +38 -0
  78. package/src/styles/_scroll.scss +13 -0
  79. package/src/styles/_settings.scss +88 -0
  80. package/src/styles/_table.scss +223 -0
  81. package/src/styles/_tippy.scss +45 -0
  82. package/src/styles/style.scss +9 -0
  83. package/src/types/DitoTypeButton.vue +143 -0
  84. package/src/types/DitoTypeCheckbox.vue +27 -0
  85. package/src/types/DitoTypeCheckboxes.vue +65 -0
  86. package/src/types/DitoTypeCode.vue +199 -0
  87. package/src/types/DitoTypeColor.vue +272 -0
  88. package/src/types/DitoTypeComponent.vue +31 -0
  89. package/src/types/DitoTypeComputed.vue +50 -0
  90. package/src/types/DitoTypeDate.vue +99 -0
  91. package/src/types/DitoTypeLabel.vue +23 -0
  92. package/src/types/DitoTypeList.vue +364 -0
  93. package/src/types/DitoTypeMarkup.vue +700 -0
  94. package/src/types/DitoTypeMultiselect.vue +522 -0
  95. package/src/types/DitoTypeNumber.vue +66 -0
  96. package/src/types/DitoTypeObject.vue +136 -0
  97. package/src/types/DitoTypePanel.vue +18 -0
  98. package/src/types/DitoTypeProgress.vue +40 -0
  99. package/src/types/DitoTypeRadio.vue +45 -0
  100. package/src/types/DitoTypeSection.vue +80 -0
  101. package/src/types/DitoTypeSelect.vue +133 -0
  102. package/src/types/DitoTypeSlider.vue +66 -0
  103. package/src/types/DitoTypeSpacer.vue +11 -0
  104. package/src/types/DitoTypeSwitch.vue +40 -0
  105. package/src/types/DitoTypeText.vue +101 -0
  106. package/src/types/DitoTypeTextarea.vue +48 -0
  107. package/src/types/DitoTypeTreeList.vue +193 -0
  108. package/src/types/DitoTypeUpload.vue +503 -0
  109. package/src/types/index.js +30 -0
  110. package/src/utils/SchemaGraph.js +147 -0
  111. package/src/utils/accessor.js +75 -0
  112. package/src/utils/agent.js +47 -0
  113. package/src/utils/data.js +92 -0
  114. package/src/utils/filter.js +266 -0
  115. package/src/utils/math.js +14 -0
  116. package/src/utils/options.js +48 -0
  117. package/src/utils/path.js +5 -0
  118. package/src/utils/resource.js +44 -0
  119. package/src/utils/route.js +53 -0
  120. package/src/utils/schema.js +1121 -0
  121. package/src/utils/type.js +81 -0
  122. package/src/utils/uid.js +15 -0
  123. package/src/utils/units.js +5 -0
  124. package/src/validators/_creditcard.js +6 -0
  125. package/src/validators/_decimals.js +11 -0
  126. package/src/validators/_domain.js +6 -0
  127. package/src/validators/_email.js +6 -0
  128. package/src/validators/_hostname.js +6 -0
  129. package/src/validators/_integer.js +6 -0
  130. package/src/validators/_max.js +6 -0
  131. package/src/validators/_min.js +6 -0
  132. package/src/validators/_password.js +5 -0
  133. package/src/validators/_range.js +6 -0
  134. package/src/validators/_required.js +9 -0
  135. package/src/validators/_url.js +6 -0
  136. package/src/validators/index.js +12 -0
  137. package/src/verbs.js +17 -0
  138. package/types/index.d.ts +3298 -0
  139. package/types/tests/admin.test-d.ts +27 -0
  140. package/types/tests/component-buttons.test-d.ts +44 -0
  141. package/types/tests/component-list.test-d.ts +159 -0
  142. package/types/tests/component-misc.test-d.ts +137 -0
  143. package/types/tests/component-object.test-d.ts +69 -0
  144. package/types/tests/component-section.test-d.ts +174 -0
  145. package/types/tests/component-select.test-d.ts +107 -0
  146. package/types/tests/components.test-d.ts +81 -0
  147. package/types/tests/context.test-d.ts +31 -0
  148. package/types/tests/fixtures.ts +24 -0
  149. package/types/tests/form.test-d.ts +109 -0
  150. package/types/tests/instance.test-d.ts +20 -0
  151. package/types/tests/schema-features.test-d.ts +402 -0
  152. package/types/tests/variance.test-d.ts +125 -0
  153. package/types/tests/view.test-d.ts +146 -0
@@ -0,0 +1,3 @@
1
+ // stylelint-disable scss/load-partial-extension
2
+ @import '@ditojs/ui/imports.scss';
3
+ @import '_settings';
@@ -0,0 +1,19 @@
1
+ .dito-info {
2
+ --size: calc(1em * var(--line-height));
3
+
4
+ display: inline-block;
5
+ position: relative;
6
+ flex: 0 0 var(--size);
7
+ width: var(--size);
8
+ height: var(--size);
9
+ text-align: center;
10
+ vertical-align: top;
11
+ margin-left: 0.35em;
12
+ color: $color-active;
13
+
14
+ &::before {
15
+ @extend %icon-info;
16
+
17
+ width: var(--size);
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ .dito-layout {
2
+ &--vertical,
3
+ &--horizontal {
4
+ display: flex;
5
+
6
+ > * {
7
+ flex: 0 0 auto;
8
+ display: flex;
9
+ }
10
+ }
11
+
12
+ &--horizontal {
13
+ gap: $form-spacing;
14
+ }
15
+
16
+ &--vertical {
17
+ flex-direction: column;
18
+ }
19
+ }
@@ -0,0 +1,38 @@
1
+ @import '../styles/_imports';
2
+
3
+ .dito-pulldown {
4
+ $self: &;
5
+
6
+ display: none;
7
+ position: absolute;
8
+ top: 0;
9
+ z-index: $z-index-popup;
10
+ border-radius: $pulldown-radius;
11
+ box-shadow: $shadow-window;
12
+ overflow: hidden;
13
+
14
+ &--open {
15
+ display: block;
16
+ }
17
+
18
+ li {
19
+ @include user-select(none);
20
+ }
21
+
22
+ &__item {
23
+ display: block;
24
+ padding: $pulldown-padding;
25
+ line-height: 1;
26
+ background: $button-color;
27
+
28
+ &--disabled {
29
+ color: $color-disabled;
30
+ cursor: default;
31
+ }
32
+
33
+ &:not(&--disabled):hover {
34
+ background: $color-active;
35
+ color: $color-white;
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,13 @@
1
+ .dito-scroll {
2
+ flex: 1;
3
+ max-height: 100%;
4
+ overflow: auto;
5
+ }
6
+
7
+ .dito-scroll-parent {
8
+ // To make vertical scrolling in .dito-scroll work:
9
+ flex: 1;
10
+ display: flex;
11
+ flex-flow: column;
12
+ overflow: hidden;
13
+ }
@@ -0,0 +1,88 @@
1
+ // Typography
2
+ $font-family-sans:
3
+ -apple-system, 'BlinkMacSystemFont', 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
4
+ 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 'Helvetica',
5
+ 'Arial', sans-serif;
6
+ $font-family-mono:
7
+ 'Menlo', 'Consolas', 'Monaco', 'Vera Mono', 'Andale Mono', 'Ubuntu Mono',
8
+ monospace;
9
+ $font-size: 13px;
10
+ $font-size-small: 11px;
11
+ // Adjust line-height so that it fulfils this equation, which is used
12
+ // to reach equal height for icon-buttons (`height: 2em`), table headers & co.:
13
+ // `(2 * $font-size - 2 * ($border-width + $input-padding-ver)) / $font-size`
14
+ // TODO: Ideally, this would be handled in @ditojs/ui, but it would have to be
15
+ // done in a way independent of `$font-size`. The right approach would probably
16
+ // be to use `$input-height` and vertical centering instead for all inputs that
17
+ // have a height of one line?
18
+ // NOTE: Due to higher precision in dart-sass, this needs to be rounded to 5
19
+ // fractional digits, otherwise CSS creates the wrong resulting line-height with
20
+ // 1 missing pixel.
21
+ $line-height: rounded(
22
+ calc(
23
+ $input-height-factor - 2 * ($border-width + $input-padding-ver) / $font-size
24
+ ),
25
+ 5
26
+ );
27
+
28
+ // Button
29
+ $button-order-arrow-size: 4px;
30
+
31
+ // Pulldown
32
+ $pulldown-radius: 0.5em;
33
+ $pulldown-padding-ver: 0.5em;
34
+ $pulldown-padding-hor: 1em;
35
+ $pulldown-padding: $pulldown-padding-ver $pulldown-padding-hor;
36
+
37
+ // Content
38
+ $content-width: 900px;
39
+ $content-width-wide: 1400px;
40
+ $content-padding: 16px;
41
+ $content-padding-half: calc($content-padding / 2);
42
+ $content-color-background: $color-lightest;
43
+
44
+ // Sidebar
45
+ $sidebar-max-width: 360px;
46
+ $sidebar-min-width: 200px;
47
+
48
+ // Form
49
+ $form-spacing: $input-padding-hor;
50
+ $form-spacing-half: calc($form-spacing / 2);
51
+
52
+ // Header
53
+ $header-font-size: 14px;
54
+ $header-line-height: 1;
55
+ $header-padding-ver: $header-font-size;
56
+ $header-padding-hor: $content-padding;
57
+ $header-padding: $header-padding-ver $header-padding-hor;
58
+ $header-height: $header-font-size + 2 * $header-padding-ver;
59
+
60
+ // Tabs
61
+ $tab-margin: $form-spacing;
62
+ $tab-padding-hor: 2 * $tab-margin;
63
+ $tab-padding-ver: calc(($header-padding-ver * 2 - $tab-margin) / 2);
64
+ $tab-radius: 4px;
65
+
66
+ // Menu
67
+ $menu-font-size: $header-font-size;
68
+ $menu-line-height: $header-line-height;
69
+ $menu-spacing: 4px;
70
+ $menu-padding-ver: $header-padding-ver - $menu-spacing;
71
+ $menu-padding-hor: $header-padding-hor - $menu-spacing;
72
+ $menu-padding: $menu-padding-ver $menu-padding-hor;
73
+
74
+ // Z-Indices
75
+ $z-index-dialog: 4000;
76
+ $z-index-drag-overlay: 3000;
77
+ $z-index-notifications: 2500;
78
+ $z-index-header: 2000;
79
+ $z-index-tippy: 750;
80
+ $z-index-main-buttons: 500;
81
+
82
+ // Patterns
83
+ $pattern-transparency-size: ($font-size - $border-width) * $input-height-factor;
84
+ $pattern-transparency: repeating-conic-gradient(
85
+ transparent 0% 25%,
86
+ #eeeeee 0% 50%
87
+ )
88
+ 0% 0% / #{$pattern-transparency-size} #{$pattern-transparency-size};
@@ -0,0 +1,223 @@
1
+ @mixin table-border {
2
+ // Note: No border-width set here on purpose!
3
+ border-style: solid;
4
+ border-color: $border-color;
5
+ }
6
+
7
+ @mixin table-border-left {
8
+ border-left-width: $border-width;
9
+ }
10
+
11
+ @mixin table-border-right {
12
+ border-right-width: $border-width;
13
+ }
14
+
15
+ @mixin table-border-top {
16
+ border-top-width: $border-width;
17
+ }
18
+
19
+ @mixin table-border-bottom {
20
+ border-bottom-width: $border-width;
21
+ }
22
+
23
+ @mixin table-border-top-left {
24
+ @include table-border-top;
25
+ @include table-border-left;
26
+
27
+ border-top-left-radius: $border-radius;
28
+ }
29
+
30
+ @mixin table-border-top-right {
31
+ @include table-border-top;
32
+ @include table-border-right;
33
+
34
+ border-top-right-radius: $border-radius;
35
+ }
36
+
37
+ @mixin table-border-bottom-left {
38
+ @include table-border-bottom;
39
+ @include table-border-left;
40
+
41
+ border-bottom-left-radius: $border-radius;
42
+ }
43
+
44
+ @mixin table-border-bottom-right {
45
+ @include table-border-bottom;
46
+ @include table-border-right;
47
+
48
+ border-bottom-right-radius: $border-radius;
49
+ }
50
+
51
+ .dito-table {
52
+ $self: &;
53
+
54
+ --separator-width: #{$border-width};
55
+
56
+ width: 100%;
57
+ height: min-content;
58
+ border-radius: $border-radius;
59
+
60
+ > tbody,
61
+ > tfoot {
62
+ > tr {
63
+ vertical-align: baseline;
64
+
65
+ > td {
66
+ padding: $form-spacing 0 $form-spacing $form-spacing;
67
+ background: $content-color-background;
68
+
69
+ &:last-child {
70
+ padding-right: $form-spacing;
71
+ }
72
+ }
73
+ }
74
+ }
75
+
76
+ &__buttons {
77
+ width: 1%;
78
+
79
+ &,
80
+ .dito-button {
81
+ // To align better with `vertical-align: baseline` in normal td:
82
+ vertical-align: top;
83
+ }
84
+ }
85
+
86
+ &--larger-padding {
87
+ // Add more spacing to cells in tables except those containing edit buttons,
88
+ // to better align cell texts with edit buttons.
89
+ td:not(#{$self}__buttons) {
90
+ $padding: $form-spacing * 1.5;
91
+
92
+ padding: $padding 0 $padding $padding;
93
+ }
94
+ // Variants of list styles: separators and alternate colors.
95
+ }
96
+
97
+ &--separators {
98
+ > tbody > tr + tr,
99
+ > tbody:not(:empty) + tfoot > tr {
100
+ > td {
101
+ border-top: var(--separator-width) solid $border-color;
102
+ }
103
+ }
104
+ }
105
+
106
+ &--alternate-colors {
107
+ > tbody > tr:nth-child(odd),
108
+ &#{$self}--even-count > tfoot > tr {
109
+ > td {
110
+ background: $color-white;
111
+ }
112
+ }
113
+ }
114
+
115
+ &--background {
116
+ > tbody,
117
+ > tfoot {
118
+ > tr > td {
119
+ background: $color-white;
120
+ }
121
+ // Add top/top-left/top-right borders to the thead cells, using the special
122
+ // convention that they're added to the first element inside them instead of
123
+ // the cell itself, so buttons can keep the border themselves and display
124
+ // focus nicely.
125
+ }
126
+ }
127
+
128
+ > thead > tr > th {
129
+ // Use `:not(:focus)` to avoid overriding button focus border styling.
130
+ > * {
131
+ box-sizing: content-box;
132
+
133
+ &:not(:focus) {
134
+ @include table-border;
135
+ }
136
+
137
+ @include table-border-top;
138
+ @include table-border-bottom;
139
+ @include table-border-left;
140
+ @include table-border-right;
141
+ }
142
+
143
+ &:first-child > * {
144
+ @include table-border-top-left;
145
+ }
146
+
147
+ &:last-child > * {
148
+ @include table-border-top-right;
149
+ }
150
+
151
+ & + th > * {
152
+ margin-left: -1px;
153
+ // Don't cover the focused border of buttons:
154
+ &:focus {
155
+ z-index: 1;
156
+ }
157
+ // Add left/right borders to the normal tbody cells.
158
+ }
159
+ }
160
+
161
+ > tbody > tr > td {
162
+ border: 0;
163
+ @include table-border;
164
+
165
+ &:first-child {
166
+ @include table-border-left;
167
+ }
168
+
169
+ &:last-child {
170
+ @include table-border-right;
171
+ }
172
+ // If there is no thead, add top/top-left/top-right borders borders to the
173
+ // first row of the tbody cells.
174
+ }
175
+
176
+ > tbody:first-child > tr:first-child > td,
177
+ /* Use :first-child to exclude situation where there's a thead and empty tbody*/
178
+ > tbody:first-child:empty + tfoot > tr > td {
179
+ @include table-border-top;
180
+
181
+ &:first-child {
182
+ @include table-border-top-left;
183
+ }
184
+
185
+ &:last-child {
186
+ @include table-border-top-right;
187
+ }
188
+ // If there is no toot, add top/top-left/top-right borders borders to the
189
+ // first row of the tbody cells.
190
+ }
191
+
192
+ > tbody:last-child > tr:last-child > td {
193
+ @include table-border-bottom;
194
+
195
+ &:first-child {
196
+ @include table-border-bottom-left;
197
+ }
198
+
199
+ &:last-child {
200
+ @include table-border-bottom-right;
201
+ }
202
+ // Add bottom/bottom-left/bottom-right borders to the thead cells.
203
+ }
204
+
205
+ > tfoot > tr > td {
206
+ border-width: 0;
207
+ @include table-border;
208
+ @include table-border-bottom;
209
+
210
+ &:first-child {
211
+ @include table-border-bottom-left;
212
+ }
213
+
214
+ &:last-child {
215
+ @include table-border-bottom-right;
216
+ }
217
+ }
218
+
219
+ #{$self} & {
220
+ // Nested .dito-table
221
+ margin: 0;
222
+ }
223
+ }
@@ -0,0 +1,45 @@
1
+ @use 'sass:color';
2
+ @import 'tippy.js/dist/tippy.css';
3
+ @import 'tippy.js/animations/shift-away-subtle.css';
4
+
5
+ .tippy-box {
6
+ .tippy-content,
7
+ .tippy-arrow {
8
+ z-index: $z-index-tippy;
9
+ }
10
+
11
+ &[data-theme] {
12
+ --color: #{$color-active};
13
+
14
+ font-size: unset;
15
+ line-height: unset;
16
+ background-color: var(--color);
17
+ color: $color-white;
18
+ filter: drop-shadow(0 2px 4px $color-shadow);
19
+
20
+ .tippy-content {
21
+ white-space: pre-line;
22
+ padding: ($input-padding-ver + 2 * $border-width)
23
+ ($input-padding-hor + $border-width);
24
+ }
25
+
26
+ > .tippy-arrow::before {
27
+ color: var(--color);
28
+ }
29
+ }
30
+
31
+ &[data-theme~='info'] {
32
+ --color: #{color.adjust($color-active, $lightness: 5%)};
33
+ }
34
+
35
+ &[data-theme~='error'] {
36
+ --color: #{color.adjust($color-error, $lightness: 5%)};
37
+
38
+ cursor: pointer;
39
+
40
+ > .tippy-arrow {
41
+ transform: unset !important;
42
+ left: 16px !important;
43
+ }
44
+ }
45
+ }
@@ -0,0 +1,9 @@
1
+ @import '_imports';
2
+ @import '_base';
3
+ @import '_button';
4
+ @import '_pulldown';
5
+ @import '_layout';
6
+ @import '_scroll';
7
+ @import '_table';
8
+ @import '_info';
9
+ @import '_tippy';
@@ -0,0 +1,143 @@
1
+ <template lang="pug">
2
+ DitoButton.dito-button(
3
+ :id="dataPath"
4
+ ref="element"
5
+ :type="type"
6
+ :text="text"
7
+ :title="title"
8
+ :disabled="disabled"
9
+ :class="buttonClass"
10
+ v-bind="attributes"
11
+ )
12
+ template(#prefix)
13
+ DitoAffixes(
14
+ v-if="prefixes.length > 0"
15
+ :items="prefixes"
16
+ position="prefix"
17
+ :disabled="disabled"
18
+ :parentContext="context"
19
+ )
20
+ template(#suffix)
21
+ DitoAffixes(
22
+ v-if="suffixes.length > 0"
23
+ :items="suffixes"
24
+ position="suffix"
25
+ :disabled="disabled"
26
+ :parentContext="context"
27
+ )
28
+ .dito-info(
29
+ v-if="!label && info"
30
+ :data-info="info"
31
+ )
32
+ </template>
33
+
34
+ <script>
35
+ import DitoTypeComponent from '../DitoTypeComponent.js'
36
+ import DitoAffixes from '../components/DitoAffixes.vue'
37
+ import { DitoButton } from '@ditojs/ui/src'
38
+ import { getSchemaAccessor } from '../utils/accessor.js'
39
+ import { hasResource } from '../utils/resource.js'
40
+ import { labelize, asArray } from '@ditojs/utils'
41
+
42
+ export default DitoTypeComponent.register(
43
+ ['button', 'submit'],
44
+ // @vue/component
45
+ {
46
+ components: { DitoAffixes, DitoButton },
47
+ defaultValue: () => undefined, // Callback to override `defaultValue: null`
48
+ excludeValue: true,
49
+ defaultWidth: 'auto',
50
+ generateLabel: false,
51
+
52
+ data() {
53
+ return {
54
+ isRunning: false
55
+ }
56
+ },
57
+
58
+ computed: {
59
+ verb() {
60
+ return this.verbs[this.name]
61
+ },
62
+
63
+ buttonClass() {
64
+ return this.verb ? `dito-button--${this.verb}` : null
65
+ },
66
+
67
+ text: getSchemaAccessor('text', {
68
+ type: String
69
+ }),
70
+
71
+ title() {
72
+ return this.text || labelize(this.verb)
73
+ },
74
+
75
+ prefixes() {
76
+ return asArray(this.schema.prefix)
77
+ },
78
+
79
+ suffixes() {
80
+ return asArray(this.schema.suffix)
81
+ },
82
+
83
+ closeForm: getSchemaAccessor('closeForm', {
84
+ type: Boolean,
85
+ default: false
86
+ })
87
+ },
88
+
89
+ methods: {
90
+ // @override
91
+ getEvents() {
92
+ const { onFocus, onBlur, onClick } = this
93
+ return { onFocus, onBlur, onClick }
94
+ },
95
+
96
+ async submit(options) {
97
+ return this.resourceComponent?.submit(this, options)
98
+ },
99
+
100
+ async onClick() {
101
+ this.isRunning = true
102
+ try {
103
+ const res = await this.emitEvent('click', {
104
+ parent: this.schemaComponent
105
+ })
106
+ // Have buttons that define resources call `this.submit()` by default:
107
+ if (
108
+ res === undefined && // Meaning: don't prevent default.
109
+ hasResource(this.schema)
110
+ ) {
111
+ await this.submit()
112
+ }
113
+ } catch (error) {
114
+ const res = await this.emitEvent('error', { error })
115
+ if (res === undefined) {
116
+ if (error instanceof AggregateError) {
117
+ for (const err of error.errors) {
118
+ this.notify({ type: 'error', text: err })
119
+ }
120
+ } else {
121
+ this.notify({ type: 'error', text: error })
122
+ }
123
+ }
124
+ } finally {
125
+ this.isRunning = false
126
+ }
127
+ }
128
+ }
129
+ }
130
+ )
131
+ </script>
132
+
133
+ <style lang="scss">
134
+ @import '../styles/_imports';
135
+
136
+ .dito-button {
137
+ $self: &;
138
+
139
+ &__text {
140
+ @include ellipsis;
141
+ }
142
+ }
143
+ </style>
@@ -0,0 +1,27 @@
1
+ <template lang="pug">
2
+ .dito-checkbox
3
+ input(
4
+ :id="dataPath"
5
+ ref="element"
6
+ v-model="value"
7
+ type="checkbox"
8
+ v-bind="attributes"
9
+ )
10
+ </template>
11
+
12
+ <script>
13
+ import DitoTypeComponent from '../DitoTypeComponent.js'
14
+
15
+ // @vue/component
16
+ export default DitoTypeComponent.register('checkbox', {
17
+ nativeField: true
18
+ })
19
+ </script>
20
+
21
+ <style lang="scss">
22
+ @import '../styles/_imports';
23
+
24
+ .dito-checkbox {
25
+ @extend %input-borderless;
26
+ }
27
+ </style>
@@ -0,0 +1,65 @@
1
+ <template lang="pug">
2
+ ul.dito-checkboxes(
3
+ :id="dataPath"
4
+ :class="`dito-layout--${schema.layout || 'vertical'}`"
5
+ )
6
+ li(
7
+ v-for="option in options"
8
+ )
9
+ label
10
+ .dito-checkbox
11
+ input(
12
+ ref="element"
13
+ v-model="selectedOptions"
14
+ type="checkbox"
15
+ :value="getValueForOption(option)"
16
+ v-bind="attributes"
17
+ )
18
+ span {{ getLabelForOption(option) }}
19
+ </template>
20
+
21
+ <script>
22
+ import DitoTypeComponent from '../DitoTypeComponent.js'
23
+ import OptionsMixin from '../mixins/OptionsMixin.js'
24
+
25
+ // @vue/component
26
+ export default DitoTypeComponent.register('checkboxes', {
27
+ mixins: [OptionsMixin],
28
+
29
+ nativeField: true,
30
+ defaultValue: [],
31
+ defaultWidth: 'auto',
32
+ defaultMultiple: true,
33
+
34
+ computed: {
35
+ // @override
36
+ multiple() {
37
+ return true
38
+ },
39
+
40
+ selectedOptions: {
41
+ get() {
42
+ return (this.selectedValue || []).filter(value => value)
43
+ },
44
+
45
+ set(option) {
46
+ this.selectedValue = option || []
47
+ }
48
+ }
49
+ }
50
+ })
51
+ </script>
52
+
53
+ <style lang="scss">
54
+ @import '../styles/_imports';
55
+
56
+ .dito-checkboxes {
57
+ label {
58
+ @extend %input-borderless;
59
+ }
60
+
61
+ input {
62
+ margin-right: $form-spacing;
63
+ }
64
+ }
65
+ </style>