yuyeon 0.0.0

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 (77) hide show
  1. package/package.json +38 -0
  2. package/src/components/button/index.ts +3 -0
  3. package/src/components/button/y-btn.scss +79 -0
  4. package/src/components/button/y-btn.ts +104 -0
  5. package/src/components/card/index.ts +6 -0
  6. package/src/components/card/y-card-body.ts +8 -0
  7. package/src/components/card/y-card-footer.ts +8 -0
  8. package/src/components/card/y-card-header.ts +8 -0
  9. package/src/components/card/y-card.scss +30 -0
  10. package/src/components/card/y-card.ts +16 -0
  11. package/src/components/checkbox/IconCheckbox.vue +24 -0
  12. package/src/components/checkbox/YCheckbox.vue +113 -0
  13. package/src/components/checkbox/YInputCheckbox.vue +108 -0
  14. package/src/components/checkbox/index.ts +8 -0
  15. package/src/components/checkbox/y-checkbox.scss +48 -0
  16. package/src/components/checkbox/y-input-checkbox.scss +86 -0
  17. package/src/components/chip/index.ts +3 -0
  18. package/src/components/chip/y-chip.scss +28 -0
  19. package/src/components/chip/y-chip.vue +69 -0
  20. package/src/components/dialog/index.ts +3 -0
  21. package/src/components/dialog/y-dialog.scss +5 -0
  22. package/src/components/dialog/y-dialog.vue +46 -0
  23. package/src/components/field-input/index.scss +5 -0
  24. package/src/components/field-input/index.ts +11 -0
  25. package/src/components/field-input/y-field-input.scss +65 -0
  26. package/src/components/field-input/y-field-input.ts +214 -0
  27. package/src/components/form/index.ts +9 -0
  28. package/src/components/form/y-form.ts +93 -0
  29. package/src/components/icons/icon-clearable.ts +6 -0
  30. package/src/components/index.ts +17 -0
  31. package/src/components/input/index.scss +5 -0
  32. package/src/components/input/index.ts +9 -0
  33. package/src/components/input/y-input.scss +209 -0
  34. package/src/components/input/y-input.ts +368 -0
  35. package/src/components/layer/index.ts +3 -0
  36. package/src/components/layer/y-layer.scss +32 -0
  37. package/src/components/layer/y-layer.vue +146 -0
  38. package/src/components/lottie-player.ts +41 -0
  39. package/src/components/progress-bar/index.ts +3 -0
  40. package/src/components/progress-bar/y-progress-bar.vue +144 -0
  41. package/src/components/ring-spinner/y-ring-spinner.scss +25 -0
  42. package/src/components/ring-spinner/y-ring-spinner.vue +31 -0
  43. package/src/components/switch/YSwitch.vue +217 -0
  44. package/src/components/switch/index.scss +5 -0
  45. package/src/components/switch/index.ts +11 -0
  46. package/src/components/switch/y-switch.scss +206 -0
  47. package/src/components/text-highlighter/index.scss +5 -0
  48. package/src/components/text-highlighter/index.ts +3 -0
  49. package/src/components/text-highlighter/y-text-highlighter.scss +7 -0
  50. package/src/components/text-highlighter/y-text-highlighter.ts +89 -0
  51. package/src/composables/layer-group.ts +31 -0
  52. package/src/composables/lazy.ts +30 -0
  53. package/src/composables/progress.ts +19 -0
  54. package/src/composables/theme.ts +25 -0
  55. package/src/directives/complement-click/index.ts +123 -0
  56. package/src/directives/plate-wave/index.ts +114 -0
  57. package/src/directives/plate-wave/plate-wave.scss +33 -0
  58. package/src/directives/theme-class.ts +14 -0
  59. package/src/file-extension.d.ts +14 -0
  60. package/src/index.ts +21 -0
  61. package/src/mixins/di.ts +23 -0
  62. package/src/mixins/rebind-attrs.ts +36 -0
  63. package/src/styles/base.scss +28 -0
  64. package/src/styles/palette.scss +94 -0
  65. package/src/styles/theme/dark.scss +35 -0
  66. package/src/styles/theme/index.scss +8 -0
  67. package/src/styles/theme/light.scss +32 -0
  68. package/src/styles/util/helper.scss +6 -0
  69. package/src/styles/util/theme.scss +16 -0
  70. package/src/styles/variables.scss +1 -0
  71. package/src/util/common.ts +59 -0
  72. package/src/util/date-time.ts +41 -0
  73. package/src/util/dom.ts +6 -0
  74. package/src/util/string.ts +9 -0
  75. package/src/util/ui.ts +39 -0
  76. package/src/util/validation.ts +9 -0
  77. package/src/util/vue-component.ts +18 -0
