@mixd-id/web-scaffold 0.1.230406243 → 0.1.230406245

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.230406243",
4
+ "version": "0.1.230406245",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -0,0 +1,126 @@
1
+ <template>
2
+ <div :class="$style.comp">
3
+ <div v-for="(val, idx) in value" class="flex flex-row items-start">
4
+ <button type="button" @click="value.splice(idx, 1);updateModelValue()" class="p-2">
5
+ <svg width="16" height="16" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 464c-118.7 0-216-96.1-216-216 0-118.7 96.1-216 216-216 118.7 0 216 96.1 216 216 0 118.7-96.1 216-216 216zm94.8-285.3L281.5 256l69.3 69.3c4.7 4.7 4.7 12.3 0 17l-8.5 8.5c-4.7 4.7-12.3 4.7-17 0L256 281.5l-69.3 69.3c-4.7 4.7-12.3 4.7-17 0l-8.5-8.5c-4.7-4.7-4.7-12.3 0-17l69.3-69.3-69.3-69.3c-4.7-4.7-4.7-12.3 0-17l8.5-8.5c4.7-4.7 12.3-4.7 17 0l69.3 69.3 69.3-69.3c4.7-4.7 12.3-4.7 17 0l8.5 8.5c4.6 4.7 4.6 12.3 0 17z"/></svg>
6
+ </button>
7
+ <div class="pr-2">
8
+ <select v-model="val.key" @change="updateModelValue">
9
+ <option value="*">All Days</option>
10
+ <option value="sun">Sun</option>
11
+ <option value="mon">Mon</option>
12
+ <option value="tue">Tue</option>
13
+ <option value="wed">Wed</option>
14
+ <option value="thu">Thu</option>
15
+ <option value="fri">Fri</option>
16
+ <option value="sat">Sat</option>
17
+ </select>
18
+ </div>
19
+ <div class="flex-1 flex flex-col gap-1 pl-2 border-l-[1px] border-text-100 divide-y divide-text-100">
20
+ <div v-for="(range, i) in val.value" class="flex flex-row">
21
+ <div class="flex-1 flex flex-row">
22
+ <input type="time" v-model="val.value[i][0]">
23
+ <div class="py-2">-</div>
24
+ <input type="time" v-model="val.value[i][1]">
25
+ </div>
26
+ <div class="p-2 flex flex-row gap-2">
27
+ <button v-if="val.value.length > 1" type="button" @click="val.value.splice(i, 1)">
28
+ <svg width="14" height="14" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M140 274c-6.6 0-12-5.4-12-12v-12c0-6.6 5.4-12 12-12h232c6.6 0 12 5.4 12 12v12c0 6.6-5.4 12-12 12H140zm364-18c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zm-32 0c0-119.9-97.3-216-216-216-119.9 0-216 97.3-216 216 0 119.9 97.3 216 216 216 119.9 0 216-97.3 216-216z"/></svg>
29
+ </button>
30
+ <button type="button" @click="val.value.push([ '00:00', '23:59' ])">
31
+ <svg width="14" height="14" class="fill-text-300 hover:fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M443.5 248.5l-7.1-7.1c-4.7-4.7-12.3-4.7-17 0L241 419.9V44c0-6.6-5.4-12-12-12h-10c-6.6 0-12 5.4-12 12v375.9L28.5 241.4c-4.7-4.7-12.3-4.7-17 0l-7.1 7.1c-4.7 4.7-4.7 12.3 0 17l211 211.1c4.7 4.7 12.3 4.7 17 0l211-211.1c4.8-4.8 4.8-12.3.1-17z"/></svg>
32
+ </button>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ </div>
37
+ <div class="flex justify-center">
38
+ <button type="button" @click="add" class="p-2">
39
+ <svg width="16" height="16" class="fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M384 250v12c0 6.6-5.4 12-12 12h-98v98c0 6.6-5.4 12-12 12h-12c-6.6 0-12-5.4-12-12v-98h-98c-6.6 0-12-5.4-12-12v-12c0-6.6 5.4-12 12-12h98v-98c0-6.6 5.4-12 12-12h12c6.6 0 12 5.4 12 12v98h98c6.6 0 12 5.4 12 12zm120 6c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zm-32 0c0-119.9-97.3-216-216-216-119.9 0-216 97.3-216 216 0 119.9 97.3 216 216 216 119.9 0 216-97.3 216-216z"/></svg>
40
+ </button>
41
+ </div>
42
+ </div>
43
+ </template>
44
+
45
+ <script>
46
+
47
+ export default{
48
+
49
+ emits: [ 'update:modelValue' ],
50
+
51
+ props: {
52
+
53
+ modelValue: {
54
+ type: Object
55
+ }
56
+
57
+ },
58
+
59
+ data(){
60
+ return {
61
+ value: [
62
+ { key:'mon', value:[ [ '08:00', '10:00' ], [ '12:00', '14:00' ] ] }
63
+ ]
64
+ }
65
+ },
66
+
67
+ methods: {
68
+
69
+ add(){
70
+
71
+ this.value.push({ value:[ [ '00:00', '23:59'] ] })
72
+
73
+ },
74
+
75
+ updateModelValue(){
76
+ const modelValue = {}
77
+ this.value.forEach( (val) => {
78
+ modelValue[val.key] = val.value
79
+ })
80
+
81
+ console.log(modelValue)
82
+
83
+ this.$emit('update:modelValue', modelValue)
84
+ },
85
+
86
+ updateValue(){
87
+ this.value = []
88
+ for( const key in this.modelValue ){
89
+ this.value.push({ key, value: this.modelValue[key] })
90
+ }
91
+ }
92
+
93
+ },
94
+
95
+ mounted() {
96
+ this.updateValue()
97
+ },
98
+
99
+ watch: {
100
+
101
+ modelValue(){
102
+ this.updateValue()
103
+ }
104
+
105
+ }
106
+
107
+ }
108
+
109
+ </script>
110
+
111
+ <style module>
112
+
113
+ .comp{
114
+ @apply border-[1px] border-text-200 bg-base-50 rounded-lg;
115
+ @apply inline-flex flex-col divide-y divide-text-100;
116
+ }
117
+
118
+ .comp select{
119
+ @apply bg-transparent p-2 outline-none;
120
+ }
121
+
122
+ .comp input{
123
+ @apply bg-transparent p-1 outline-none appearance-none;
124
+ }
125
+
126
+ </style>
@@ -165,6 +165,9 @@ export default {
165
165
  .dropdown:not(.readonly){
166
166
  @apply hover:border-text-300;
167
167
  }
168
+ .dropdown.readonly{
169
+ @apply bg-text-50;
170
+ }
168
171
 
169
172
  .dropdown select,
170
173
  .dropdown input{
@@ -178,7 +178,7 @@ export default{
178
178
  }
179
179
 
180
180
  .textbox.readonly{
181
- @apply bg-base-50;
181
+ @apply bg-text-50;
182
182
  }
183
183
 
184
184
  .size-sm input{ @apply text-sm; }
package/src/index.js CHANGED
@@ -474,6 +474,7 @@ export default{
474
474
  app.component('ObjectTree', defineAsyncComponent(() => import("./components/ObjectTree.vue")))
475
475
  app.component('FBLogin', defineAsyncComponent(() => import("./components/FBLogin.vue")))
476
476
  app.component('GSignIn', defineAsyncComponent(() => import("./components/GSignIn.vue")))
477
+ app.component('DayTimeRange', defineAsyncComponent(() => import("./components/DayTimeRange.vue")))
477
478
 
478
479
  app.component('AhrefSetting', defineAsyncComponent(() => import("./widgets/AhrefSetting.vue")))
479
480
  app.component('ArticleSetting', defineAsyncComponent(() => import("./widgets/ArticleSetting.vue")))
@@ -2,6 +2,7 @@ const md5 = require("md5");
2
2
  const fs = require("fs");
3
3
  const { Op } = module.parent.require('sequelize')
4
4
  const axios = module.parent.require('axios')
5
+ const dayjs = module.parent.require('dayjs')
5
6
 
6
7
 
7
8
  const ceil = (num, precision = 0) => {
@@ -470,6 +471,26 @@ const datasourceLoad = async ({ datasource, Models }) => {
470
471
  return obj
471
472
  }
472
473
 
474
+ const dayTimeRange = (params, value) => {
475
+
476
+ /*params = {
477
+ '*': [ [ '08:00', '12:00' ], [ '13:00', '18:00' ] ],
478
+ 'sat': [ [ '08:00', '12:00' ], [ '13:00', '14:00' ] ],
479
+ }
480
+ value = '2023-02-06 17:59:00'*/
481
+
482
+ if(!value)
483
+ value = dayjs().format('YYYY-MM-DD HH:mm:ss')
484
+
485
+ const curDay = dayjs(value).format('ddd').toLowerCase()
486
+ const curTime = dayjs(value).format('HH:mm')
487
+ const ranges = params[curDay] ?? params['*']
488
+
489
+ return (ranges ?? []).some((range) => {
490
+ return curTime >= range[0] && curTime <= range[1]
491
+ })
492
+ }
493
+
473
494
 
474
495
  module.exports = {
475
496
  ceil,
@@ -497,4 +518,5 @@ module.exports = {
497
518
  removeStyleFromTag,
498
519
  datasourceGet,
499
520
  datasourceLoad,
521
+ dayTimeRange,
500
522
  }