@mptw/skylens-ui 1.4.79 → 1.4.81

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.
@@ -0,0 +1,109 @@
1
+ <template lang="pug">
2
+ .sl-context-menu-avatar(ref='el')
3
+ ClientOnly
4
+ Teleport(to='body')
5
+ .sl-context-menu-wrapper.hidden(ref='menuWrapperEl', @mousedown='onMouseDown')
6
+ .sl-context-menu(ref='menuEl')
7
+ a.sl-context-menu-item(
8
+ v-for='action in actions',
9
+ href='javascript:;',
10
+ :key='action.key',
11
+ @click='onClickAction(action.key)',
12
+ ) {{ action.label }}
13
+ </template>
14
+
15
+ <script lang="ts">
16
+ import { fromEvent, Subscription } from 'rxjs';
17
+
18
+ export default defineComponent({
19
+ name: 'SLContextMenu',
20
+ props: {
21
+ actions: {
22
+ type: Array as PropType<{
23
+ key: string,
24
+ label: string,
25
+ }[]>,
26
+ default: () => [{
27
+ key: 'saveAs',
28
+ label: '另存圖檔 (.png)',
29
+ }, {
30
+ key: 'copy',
31
+ label: '複製圖檔',
32
+ }],
33
+ },
34
+ },
35
+ emits: ['action'],
36
+ setup(props, { emit }) {
37
+ const { actions } = toRefs(props);
38
+
39
+ const el = shallowRef<HTMLDivElement | null>(null);
40
+ const menuWrapperEl = shallowRef<HTMLDivElement | null>(null);
41
+ const menuEl = shallowRef<HTMLDivElement | null>(null);
42
+
43
+ let contextMenuSubscriber: Subscription | null = null;
44
+
45
+ function onClickAction(key: string) {
46
+ emit('action', key);
47
+ hide();
48
+ }
49
+
50
+ function show() {
51
+ menuWrapperEl.value?.classList.remove('hidden');
52
+ }
53
+
54
+ function hide() {
55
+ menuWrapperEl.value?.classList.add('hidden');
56
+ }
57
+
58
+ function onRightClick(e: PointerEvent) {
59
+ console.log(menuEl.value, actions.value);
60
+ if (!menuEl.value || !actions.value.length) {
61
+ return;
62
+ }
63
+
64
+ e.preventDefault();
65
+ menuEl.value.setAttribute('style', `top: ${e.clientY}px; left: ${e.clientX}px;`);
66
+ show();
67
+ }
68
+
69
+ function onMouseDown() {
70
+ hide();
71
+ }
72
+
73
+ onMounted(() => {
74
+ if (el.value && el.value.parentElement) {
75
+ contextMenuSubscriber = fromEvent(el.value.parentElement, 'contextmenu').subscribe((e) => {
76
+ onRightClick(e as PointerEvent);
77
+ });
78
+ }
79
+ });
80
+
81
+ onBeforeUnmount(() => {
82
+ if (contextMenuSubscriber) {
83
+ contextMenuSubscriber.unsubscribe();
84
+ }
85
+ contextMenuSubscriber = null;
86
+ });
87
+
88
+ return {
89
+ el,
90
+ menuWrapperEl,
91
+ menuEl,
92
+ onClickAction,
93
+ onMouseDown,
94
+ };
95
+ },
96
+ });
97
+ </script>
98
+
99
+ <style lang="stylus">
100
+ .sl-context-menu-wrapper
101
+ @apply s('z-[9999]') fixed top-0 left-0 w-full h-full
102
+
103
+ .sl-context-menu
104
+ @apply absolute border border-primary-600 rounded overflow-hidden shadow-popup-sm
105
+
106
+ &-item
107
+ @apply block w-auto s('min-w-[160px]') p-3 bg-white text-base text-gray-2
108
+ @apply s('hover:bg-primary-100') s('hover:text-primary')
109
+ </style>
@@ -4,12 +4,12 @@
4
4
  ref="el"
5
5
  )
6
6
  input(
7
- type="checkbox"
8
- :id="uid"
9
- v-model="modelProxy"
10
- :true-value="trueValue",
11
- :false-value="falseValue",
12
- )
7
+ type="checkbox"
8
+ :id="uid"
9
+ v-model="modelProxy"
10
+ :true-value="trueValue",
11
+ :false-value="falseValue",
12
+ )
13
13
  label(:for="uid" :style="`width: ${labelWidth}px;`" ref="labelEl")
14
14
  span(ref="trueLabelEl").true-label {{ size === '' ? trueLabel : minTrueLabel }}
15
15
  span(ref="falseLabelEl").false-label {{ size === '' ? falseLabel : minFalseLabel }}