@@ -0,0 +1,146 @@
1
+ <template>
2
+ <Teleport :to="layerGroup" :disabled="!layerGroup">
3
+ <template v-if="rendered">
4
+ <div class="y-layer" :class="computedClass" :style="computedStyle">
5
+ <Transition name="fade" appear>
6
+ <div
7
+ v-if="active && scrim"
8
+ class="y-layer__scrim"
9
+ @click="onClickScrim"
10
+ ref="scrimElement"
11
+ ></div>
12
+ </Transition>
13
+ <Transition name="slide-fade" @after-leave="onAfterLeave" appear>
14
+ <div
15
+ v-show="active"
16
+ v-complement-click="complementClickOption"
17
+ class="y-layer__content"
18
+ >
19
+ <slot :active="active"></slot>
20
+ </div>
21
+ </Transition>
22
+ </div>
23
+ </template>
24
+ </Teleport>
25
+ </template>
26
+
27
+ <script lang="ts">
28
+ import {
29
+ computed,
30
+ defineComponent,
31
+ PropType,
32
+ inject,
33
+ reactive,
34
+ ref
35
+ } from "vue";
36
+ import { useLayerGroup } from '../../composables/layer-group';
37
+
38
+ import './y-layer.scss';
39
+ import { useLazy } from '../../composables/lazy';
40
+ import {
41
+ ComplementClick,
42
+ ComplementClickBindingOptions,
43
+ } from '../../directives/complement-click';
44
+
45
+ export default defineComponent({
46
+ name: 'YLayer',
47
+ inheritAttrs: false,
48
+ directives: {
49
+ ComplementClick,
50
+ },
51
+ props: {
52
+ modelValue: {
53
+ type: Boolean as PropType<boolean>,
54
+ },
55
+ scrim: {
56
+ type: Boolean as PropType<boolean>,
57
+ },
58
+ contentTagDialog: {
59
+ type: Boolean as PropType<boolean>,
60
+ },
61
+ eager: {
62
+ type: Boolean as PropType<boolean>,
63
+ },
64
+ class: {
65
+ type: [Array, String, Object] as PropType<
66
+ string[] | string | Record<string, boolean>
67
+ >,
68
+ },
69
+ closeClickScrim: {
70
+ type: Boolean as PropType<boolean>,
71
+ },
72
+ persistent: Boolean as PropType<boolean>,
73
+ },
74
+ emits: {
75
+ 'update:modelValue': (value: boolean) => true,
76
+ 'click:complement': (mouseEvent: MouseEvent) => true,
77
+ },
78
+ setup(props: any, { emit }) {
79
+ const { layerGroup } = useLayerGroup();
80
+ const active = computed({
81
+ get: () => {
82
+ return props.modelValue;
83
+ },
84
+ set: (v: boolean) => {
85
+ emit('update:modelValue', v);
86
+ },
87
+ });
88
+ const { lazyValue, onAfterUpdate } = useLazy(props.eager, active);
89
+ const rendered = computed(() => lazyValue.value || active.value);
90
+ const poly = inject('poly');
91
+ const scrimElement = ref<HTMLElement | null>(null);
92
+ function onClickComplementLayer(mouseEvent: MouseEvent) {
93
+ emit('click:complement', mouseEvent);
94
+ if (!props.persistent) {
95
+ if (scrimElement.value !== null && scrimElement.value === mouseEvent.target && props.closeClickScrim) {
96
+ active.value = false;
97
+ }
98
+ } else {
99
+ // TODO: shrug ani
100
+ }
101
+ }
102
+ function closeConditional(): boolean {
103
+ return active.value; // TODO: && groupTopLevel.value;
104
+ }
105
+ const complementClickOption = reactive<ComplementClickBindingOptions>({
106
+ handler: onClickComplementLayer,
107
+ determine: closeConditional,
108
+ include: () => [
109
+ // activatorEl.value
110
+ ],
111
+ });
112
+ return {
113
+ complementClickOption,
114
+ layerGroup,
115
+ active,
116
+ rendered,
117
+ onAfterUpdate,
118
+ poly,
119
+ scrimElement,
120
+ };
121
+ },
122
+ methods: {
123
+ onAfterLeave() {
124
+ this.onAfterUpdate();
125
+ },
126
+ onClickScrim() {
127
+ if (this.closeClickScrim) {
128
+ this.active = false;
129
+ }
130
+ },
131
+ },
132
+ computed: {
133
+ computedStyle(): any {
134
+ return {
135
+ zIndex: '2000',
136
+ };
137
+ },
138
+ computedClass(): any {
139
+ return {
140
+ 'y-layer--active': this.active,
141
+ 'y-dialog': this.poly === 'y-dialog',
142
+ };
143
+ },
144
+ },
145
+ });
146
+ </script>
@@ -0,0 +1,41 @@
1
+ import { defineComponent, h, PropType } from 'vue';
2
+ import lottie, {
3
+ AnimationConfigWithData,
4
+ AnimationConfigWithPath,
5
+ } from 'lottie-web';
6
+
7
+ export default defineComponent({
8
+ name: 'lottie-player',
9
+ props: {
10
+ src: {
11
+ type: [String, Object] as PropType<string | Record<string, any>>,
12
+ },
13
+ loop: {
14
+ type: Boolean as PropType<boolean>,
15
+ default: false,
16
+ },
17
+ autoplay: {
18
+ type: Boolean as PropType<boolean>,
19
+ default: true,
20
+ },
21
+ },
22
+ mounted() {
23
+ const params: AnimationConfigWithPath | AnimationConfigWithData = {
24
+ container: this.$el,
25
+ renderer: 'svg',
26
+ loop: this.loop,
27
+ autoplay: this.autoplay,
28
+ };
29
+ if (this.src) {
30
+ if (typeof this.src === 'string') {
31
+ (params as AnimationConfigWithPath).path = this.src;
32
+ } else {
33
+ (params as AnimationConfigWithData).animationData = this.src;
34
+ }
35
+ lottie.loadAnimation(params);
36
+ }
37
+ },
38
+ render() {
39
+ return h('div', { class: 'lottie-player' });
40
+ },
41
+ });
@@ -0,0 +1,3 @@
1
+ import YProgressBar from './y-progress-bar.vue';
2
+
3
+ export { YProgressBar };
@@ -0,0 +1,144 @@
1
+ <template>
2
+ <div
3
+ class="y-progress y-progress-bar"
4
+ :class="classes"
5
+ role="progressbar"
6
+ aria-valuemin="0"
7
+ aria-valuemax="100"
8
+ :aria-valuenow="numValue"
9
+ :style="{
10
+ '--y-progress-bar__height':
11
+ height !== undefined ? `${height}px` : undefined,
12
+ '--y-progress-bar__outline-color':
13
+ outlineColor !== undefined ? outlineColor : undefined,
14
+ }"
15
+ >
16
+ <div class="y-progress__track"></div>
17
+ <div class="y-progress__tube">
18
+ <div class="y-progress__lead" :style="styles">
19
+ <slot name="lead-inner">
20
+ <div
21
+ v-if="innerText"
22
+ class="y-progress__lead-inner"
23
+ :class="{ 'y-progress__lead-inner--fixed': numValue < 3 }"
24
+ :style="{ color: textColor }"
25
+ >
26
+ <span>{{ numValue }} %</span>
27
+ </div>
28
+ </slot>
29
+ </div>
30
+ </div>
31
+ </div>
32
+ </template>
33
+
34
+ <script lang="ts">
35
+ import { defineComponent, PropType, StyleValue } from 'vue';
36
+ import { useProgress } from '../../composables/progress';
37
+
38
+ export default defineComponent({
39
+ name: 'y-progress-bar',
40
+ props: {
41
+ value: {
42
+ type: Number as PropType<number>,
43
+ },
44
+ rounded: {
45
+ type: Boolean as PropType<boolean>,
46
+ },
47
+ height: {
48
+ type: Number as PropType<number>,
49
+ },
50
+ noRewindTransition: {
51
+ type: Boolean as PropType<boolean>,
52
+ },
53
+ outlined: {
54
+ type: Boolean as PropType<boolean>,
55
+ },
56
+ innerText: {
57
+ type: Boolean as PropType<boolean>,
58
+ },
59
+ textColor: {
60
+ type: String as PropType<string>,
61
+ },
62
+ outlineColor: {
63
+ type: String as PropType<string>,
64
+ },
65
+ },
66
+ setup(props) {
67
+ const { numValue } = useProgress(props);
68
+
69
+ return {
70
+ numValue,
71
+ };
72
+ },
73
+ data() {
74
+ return {
75
+ delta: 0,
76
+ };
77
+ },
78
+ computed: {
79
+ classes(): Record<string, boolean> {
80
+ let noTransition = false;
81
+ if (this.noRewindTransition && this.delta < 0) {
82
+ noTransition = true;
83
+ }
84
+ return {
85
+ 'y-progress--no-trans': noTransition,
86
+ 'y-progress--outlined': this.outlined,
87
+ 'y-progress-bar--rounded': this.rounded,
88
+ };
89
+ },
90
+ styles(): StyleValue {
91
+ let minWidth;
92
+ if (this.innerText && this.numValue < 5 && this.numValue > 0) {
93
+ minWidth = '2rem';
94
+ }
95
+ return {
96
+ transform: `scaleX(${this.numValue / 100})`,
97
+ minWidth,
98
+ };
99
+ },
100
+ },
101
+ });
102
+ </script>
103
+
104
+ <style lang="scss">
105
+ .y-progress {
106
+ --y-progress-bar__height: 4px;
107
+ display: flex;
108
+ position: relative;
109
+ height: var(--y-progress-bar__height, 4px);
110
+
111
+ &-bar--rounded {
112
+ border-radius: calc(var(--y-progress-bar__height) / 2);
113
+ }
114
+
115
+ &--outlined {
116
+ --y-progress-bar__outline-color: var(--y-palette--primary);
117
+ border: 1px solid var(--y-progress-bar__outline-color);
118
+ }
119
+
120
+ &__tube {
121
+ border-radius: inherit;
122
+ overflow: clip;
123
+ min-width: 0;
124
+ flex: 1 1;
125
+ }
126
+
127
+ &__track {
128
+ background-color: #f0f0f0;
129
+ position: absolute;
130
+ inset: 0;
131
+ border-radius: inherit;
132
+ overflow: clip;
133
+ }
134
+
135
+ &__lead {
136
+ width: 100%;
137
+ height: 100%;
138
+ background-color: var(--y-palette--primary);
139
+ position: relative;
140
+ transform-origin: left;
141
+ transition: all 250ms cubic-bezier(0.42, 0.5, 0.51, 1.02);
142
+ }
143
+ }
144
+ </style>
@@ -0,0 +1,25 @@
1
+ .y-ring-spinner {
2
+ transform-origin: center;
3
+ animation: rotate 2s linear infinite;
4
+
5
+ &__circle {
6
+ fill: none;
7
+ stroke: currentColor;
8
+ animation: ring-spinner-dash 1.4s cubic-bezier(0.27, 0.03, 0.5, 1.22)
9
+ infinite;
10
+ }
11
+ }
12
+ @keyframes ring-spinner-dash {
13
+ 0% {
14
+ stroke-dasharray: 1, 200;
15
+ stroke-dashoffset: 0;
16
+ }
17
+ 50% {
18
+ stroke-dasharray: 100, 200;
19
+ stroke-dashoffset: -15px;
20
+ }
21
+ 100% {
22
+ stroke-dasharray: 100, 200;
23
+ stroke-dashoffset: -104px;
24
+ }
25
+ }
@@ -0,0 +1,31 @@
1
+ <template>
2
+ <svg
3
+ class="y-ring-spinner"
4
+ width="48"
5
+ height="48"
6
+ viewBox="0 0 48 48"
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ >
9
+ <circle
10
+ class="y-ring-spinner__circle"
11
+ cx="24"
12
+ cy="24"
13
+ r="18"
14
+ stroke-width="4"
15
+ stroke-dasharray="113.097"
16
+ stroke-dashoffset="113.097"
17
+ />
18
+ </svg>
19
+ </template>
20
+
21
+ <script lang="ts">
22
+ import { defineComponent } from 'vue';
23
+
24
+ import './y-ring-spinner.scss';
25
+
26
+ const NAME = 'y-ring-spinner';
27
+
28
+ export default defineComponent({
29
+ name: NAME,
30
+ });
31
+ </script>
@@ -0,0 +1,217 @@
1
+ <!--
2
+ - Created by yeonyu at 2021-09-23
3
+ -->
4
+
5
+ <template>
6
+ <div class="y-switch" :class="classes">
7
+ <div class="y-switch__slot">
8
+ <div
9
+ class="y-switch__input"
10
+ @click.capture="onClick"
11
+ @keydown="onKeydown"
12
+ >
13
+ <input
14
+ :id="inputId"
15
+ :aria-checked="innerValue"
16
+ type="checkbox"
17
+ role="switch"
18
+ @focus="onFocus"
19
+ @blur="onBlur"
20
+ @change="onChange"
21
+ :disabled="disabled"
22
+ :checked="innerValue"
23
+ ref="checkbox"
24
+ />
25
+ <div class="y-switch__track" :style="trackStyles">
26
+ <div v-if="stateLabel" class="y-switch__state">
27
+ <span class="y-switch__state-label y-switch__state-label--on">
28
+ {{ labelOn }}
29
+ </span>
30
+ <span class="y-switch__state-label y-switch__state-label--off">
31
+ {{ labelOff }}
32
+ </span>
33
+ </div>
34
+ </div>
35
+ <div class="y-switch__thumb">
36
+ <div v-if="loading" class="y-switch__spinner"></div>
37
+ </div>
38
+ </div>
39
+ <label :for="inputId" class="y-switch__label">
40
+ <slot name="label"></slot>
41
+ <input hidden />
42
+ </label>
43
+ </div>
44
+ </div>
45
+ </template>
46
+
47
+ <script lang="ts">
48
+ import { defineComponent, PropType } from 'vue';
49
+
50
+ let uidCounter = 0;
51
+
52
+ export default defineComponent({
53
+ name: 'YSwitch',
54
+ model: {
55
+ prop: 'input',
56
+ event: 'change',
57
+ },
58
+ props: {
59
+ input: {
60
+ type: [Boolean, Array] as PropType<boolean | any[]>,
61
+ default: false,
62
+ },
63
+ value: {
64
+ type: [String, Number, Object] as PropType<any>,
65
+ },
66
+ max: {
67
+ type: Number,
68
+ },
69
+ loading: {
70
+ type: Boolean,
71
+ },
72
+ disabled: {
73
+ type: Boolean,
74
+ },
75
+ stickOut: {
76
+ type: Boolean,
77
+ },
78
+ stateLabel: {
79
+ type: Boolean,
80
+ },
81
+ color: {
82
+ type: String,
83
+ },
84
+ labelOn: {
85
+ type: String,
86
+ default: 'ON',
87
+ },
88
+ labelOff: {
89
+ type: String,
90
+ default: 'OFF',
91
+ },
92
+ },
93
+ data() {
94
+ return {
95
+ innerValue: false,
96
+ counterId: '',
97
+ focused: false,
98
+ };
99
+ },
100
+ created() {
101
+ const iid = uidCounter.toString();
102
+ uidCounter += 1;
103
+ this.counterId = iid;
104
+ if (Array.isArray(this.input)) {
105
+ this.inputByValue();
106
+ } else {
107
+ this.innerValue = this.input;
108
+ }
109
+ },
110
+ computed: {
111
+ isMultipleInput() {
112
+ return Array.isArray(this.input);
113
+ },
114
+ multipleInputIndex() {
115
+ if (!Array.isArray(this.input)) {
116
+ return -1;
117
+ }
118
+ return this.input.findIndex((inp) => {
119
+ return inp === this.value;
120
+ });
121
+ },
122
+ inputId() {
123
+ const id = this.counterId;
124
+ return `y-switch--${id}`;
125
+ },
126
+ trackStyles() {
127
+ return {
128
+ backgroundColor: this.color,
129
+ };
130
+ },
131
+ classes() {
132
+ return {
133
+ 'y-switch--disabled': this.disabled,
134
+ 'y-switch--loading': this.loading,
135
+ 'y-switch--active': this.innerValue,
136
+ 'y-switch--stick-out': this.stickOut,
137
+ 'y-switch--focused': this.focused,
138
+ };
139
+ },
140
+ },
141
+ methods: {
142
+ inputByValue() {
143
+ if (Array.isArray(this.input)) {
144
+ const found = this.input.find((inp: any) => {
145
+ return inp === this.value;
146
+ });
147
+
148
+ if (found !== undefined) {
149
+ this.innerValue = true;
150
+ } else {
151
+ this.innerValue = false;
152
+ }
153
+ }
154
+ },
155
+ changeMultipleInput(checked: boolean) {
156
+ if (Array.isArray(this.input)) {
157
+ const multipleInput = this.input.slice();
158
+ if (
159
+ checked &&
160
+ this.max !== undefined &&
161
+ multipleInput.length >= this.max
162
+ ) {
163
+ this.$emit('overmax');
164
+ this.nextChange(false, multipleInput);
165
+ return;
166
+ }
167
+ if (checked && this.multipleInputIndex < 0) {
168
+ multipleInput.push(this.value);
169
+ } else if (this.multipleInputIndex > -1) {
170
+ multipleInput.splice(this.multipleInputIndex, 1);
171
+ }
172
+ this.$emit('change', multipleInput);
173
+ }
174
+ },
175
+ nextChange(checked: boolean, value: any) {
176
+ this.$nextTick(() => {
177
+ this.innerValue = checked;
178
+ });
179
+ },
180
+ onClick($event: Event) {
181
+ if (this.disabled || this.loading) return;
182
+ this.changeInput(!this.innerValue, $event);
183
+ },
184
+ onFocus() {
185
+ this.focused = true;
186
+ },
187
+ onBlur() {
188
+ this.focused = false;
189
+ },
190
+ onKeydown($event: KeyboardEvent) {
191
+ // nothing
192
+ },
193
+ onChange($event: Event) {
194
+ const $checkbox = $event.target as HTMLInputElement;
195
+ const { checked } = $checkbox;
196
+ this.changeInput(checked, $event);
197
+ },
198
+ changeInput(checked: boolean, event?: Event) {
199
+ this.innerValue = checked;
200
+ if (this.isMultipleInput) {
201
+ this.changeMultipleInput(checked);
202
+ } else {
203
+ this.$emit('change', checked);
204
+ }
205
+ },
206
+ },
207
+ watch: {
208
+ input() {
209
+ this.inputByValue();
210
+ },
211
+ },
212
+ });
213
+ </script>
214
+
215
+ <style lang="scss">
216
+ @import 'index';
217
+ </style>
@@ -0,0 +1,5 @@
1
+ /*!
2
+ * Created by yeonyu 2022.
3
+ */
4
+
5
+ @import 'y-switch';
@@ -0,0 +1,11 @@
1
+ /*
2
+ * Created by yeonyu at 2021-09-30
3
+ */
4
+
5
+ import YSwitch from './YSwitch.vue';
6
+
7
+ export { YSwitch };
8
+
9
+ export default {
10
+ YSwitch,
11
+ };