@ditojs/ui 2.72.0 → 2.73.1

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": "@ditojs/ui",
3
- "version": "2.72.0",
3
+ "version": "2.73.1",
4
4
  "type": "module",
5
5
  "description": "Dito.js UI is a simple UI library, built with Vue.js for use in Dito.js Admin and elsewhere",
6
6
  "repository": "https://github.com/ditojs/dito/tree/master/packages/ui",
@@ -41,12 +41,12 @@
41
41
  "ie_mob >= 11"
42
42
  ],
43
43
  "dependencies": {
44
- "@ditojs/utils": "^2.72.0",
44
+ "@ditojs/utils": "^2.73.0",
45
45
  "@soda/get-current-script": "^1.0.2"
46
46
  },
47
47
  "devDependencies": {
48
- "@ditojs/build": "^2.72.0",
48
+ "@ditojs/build": "^2.73.0",
49
49
  "vite": "^7.3.1"
50
50
  },
51
- "gitHead": "6af5f5bad3ff155436e4344d9c422933ff5ee7d8"
51
+ "gitHead": "f40a5de8cb0b711af68838e386a182e3d94ee106"
52
52
  }
@@ -0,0 +1,54 @@
1
+ <template lang="pug">
2
+ button.dito-button(
3
+ :type="type"
4
+ :title="title"
5
+ :disabled="disabled"
6
+ :class="[classes, { 'dito-button--affixed': hasAffixes }]"
7
+ v-bind="attributes"
8
+ )
9
+ .dito-button__prefix(
10
+ v-if="hasAffixes"
11
+ )
12
+ slot(name="prefix")
13
+ .dito-button__text(
14
+ v-if="text || hasAffixes"
15
+ ) {{ text || '' }}
16
+ slot
17
+ .dito-button__suffix(
18
+ v-if="hasAffixes"
19
+ )
20
+ slot(name="suffix")
21
+ </template>
22
+
23
+ <script>
24
+ import { hasSlotContent } from '../utils/vue.js'
25
+
26
+ export default {
27
+ inheritAttrs: false,
28
+
29
+ props: {
30
+ type: { type: String, default: 'button' },
31
+ text: { type: String, default: null },
32
+ title: { type: String, default: null },
33
+ disabled: { type: Boolean, default: false }
34
+ },
35
+
36
+ computed: {
37
+ hasAffixes() {
38
+ return (
39
+ hasSlotContent(this.$slots.prefix) ||
40
+ hasSlotContent(this.$slots.suffix)
41
+ )
42
+ },
43
+
44
+ classes() {
45
+ return this.$attrs.class
46
+ },
47
+
48
+ attributes() {
49
+ const { class: _, ...attributes } = this.$attrs
50
+ return attributes
51
+ }
52
+ }
53
+ }
54
+ </script>
@@ -1,6 +1,6 @@
1
1
  <!-- Derived from ATUI, and further extended: https://aliqin.github.io/atui/ -->
2
2
  <template lang="pug">
