@mixd-id/web-scaffold 0.1.230406071 → 0.1.230406074

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.230406071",
4
+ "version": "0.1.230406074",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -11,6 +11,7 @@
11
11
  "exports": {
12
12
  ".": "./src/index.js",
13
13
  "./themes/default": "./src/themes/default/index.js",
14
+ "./mixin/component": "./src/mixin/component.js",
14
15
  "./helpers": {
15
16
  "require": "./src/utils/helpers.js",
16
17
  "import": "./src/utils/helpers.mjs"
@@ -6,14 +6,25 @@
6
6
 
7
7
  <script>
8
8
 
9
- import {_applyClass, mediaPrefixes} from "../utils/helpers.mjs";
9
+ import {_applyClass} from "../utils/helpers.mjs";
10
+ import { componentMixin } from '../mixin/component';
10
11
 
11
12
  export default{
12
13
 
14
+ mixins: [ componentMixin ],
15
+
16
+ props: {
17
+
18
+ title: {
19
+ type: String,
20
+ default: 'Box'
21
+ }
22
+
23
+ },
24
+
13
25
  computed: {
14
26
 
15
27
  computedClass(){
16
-
17
28
  const classNames = [
18
29
  this.$style.comp
19
30
  ]
@@ -21,23 +32,8 @@ export default{
21
32
  classNames.push(..._applyClass(this.$props, { display:'flex' }))
22
33
 
23
34
  return classNames.join(' ')
24
- }
25
-
26
- },
27
-
28
- props: {
29
-
30
- title: {
31
- type: String,
32
- default: 'Box'
33
35
  },
34
36
 
35
- margin: Array,
36
-
37
- padding: Array,
38
-
39
- display: Array
40
-
41
37
  }
42
38
 
43
39
  }
@@ -48,6 +44,21 @@ export default{
48
44
 
49
45
  .comp{
50
46
  @apply border-[1px] border-text-200 flex items-center justify-center;
47
+ background-color: v-bind(bgColor[0]);
48
+ background-image: v-bind(bgImages[0]);
49
+ background-position: v-bind(bgPositions[0]);
50
+ background-size: v-bind(bgSizes[0]);
51
+ background-repeat: v-bind(bgRepeats[0]);
52
+ }
53
+
54
+ @media screen and (min-width: 768px){
55
+ .comp{
56
+ background-color: v-bind(bgColor[1]);
57
+ background-image: v-bind(bgImages[1]);
58
+ background-position: v-bind(bgPositions[1]);
59
+ background-size: v-bind(bgSizes[1]);
60
+ background-repeat: v-bind(bgRepeats[1]);
61
+ }
51
62
  }
52
63
 
53
64
  </style>
@@ -13,9 +13,13 @@
13
13
  @click="select(color)"></div>
14
14
  </div>
15
15
  </div>
16
- <button type="button" v-if="Boolean(customColor)"
17
- class="w-full p-1 border-text-100 border-[1px] rounded-lg"
18
- @click="$refs.inputColor.click()">Custom</button>
16
+ <div class="grid grid-cols-2 gap-4">
17
+ <button type="button" @click="select('')"
18
+ class="w-full p-1 border-text-100 border-[1px] rounded-lg">None</button>
19
+ <button type="button" v-if="Boolean(customColor)"
20
+ class="w-full p-1 border-text-100 border-[1px] rounded-lg"
21
+ @click="$refs.inputColor.click()">Custom</button>
22
+ </div>
19
23
  </div>
20
24
  </ContextMenu>
21
25
 
@@ -355,7 +355,7 @@ export default{
355
355
 
356
356
  onHooks(model, event, items){
357
357
 
358
- if(model === this.subscriptionObj.model){
358
+ if(model === this.subscriptionObj.model && Array.isArray(items)){
359
359
  switch(event){
360
360
 
361
361
  case 'create':
@@ -0,0 +1,114 @@
1
+ <template>
2
+ <div :class="$style.comp">
3
+ <div class="flex flex-row gap-1">
4
+ <button type="button" @click="setType(1)">
5
+ <svg width="12" height="12" class="fill-text" :class="{ 'fill-primary-500':type === 1 }" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zm16 400c0 8.8-7.2 16-16 16H48c-8.8 0-16-7.2-16-16V80c0-8.8 7.2-16 16-16h352c8.8 0 16 7.2 16 16v352z"/></svg>
6
+ </button>
7
+ <button type="button" @click="setType(2)">
8
+ <svg width="12" height="12" class="fill-text" :class="{ 'fill-primary-500':type === 2 }" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M120 32H48A48 48 0 0 0 0 80v352a48 48 0 0 0 48 48h72a8 8 0 0 0 8-8v-16a8 8 0 0 0-8-8H48a16 16 0 0 1-16-16V80a16 16 0 0 1 16-16h72a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8zm280 0h-72a8 8 0 0 0-8 8v16a8 8 0 0 0 8 8h72a16 16 0 0 1 16 16v352a16 16 0 0 1-16 16h-72a8 8 0 0 0-8 8v16a8 8 0 0 0 8 8h72a48 48 0 0 0 48-48V80a48 48 0 0 0-48-48z"/></svg>
9
+ </button>
10
+ <button type="button" @click="setType(4)">
11
+ <svg width="12" height="12" class="fill-text" :class="{ 'fill-primary-500':type === 4 }" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48H48C21.49 32 0 53.49 0 80zm240-16v176H32V80c0-8.837 7.163-16 16-16h192zM32 432V272h208v176H48c-8.837 0-16-7.163-16-16zm240 16V272h208v160c0 8.837-7.163 16-16 16H272zm208-208H272V64h192c8.837 0 16 7.163 16 16v160z"/></svg>
12
+ </button>
13
+ </div>
14
+ <div class="grid grid-cols-4 gap-1">
15
+ <select v-if="type >= 1" :value="values[0]"
16
+ @change="(e) => setValue(0, e.target.value)">
17
+ <option v-for="i in 9" :value="i - 1">{{ i - 1}}</option>
18
+ </select>
19
+ <select v-if="type >= 2" :value="values[1]"
20
+ @change="(e) => setValue(1, e.target.value)">
21
+ <option v-for="i in 9" :value="i - 1">{{ i - 1}}</option>
22
+ </select>
23
+ <select v-if="type >= 4" :value="values[2]"
24
+ @change="(e) => setValue(2, e.target.value)">
25
+ <option v-for="i in 9" :value="i - 1">{{ i - 1}}</option>
26
+ </select>
27
+ <select v-if="type >= 4" :value="values[3]"
28
+ @change="(e) => setValue(3, e.target.value)">
29
+ <option v-for="i in 9" :value="i - 1">{{ i - 1}}</option>
30
+ </select>
31
+ </div>
32
+ </div>
33
+ </template>
34
+
35
+ <script>
36
+
37
+ export default{
38
+
39
+ emits: [ 'change', 'update:modelValue' ],
40
+
41
+ props: {
42
+
43
+ modelValue: String
44
+
45
+ },
46
+
47
+ methods: {
48
+
49
+ setType(type){
50
+ let v
51
+ switch(type){
52
+ case 1:
53
+ v = [ this.values[0] ]
54
+ break
55
+ case 2:
56
+ v = [ this.values[0], this.values[1] ?? '0' ]
57
+ break
58
+ case 4:
59
+ v = [
60
+ this.values[0],
61
+ this.values[1] ?? '0',
62
+ this.values[2] ?? '0',
63
+ this.values[3] ?? '0'
64
+ ]
65
+ break
66
+ }
67
+
68
+ if(Array.isArray(v)){
69
+ this.$emit('update:modelValue', v.join(','))
70
+ this.$emit('change')
71
+ }
72
+ },
73
+
74
+ setValue(idx, value){
75
+ const v = [ ...this.values ]
76
+ v[idx] = value
77
+ this.$emit('update:modelValue', v.join(','))
78
+ this.$emit('change')
79
+ }
80
+
81
+ },
82
+
83
+ computed: {
84
+
85
+ type(){
86
+ return (this.modelValue ?? '').split(',').length
87
+ },
88
+
89
+ values(){
90
+ return (this.modelValue ?? '').split(',')
91
+ }
92
+
93
+ }
94
+
95
+ }
96
+
97
+ </script>
98
+
99
+ <style module>
100
+
101
+ .comp{
102
+ @apply flex flex-col gap-1;
103
+ }
104
+
105
+ .comp button{
106
+ @apply border-[1px] border-text-200 bg-text-100 rounded-lg p-1 px-3;
107
+ }
108
+
109
+ .comp select{
110
+ @apply appearance-none outline-none p-1 text-center bg-transparent cursor-pointer w-full;
111
+ @apply border-[1px] border-text-200 rounded-lg;
112
+ }
113
+
114
+ </style>
@@ -2,8 +2,8 @@
2
2
  <div :class="computedClass">
3
3
  <slot name="start"></slot>
4
4
  <textarea
5
- :placeholder="placeholder" :rows="rows" ref="input" @blur="onBlur" @input="onInput"
6
- :value="modelValue" />
5
+ :placeholder="placeholder" :rows="rows" ref="input" @focus="isActive = true" @blur="onBlur" @input="onInput"
6
+ :value="modelValue" :readonly="Boolean(readonly)" />
7
7
  <div v-if="state === -2 && !!(errors)">
8
8
  <svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
9
9
  <path fill-rule="evenodd" clip-rule="evenodd" d="M12 13.75C12.4142 13.75 12.75 13.4142 12.75 13V8.00001C12.75 7.5858 12.4142 7.25001 12 7.25001C11.5858 7.25001 11.25 7.5858 11.25 8.00001V13C11.25 13.4142 11.5858 13.75 12 13.75Z"/>
@@ -53,6 +53,8 @@ export default{
53
53
 
54
54
  placeholder: String,
55
55
 
56
+ readonly: undefined,
57
+
56
58
  rows: String,
57
59
 
58
60
  },
@@ -89,6 +91,7 @@ export default{
89
91
  this.$style['state-' + this.computedState],
90
92
  this.isActive ? this.$style.active : '',
91
93
  this.align ? this.$style['align-' + this.align] : '',
94
+ this.readonly ? this.$style.readonly : '',
92
95
  this.size ? this.$style['size-' + this.size] : ''
93
96
  ].join(' ')
94
97
  },
@@ -133,7 +136,7 @@ export default{
133
136
 
134
137
  .textarea{
135
138
  @apply min-h-[var(--h-cp)];
136
- @apply flex items-start border-[1px] border-text-100 bg-base-50 rounded-lg overflow-hidden;
139
+ @apply flex items-start border-[1px] border-text-200 bg-base-50 rounded-lg overflow-hidden;
137
140
  @apply !max-h-[200px];
138
141
  }
139
142
  .textarea textarea{
@@ -147,6 +150,9 @@ export default{
147
150
  .textarea>textarea::placeholder{
148
151
  @apply text-text-200;
149
152
  }
153
+ .textarea.readonly{
154
+ @apply bg-text-50;
155
+ }
150
156
 
151
157
  .size-sm{ @apply min-h-[var(--h-cp-sm)]; }
152
158
  .size-sm textarea{ @apply text-sm; }
@@ -173,4 +179,4 @@ export default{
173
179
  @apply text-right
174
180
  }
175
181
 
176
- </style>
182
+ </style>
package/src/index.js CHANGED
@@ -307,6 +307,7 @@ export default{
307
307
  app.component('SplitPane', defineAsyncComponent(() => import("./components/SplitPane.vue")))
308
308
  app.component('TabView', defineAsyncComponent(() => import("./components/TabView.vue")))
309
309
  app.component('TextEditor', defineAsyncComponent(() => import("./components/TextEditor.vue")))
310
+ app.component('PaddingBox', defineAsyncComponent(() => import("./components/PaddingBox.vue")))
310
311
 
311
312
 
312
313
  }
@@ -0,0 +1,153 @@
1
+ // mixin/component.js
2
+ export const componentMixin = {
3
+
4
+ props: {
5
+
6
+ bgColors: Array,
7
+ bgImage: Array,
8
+ bgPosition: Array,
9
+ bgSize: Array,
10
+ bgRepeat: Array,
11
+
12
+ bdColor: Array,
13
+ bdSize: Array,
14
+ bdStyle: Array,
15
+ bdRadius: Array,
16
+
17
+ maxWidth: Array,
18
+
19
+ enabled: Boolean,
20
+ name: String,
21
+ margin: Array,
22
+ padding: Array,
23
+ display: Array,
24
+ uid: String
25
+
26
+ },
27
+
28
+ computed: {
29
+
30
+ bgImages(){
31
+ return [
32
+ this.bgImage && this.bgImage[0] && this.bgImage[0].imageUrl ?
33
+ `url('${import.meta.env.VITE_IMAGE_HOST + '/' + this.bgImage[0].imageUrl}')` : '',
34
+ this.bgImage && this.bgImage[1] && this.bgImage[1].imageUrl ?
35
+ `url('${import.meta.env.VITE_IMAGE_HOST + '/' + this.bgImage[1].imageUrl}')` :
36
+ (this.bgImage && this.bgImage[0] && this.bgImage[0].imageUrl ?
37
+ `url('${import.meta.env.VITE_IMAGE_HOST + '/' + this.bgImage[0].imageUrl}')` : '')
38
+ ]
39
+ },
40
+
41
+ bgPositions(){
42
+ return [
43
+ this.bgPosition && this.bgPosition[0] ? this.bgPosition[0] : '',
44
+ this.bgPosition && this.bgPosition[1] ? this.bgPosition[1] :
45
+ (this.bgPosition && this.bgPosition[0] ? this.bgPosition[0] : '')
46
+ ]
47
+ },
48
+
49
+ bgSizes(){
50
+ return [
51
+ this.bgSize && this.bgSize[0] ? this.bgSize[0] : '',
52
+ this.bgSize && this.bgSize[1] ? this.bgSize[1] :
53
+ (this.bgSize && this.bgSize[0] ? this.bgSize[0] : '')
54
+ ]
55
+ },
56
+
57
+ bgRepeats(){
58
+ return [
59
+ this.bgRepeat && this.bgRepeat[0] ? this.bgRepeat[0] : '',
60
+ this.bgRepeat && this.bgRepeat[1] ? this.bgRepeat[1] :
61
+ (this.bgRepeat && this.bgRepeat[0] ? this.bgRepeat[0] : '')
62
+ ]
63
+ },
64
+
65
+ bgColor(){
66
+ return [
67
+ this.bgColors && this.bgColors[0] ? this.bgColors[0] : '',
68
+ this.bgColors && this.bgColors[1] ? this.bgColors[1] :
69
+ (this.bgColors && this.bgColors[0] ? this.bgColors[0] : '')
70
+ ]
71
+ },
72
+
73
+ bdColors(){
74
+ return [
75
+ this.bdColor && this.bdColor[0] ? this.bdColor[0] : '',
76
+ this.bdColor && this.bdColor[1] ? this.bdColor[1] :
77
+ (this.bdColor && this.bdColor[0] ? this.bdColor[0] : '')
78
+ ]
79
+ },
80
+
81
+ bdSizes(){
82
+ if(!this.bdSize) return [[], []]
83
+
84
+ const bdSize0 = (this.bdSize[0] ?? '').split(',')
85
+ const bdSize1 = this.bdSize[1] ? this.bdSize[1].split(',') : bdSize0
86
+
87
+ return [
88
+ [
89
+ bdSize0.length === 1 ? bdSize0[0] + 'px' : bdSize0[0] + 'px',
90
+ bdSize0.length === 1 ? bdSize0[0] + 'px' : bdSize0[1] + 'px',
91
+ bdSize0.length === 1 ? bdSize0[0] + 'px' : bdSize0[2] + 'px',
92
+ bdSize0.length === 1 ? bdSize0[0] + 'px' : bdSize0[3] + 'px',
93
+ ],
94
+ [
95
+ bdSize1.length === 1 ? bdSize1[0] + 'px' : bdSize1[0] + 'px',
96
+ bdSize1.length === 1 ? bdSize1[0] + 'px' : bdSize1[1] + 'px',
97
+ bdSize1.length === 1 ? bdSize1[0] + 'px' : bdSize1[2] + 'px',
98
+ bdSize1.length === 1 ? bdSize1[0] + 'px' : bdSize1[3] + 'px',
99
+ ]
100
+ ]
101
+ },
102
+
103
+ bdRadiuses(){
104
+ if(!this.bdRadius) return [[], []]
105
+
106
+ const bdRadius0 = (this.bdRadius[0] ?? '').split(',')
107
+ const bdRadius1 = this.bdRadius[1] ? this.bdRadius[1].split(',') : bdRadius0
108
+
109
+ return [
110
+ [
111
+ bdRadius0.length === 1 ? bdRadius0[0] + 'px' : bdRadius0[0] + 'px',
112
+ bdRadius0.length === 1 ? bdRadius0[0] + 'px' : bdRadius0[1] + 'px',
113
+ bdRadius0.length === 1 ? bdRadius0[0] + 'px' : bdRadius0[2] + 'px',
114
+ bdRadius0.length === 1 ? bdRadius0[0] + 'px' : bdRadius0[3] + 'px',
115
+ ],
116
+ [
117
+ bdRadius1.length === 1 ? bdRadius1[0] + 'px' : bdRadius1[0] + 'px',
118
+ bdRadius1.length === 1 ? bdRadius1[0] + 'px' : bdRadius1[1] + 'px',
119
+ bdRadius1.length === 1 ? bdRadius1[0] + 'px' : bdRadius1[2] + 'px',
120
+ bdRadius1.length === 1 ? bdRadius1[0] + 'px' : bdRadius1[3] + 'px',
121
+ ]
122
+ ]
123
+ },
124
+
125
+ bdStyles(){
126
+ if(!this.bdStyle) return []
127
+
128
+ return [
129
+ this.bdStyle[0] ? this.bdStyle[0] : '',
130
+ this.bdStyle[1] ? this.bdStyle[1] : (this.bdStyle[0] ? this.bdStyle[0] : '')
131
+ ]
132
+ },
133
+
134
+ maxWidths(){
135
+
136
+ return [
137
+ this.maxWidth && this.maxWidth[0] ? this.maxWidth[0] : '',
138
+ this.maxWidth && this.maxWidth[1] ? this.maxWidth[1] :
139
+ (this.maxWidth && this.maxWidth[0] ? this.maxWidth[0] : '')
140
+ ]
141
+ },
142
+
143
+ margins(){
144
+ if(!this.maxWidth) return []
145
+
146
+ return [
147
+ '0 auto',
148
+ '0 auto',
149
+ ]
150
+ }
151
+
152
+ }
153
+ };
@@ -147,19 +147,47 @@ const mediaPrefixes = [
147
147
  '',
148
148
  'md:'
149
149
  ]
150
+ const calcUnit = (prefix, midfix, value) => {
151
+
152
+ const values = (value ?? '').split(',')
153
+
154
+ if(values.length === 1){
155
+ return prefix + midfix + '-' + values[0]
156
+ }
157
+ else if(values.length === 2){
158
+ return prefix + midfix + 'x-' + values[0] +
159
+ ' ' +
160
+ prefix + midfix + 'y-' + values[1]
161
+ }
162
+ else if(values.length === 4){
163
+ return prefix + midfix + 'l-' + values[0] +
164
+ ' ' +
165
+ prefix + midfix + 't-' + values[1] +
166
+ ' ' +
167
+ prefix + midfix + 'r-' + values[2] +
168
+ ' ' +
169
+ prefix + midfix + 'b-' + values[3]
170
+ }
171
+ }
150
172
  const _applyClass = function(props, defaultClass = {}){
151
173
 
152
174
  const arr = []
153
175
 
154
176
  if(Array.isArray(props.padding) && props.padding.length > 0){
155
177
  for(let i in props.padding){
156
- arr.push(mediaPrefixes[i] + 'p-' + props.padding[i])
178
+ const unit = calcUnit(mediaPrefixes[i], 'p', props.padding[i])
179
+ if(unit){
180
+ arr.push(unit)
181
+ }
157
182
  }
158
183
  }
159
184
 
160
185
  if(Array.isArray(props.margin)){
161
186
  for(let i in props.margin){
162
- arr.push(mediaPrefixes[i] + 'm-' + props.margin[i])
187
+ const unit = calcUnit(mediaPrefixes[i], 'm', props.margin[i])
188
+ if(unit){
189
+ arr.push(unit)
190
+ }
163
191
  }
164
192
  }
165
193