@@ -52,7 +52,7 @@ export default defineComponent({
52
52
  size: {
53
53
  type: String,
54
54
  default: "",
55
- validator: (val: string) => ["", "min", "sm"].includes(val),
55
+ validator: (val: string) => ["", "min", "sm", "xs"].includes(val),
56
56
  },
57
57
  color: {
58
58
  type: String,
@@ -198,6 +198,19 @@ export default defineComponent({
198
198
  .false-label
199
199
  @apply s('pl-[31px]')
200
200
 
201
+ &.ios-switch-xs
202
+ label
203
+ @apply s('min-w-[60px]') s('h-[24px]') text-xs
204
+
205
+ &:before
206
+ @apply s('inset-y-0.75') s('left-0.75') s('w-[16px]') border border-primary-100 rounded-full shadow-none
207
+
208
+ .true-label
209
+ @apply s('pr-[27px]')
210
+
211
+ .false-label
212
+ @apply s('pl-[27px]')
213
+
201
214
  &.ios-switch-primary-600
202
215
  input:checked + label
203
216
  @apply bg-primary-600 border-primary
@@ -35,14 +35,14 @@
35
35
  v-else
36
36
  )
37
37
  .sidebar-mode-setting
38
- .sidebar-mode-setting-title 模式
38
+ .sidebar-mode-setting-title 選單模式
39
39
  SLIOSSwitch(
40
40
  :modelValue="dark"
41
41
  trueLabel="深色"
42
42
  minTrueLabel="深"
43
43
  falseLabel="淺色"
44
44
  minFalseLabel="淺"
45
- :size="closuredProxy ? 'min' : ''"
45
+ :size="closuredProxy ? 'min' : 'xs'"
46
46
  :color='switchColor'
47
47
  @update:modelValue="onUpdatedMode"
48
48
  )
@@ -51,7 +51,7 @@
51
51
  SLIcon(icon="chevron-right")
52
52
  .sidebar-nav-intro(ref='introEl')
53
53
  .sidebar-nav-intro-header {{ navLinkIntro ? navLinkIntro.title : '' }}
54
- .sidebar-nav-intro-body {{ navLinkIntro ? navLinkIntro.content : ''}}
54
+ .sidebar-nav-intro-body {{ navLinkIntro ? navLinkIntro.content : '' }}
55
55
  .sidebar-nav-intro-footer
56
56
  SLButton(
57
57
  title='我知道了',
@@ -81,7 +81,7 @@ export default defineComponent({
81
81
  },
82
82
  config: {
83
83
  type: Array as PropType<NavConfigType>,
84
- default: () => [],
84
+ default: () => [],
85
85
  },
86
86
  navIntros: {
87
87
  type: Array as PropType<{
@@ -116,7 +116,7 @@ export default defineComponent({
116
116
 
117
117
  function onClickedToggle() {
118
118
  if (introing.value) return;
119
-
119
+
120
120
  closuredProxy.value = !closuredProxy.value;
121
121
  }
122
122
 
@@ -287,7 +287,7 @@ export default defineComponent({
287
287
  @apply bg-nav-color-switch-bg border-primary-600
288
288
 
289
289
  &:before
290
- @apply border-2 border-primary-600 bg-primary-300
290
+ @apply border-primary-600 bg-primary-300
291
291
 
292
292
  .sidebar-toggle
293
293
  @apply bg-primary-900 text-white
@@ -373,19 +373,19 @@ export default defineComponent({
373
373
  @apply w-full h-px my-2 bg-primary-200
374
374
 
375
375
  .sidebar-mode-setting
376
- @apply flex-grow-0 flex-shrink-0 flex items-center justify-end my-4 pr-4 s('pl-[42px]') space-x-2 text-base text-primary
376
+ @apply flex-grow-0 flex-shrink-0 flex items-center justify-start my-4 pl-4 space-x-2 text-xs text-primary
377
377
 
378
378
  &-title
379
379
  @apply flex-grow-0 flex-shrink-0
380
380
 
381
381
  .ios-switch
382
- @apply flex-grow
382
+ @apply flex-grow-0 flex-shrink-0
383
383
 
384
384
  label
385
385
  @apply border-primary-100 bg-primary-25
386
386
 
387
387
  &:before
388
- @apply border-2 border-primary-100
388
+ @apply border-primary-100
389
389
 
390
390
  &-toggle
391
391
  @apply absolute top-0 right-0 flex justify-center items-center w-5 h-10 s('mt-2.5') bg-primary-50 rounded-l-xl text-sm text-primary-500 leading-none transition-all
@@ -424,5 +424,4 @@ export default defineComponent({
424
424
  &:before
425
425
  content ''
426
426
  @apply visible
427
- </style>
428
-
427
+ </style>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mptw/skylens-ui",
3
3
  "type": "module",
4
- "version": "1.4.79",
4
+ "version": "1.4.81",
5
5
  "main": "./nuxt.config.ts",
6
6
  "scripts": {
7
7
  "dev": "nuxi dev .playground",