3
- Trigger.dito-date-picker(
3
+ DitoTrigger.dito-date-picker(
4
4
  ref="trigger"
5
5
  v-model:show="showPopup"
6
6
  trigger="focus"
@@ -11,7 +11,7 @@ Trigger.dito-date-picker(
11
11
  v-if="$slots.trigger"
12
12
  name="trigger"
13
13
  )
14
- InputField.dito-date-picker-input(
14
+ DitoInput.dito-date-picker-input(
15
15
  v-else
16
16
  ref="input"
17
17
  v-model="currentText"
@@ -22,17 +22,17 @@ Trigger.dito-date-picker(
22
22
  @keydown="onKeyDown"
23
23
  @mousedown.stop="onMouseDown(false)"
24
24
  )
25
- template(#before)
26
- slot(name="before")
27
- template(#after)
28
- Icon(
25
+ template(#prefix)
26
+ slot(name="prefix")
27
+ template(#suffix)
28
+ DitoIcon(
29
29
  name="calendar"
30
30
  :disabled="disabled"
31
31
  @mousedown.prevent="onMouseDown(true)"
32
32
  )
33
- slot(name="after")
33
+ slot(name="suffix")
34
34
  template(#popup)
35
- Calendar.dito-date-picker-popup(
35
+ DitoCalendar.dito-date-picker-popup(
36
36
  ref="calendar"
37
37
  v-model="currentValue"
38
38
  v-bind="{ locale, disabledDate }"
@@ -42,17 +42,17 @@ Trigger.dito-date-picker(
42
42
 
43
43
  <script>
44
44
  import { format, defaultFormats } from '@ditojs/utils'
45
- import Trigger from './Trigger.vue'
46
- import Calendar from './Calendar.vue'
47
- import InputField from './InputField.vue'
48
- import Icon from './Icon.vue'
45
+ import DitoTrigger from './DitoTrigger.vue'
46
+ import DitoCalendar from './DitoCalendar.vue'
47
+ import DitoInput from './DitoInput.vue'
48
+ import DitoIcon from './DitoIcon.vue'
49
49
  import { parseDate, getDatePartAtPosition } from '../utils/date.js'
50
50
  import { getSelection, setSelection } from '../utils/selection.js'
51
51
  import { getKeyNavigation } from '../utils/event.js'
52
52
  import { getTarget } from '../utils/trigger.js'
53
53
 
54
54
  export default {
55
- components: { Trigger, Calendar, InputField, Icon },
55
+ components: { DitoTrigger, DitoCalendar, DitoInput, DitoIcon },
56
56
  emits: ['update:modelValue', 'update:show', 'change', 'focus', 'blur'],
57
57
  inheritAttrs: false,
58
58
 
@@ -3,7 +3,7 @@
3
3
  .dito-date-time-picker__inner(
4
4
  :class="{ 'dito-date-time-picker__inner--focus': focused }"
5
5
  )
6
- InputField.dito-date-time-picker__input(
6
+ DitoInput.dito-date-time-picker__input(
7
7
  ref="input"
8
8
  v-model="currentText"
9
9
  type="text"
@@ -13,16 +13,16 @@
13
13
  @keydown="onKeyDown"
14
14
  @mousedown.stop="onMouseDown(false)"
15
15
  )
16
- template(#before)
17
- slot(name="before")
18
- template(#after)
19
- Icon(
16
+ template(#prefix)
17
+ slot(name="prefix")
18
+ template(#suffix)
19
+ DitoIcon(
20
20
  name="calendar"
21
21
  :disabled="disabled"
22
22
  @mousedown.prevent="onMouseDown(true)"
23
23
  )
24
- slot(name="after")
25
- DatePicker(
24
+ slot(name="suffix")
25
+ DitoDatePicker(
26
26
  ref="date"
27
27
  v-model="currentValue"
28
28
  v-model:show="showDate"
@@ -32,7 +32,7 @@
32
32
  )
33
33
  template(#trigger)
34
34
  //- Intentionally empty
35
- TimePicker(
35
+ DitoTimePicker(
36
36
  ref="time"
37
37
  v-model="currentValue"
38
38
  v-model:show="showTime"
@@ -46,16 +46,16 @@
46
46
 
47
47
  <script>
48
48
  import { format, defaultFormats, assignDeeply } from '@ditojs/utils'
49
- import InputField from './InputField.vue'
50
- import DatePicker from './DatePicker.vue'
51
- import TimePicker from './TimePicker.vue'
52
- import Icon from './Icon.vue'
49
+ import DitoInput from './DitoInput.vue'
50
+ import DitoDatePicker from './DitoDatePicker.vue'
51
+ import DitoTimePicker from './DitoTimePicker.vue'
52
+ import DitoIcon from './DitoIcon.vue'
53
53
  import { parseDate } from '../utils/date.js'
54
54
  import { getSelection, setSelection } from '../utils/selection.js'
55
55
  import { getKeyNavigation } from '../utils/event.js'
56
56
 
57
57
  export default {
58
- components: { InputField, DatePicker, TimePicker, Icon },
58
+ components: { DitoInput, DitoDatePicker, DitoTimePicker, DitoIcon },
59
59
  emits: ['update:modelValue', 'change', 'focus', 'blur'],
60
60
  inheritAttrs: false,
61
61
 
@@ -1,10 +1,5 @@
1
1
  <template lang="pug">
2
- i.dito-icon(
3
- :class=`{
4
- ['dito-icon--' + name]: true,
5
- 'dito-icon--disabled': disabled
6
- }`
7
- )
2
+ i.dito-icon(:class="classes")
8
3
  </template>
9
4
 
10
5
  <script>
@@ -18,6 +13,16 @@ export default {
18
13
  type: Boolean,
19
14
  default: false
20
15
  }
16
+ },
17
+
18
+ computed: {
19
+ classes() {
20
+ const prefix = 'dito-icon'
21
+ return {
22
+ [`${prefix}--${this.name}`]: true,
23
+ [`${prefix}--disabled`]: this.disabled
24
+ }
25
+ }
21
26
  }
22
27
  }
23
28
  </script>
@@ -40,17 +45,17 @@ export default {
40
45
  }
41
46
 
42
47
  .dito-icon {
48
+ position: relative;
49
+ width: 1em;
50
+ height: 1em;
51
+
43
52
  @at-root .dito-input & {
44
- position: absolute;
45
- inset: $border-width;
46
- left: unset;
47
- width: 2em;
48
53
  font-style: normal;
49
54
  border-radius: $border-radius;
50
55
  color: $color-grey;
51
56
  background: $color-white;
52
57
 
53
- &--disabled {
58
+ &.dito-icon--disabled {
54
59
  color: $color-light;
55
60
  }
56
61
  }
@@ -1,6 +1,9 @@
1
1
  <template lang="pug">
2
- .dito-input(:class="classes")
3
- slot(name="before")
2
+ .dito-input(
3
+ :class="classes"
4
+ @mousedown.prevent="onMouseDown"
5
+ )
6
+ slot(name="prefix")
4
7
  input(
5
8
  :id="id"
6
9
  ref="input"
@@ -16,7 +19,7 @@
16
19
  :aria-label="title"
17
20
  v-bind="attributes"
18
21
  )
19
- slot(name="after")
22
+ slot(name="suffix")
20
23
  </template>
21
24
 
22
25
  <script>
@@ -92,6 +95,14 @@ export default {
92
95
 
93
96
  blur() {
94
97
  this.input.blur()
98
+ },
99
+
100
+ onMouseDown() {
101
+ // Focus the input when the outer container is clicked, e.g. when clicking
102
+ // on affixes.
103
+ if (!this.disabled && !this.readonly) {
104
+ this.focus()
105
+ }
95
106
  }
96
107
  }
97
108
  }
@@ -101,15 +112,17 @@ export default {
101
112
  @import '../styles/_imports';
102
113
 
103
114
  .dito-input {
104
- display: inline-block;
115
+ display: inline-flex;
116
+ align-items: center;
105
117
 
106
118
  @extend %input;
107
119
 
108
120
  input {
109
121
  // Inherit all styling from .dito-input
110
122
  all: inherit;
123
+ flex: 1;
124
+ min-width: 0;
111
125
  display: inline-block;
112
- width: 100%;
113
126
  border: 0;
114
127
  margin: 0;
115
128
  padding: 0;
@@ -1,6 +1,6 @@
1
1
  <!-- Derived from ATUI, and further extended: https://aliqin.github.io/atui/ -->
2
2
  <template lang="pug">
3
- Trigger.dito-time-picker(
3
+ DitoTrigger.dito-time-picker(
4
4
  ref="trigger"
5
5
  v-model:show="showPopup"
6
6
  trigger="focus"
@@ -11,7 +11,7 @@ Trigger.dito-time-picker(
11
11
  v-if="$slots.trigger"
12
12
  name="trigger"
13
13
  )
14
- InputField.dito-time-picker-input(
14
+ DitoInput.dito-time-picker-input(
15
15
  v-else
16
16
  ref="input"
17
17
  v-model="currentText"
@@ -22,15 +22,15 @@ Trigger.dito-time-picker(
22
22
  @keydown="onKeyDown"
23
23
  @mousedown.stop="onMouseDown(false)"
24
24
  )
25
- template(#before)
26
- slot(name="before")
27
- template(#after)
28
- Icon(
25
+ template(#prefix)
26
+ slot(name="prefix")
27
+ template(#suffix)
28
+ DitoIcon(
29
29
  name="clock"
30
30
  :disabled="disabled"
31
31
  @mousedown.prevent="onMouseDown(true)"
32
32
  )
33
- slot(name="after")
33
+ slot(name="suffix")
34
34
  template(#popup)
35
35
  .dito-time-picker-popup
36
36
  .dito-time-picker-panel
@@ -67,16 +67,16 @@ Trigger.dito-time-picker(
67
67
 
68
68
  <script>
69
69
  import { format, defaultFormats } from '@ditojs/utils'
70
- import Trigger from './Trigger.vue'
71
- import InputField from './InputField.vue'
72
- import Icon from './Icon.vue'
70
+ import DitoTrigger from './DitoTrigger.vue'
71
+ import DitoInput from './DitoInput.vue'
72
+ import DitoIcon from './DitoIcon.vue'
73
73
  import { alterDate, parseDate, getDatePartAtPosition } from '../utils/date.js'
74
74
  import { getSelection, setSelection } from '../utils/selection.js'
75
75
  import { getKeyNavigation } from '../utils/event.js'
76
76
  import { getTarget } from '../utils/trigger.js'
77
77
 
78
78
  export default {
79
- components: { Trigger, InputField, Icon },
79
+ components: { DitoTrigger, DitoInput, DitoIcon },
80
80
  emits: ['update:modelValue', 'update:show', 'change', 'focus', 'blur'],
81
81
  inheritAttrs: false,
82
82
 
@@ -1,9 +1,10 @@
1
- export { default as Calendar } from './Calendar.vue'
2
- export { default as DatePicker } from './DatePicker.vue'
3
- export { default as DateTimePicker } from './DateTimePicker.vue'
4
- export { default as Icon } from './Icon.vue'
5
- export { default as InputField } from './InputField.vue'
6
- export { default as Pagination } from './Pagination.vue'
7
- export { default as SwitchButton } from './SwitchButton.vue'
8
- export { default as TimePicker } from './TimePicker.vue'
9
- export { default as Trigger } from './Trigger.vue'
1
+ export { default as DitoButton } from './DitoButton.vue'
2
+ export { default as DitoCalendar } from './DitoCalendar.vue'
3
+ export { default as DitoDatePicker } from './DitoDatePicker.vue'
4
+ export { default as DitoDateTimePicker } from './DitoDateTimePicker.vue'
5
+ export { default as DitoIcon } from './DitoIcon.vue'
6
+ export { default as DitoInput } from './DitoInput.vue'
7
+ export { default as DitoPagination } from './DitoPagination.vue'
8
+ export { default as DitoSwitch } from './DitoSwitch.vue'
9
+ export { default as DitoTimePicker } from './DitoTimePicker.vue'
10
+ export { default as DitoTrigger } from './DitoTrigger.vue'
@@ -17,6 +17,27 @@
17
17
  min-height: 1.5em;
18
18
  @include user-select(none);
19
19
 
20
+ &--affixed {
21
+ display: inline-grid;
22
+ grid-template-columns: 1fr auto 1fr;
23
+ }
24
+
25
+ &__text,
26
+ &__prefix,
27
+ &__suffix {
28
+ display: flex;
29
+ align-items: center;
30
+ justify-content: center;
31
+ }
32
+
33
+ &__prefix {
34
+ justify-content: flex-start;
35
+ }
36
+
37
+ &__suffix {
38
+ justify-content: flex-end;
39
+ }
40
+
20
41
  &:focus {
21
42
  border-color: $color-active;
22
43
  }
File without changes