@katlux/toolkit 0.1.0-beta.5 → 0.1.0-beta.50

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 (137) hide show
  1. package/dist/compiled/composables/usePresetComponent.mjs +21 -16
  2. package/dist/module.cjs +52 -0
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +52 -0
  5. package/dist/runtime/components/KCalendar/KCalendar.global.d.vue.ts +11 -12
  6. package/dist/runtime/components/KCalendar/KCalendar.global.vue.d.ts +11 -12
  7. package/dist/runtime/components/KCalendar/KCalendar.logic.d.ts +1 -0
  8. package/dist/runtime/components/KCalendar/KCalendar.logic.js +25 -10
  9. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +18 -10
  10. package/dist/runtime/components/KCombobox/KCombobox.global.vue +6 -2
  11. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +18 -10
  12. package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +78 -0
  13. package/dist/runtime/components/KCombobox/KCombobox.logic.js +8 -3
  14. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +149 -0
  15. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue +65 -0
  16. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +149 -0
  17. package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.d.ts +116 -0
  18. package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.js +149 -0
  19. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +56 -8
  20. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +23 -3
  21. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +56 -8
  22. package/dist/runtime/components/KDatePicker/KDatePicker.logic.d.ts +22 -1
  23. package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +89 -7
  24. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +54 -8
  25. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue +23 -3
  26. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +54 -8
  27. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.d.ts +22 -1
  28. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.js +148 -7
  29. package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +18 -0
  30. package/dist/runtime/components/KDropdown/KDropdown.global.vue +13 -4
  31. package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +18 -0
  32. package/dist/runtime/components/KDropdown/KDropdown.logic.d.ts +28 -1
  33. package/dist/runtime/components/KDropdown/KDropdown.logic.js +85 -4
  34. package/dist/runtime/components/KGrid/KGrid.global.d.vue.ts +7 -56
  35. package/dist/runtime/components/KGrid/KGrid.global.vue +9 -2
  36. package/dist/runtime/components/KGrid/KGrid.global.vue.d.ts +7 -56
  37. package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +20 -0
  38. package/dist/runtime/components/KHourPicker/KHourPicker.global.vue +25 -12
  39. package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +20 -0
  40. package/dist/runtime/components/KHourPicker/KHourPicker.logic.d.ts +14 -3
  41. package/dist/runtime/components/KHourPicker/KHourPicker.logic.js +25 -10
  42. package/dist/runtime/components/KHourSelect/KHourSelect.logic.js +4 -1
  43. package/dist/runtime/components/KIcon/KIcon.global.d.vue.ts +1 -1
  44. package/dist/runtime/components/KIcon/KIcon.global.vue.d.ts +1 -1
  45. package/dist/runtime/components/KIcon/KIcon.logic.d.ts +1 -1
  46. package/dist/runtime/components/KIcon/KIcon.logic.js +13 -8
  47. package/dist/runtime/components/KLoader/KLoader.global.d.vue.ts +3 -3
  48. package/dist/runtime/components/KLoader/KLoader.global.vue.d.ts +3 -3
  49. package/dist/runtime/components/KLoader/KLoader.logic.d.ts +8 -1
  50. package/dist/runtime/components/KLoader/KLoader.logic.js +1 -0
  51. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue +1 -1
  52. package/dist/runtime/components/KModal/KModal.global.vue +4 -1
  53. package/dist/runtime/components/KModal/KModal.logic.d.ts +3 -1
  54. package/dist/runtime/components/KModal/KModal.logic.js +6 -2
  55. package/dist/runtime/components/KPanel/KPanel.global.d.vue.ts +5 -28
  56. package/dist/runtime/components/KPanel/KPanel.global.vue +12 -4
  57. package/dist/runtime/components/KPanel/KPanel.global.vue.d.ts +5 -28
  58. package/dist/runtime/components/KPanel/KPanel.logic.d.ts +10 -0
  59. package/dist/runtime/components/KPanel/KPanel.logic.js +8 -0
  60. package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +15 -2
  61. package/dist/runtime/components/KTextbox/KTextbox.global.vue +5 -4
  62. package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +15 -2
  63. package/dist/runtime/components/KTextbox/KTextbox.logic.d.ts +10 -4
  64. package/dist/runtime/components/KTextbox/KTextbox.logic.js +12 -5
  65. package/dist/runtime/components/KTree/KTree.global.d.vue.ts +1 -1
  66. package/dist/runtime/components/KTree/KTree.global.vue.d.ts +1 -1
  67. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +2 -2
  68. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +2 -2
  69. package/dist/runtime/components/KTreePicker/KTreePicker.logic.d.ts +77 -0
  70. package/dist/runtime/composables/usePresetComponent.d.ts +16 -0
  71. package/dist/runtime/composables/usePresetComponent.js +21 -16
  72. package/dist/runtime/presets/default/assets/scss/css-variables.css +64 -13
  73. package/dist/runtime/presets/default/assets/scss/css-variables.scss +286 -0
  74. package/dist/runtime/presets/default/assets/scss/docs.scss +52 -0
  75. package/dist/runtime/presets/default/assets/scss/index.css +72 -13
  76. package/dist/runtime/presets/default/assets/scss/index.scss +12 -0
  77. package/dist/runtime/presets/default/assets/scss/mixins.scss +94 -0
  78. package/dist/runtime/presets/default/assets/scss/reset.scss +16 -0
  79. package/dist/runtime/presets/default/components/KAccordion/KAccordion.vue +5 -2
  80. package/dist/runtime/presets/default/components/KAccordion/KAccordionItem.vue +40 -37
  81. package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue +29 -22
  82. package/dist/runtime/presets/default/components/KButton/KButton.vue +147 -428
  83. package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue +57 -53
  84. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue +189 -161
  85. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue +46 -36
  86. package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +3 -0
  87. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +90 -70
  88. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +3 -0
  89. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue +78 -60
  90. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.d.vue.ts +27 -0
  91. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.vue +190 -0
  92. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.vue.d.ts +27 -0
  93. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +40 -31
  94. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +110 -92
  95. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.d.vue.ts +3 -0
  96. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +44 -25
  97. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue.d.ts +3 -0
  98. package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.d.vue.ts +3 -0
  99. package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.vue +68 -52
  100. package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.vue.d.ts +3 -0
  101. package/dist/runtime/presets/default/components/KDropdown/KDropdown.d.vue.ts +8 -0
  102. package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue +46 -25
  103. package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue.d.ts +8 -0
  104. package/dist/runtime/presets/default/components/KGantt/KGantt.vue +337 -241
  105. package/dist/runtime/presets/default/components/KGantt/KGanttRuler.vue +40 -35
  106. package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.vue +170 -140
  107. package/dist/runtime/presets/default/components/KGrid/KGrid.vue +62 -60
  108. package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.d.vue.ts +6 -2
  109. package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.vue +44 -28
  110. package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.vue.d.ts +6 -2
  111. package/dist/runtime/presets/default/components/KHourSelect/KHourSelect.vue +34 -28
  112. package/dist/runtime/presets/default/components/KIcon/KIcon.d.vue.ts +1 -1
  113. package/dist/runtime/presets/default/components/KIcon/KIcon.vue +31 -22
  114. package/dist/runtime/presets/default/components/KIcon/KIcon.vue.d.ts +1 -1
  115. package/dist/runtime/presets/default/components/KLoader/KLoader.vue +53 -47
  116. package/dist/runtime/presets/default/components/KMaskTextbox/KMaskTextbox.vue +113 -84
  117. package/dist/runtime/presets/default/components/KModal/KModal.d.vue.ts +1 -0
  118. package/dist/runtime/presets/default/components/KModal/KModal.vue +64 -35
  119. package/dist/runtime/presets/default/components/KModal/KModal.vue.d.ts +1 -0
  120. package/dist/runtime/presets/default/components/KPagination/KPagination.vue +42 -40
  121. package/dist/runtime/presets/default/components/KPanel/KPanel.d.vue.ts +3 -0
  122. package/dist/runtime/presets/default/components/KPanel/KPanel.vue +95 -34
  123. package/dist/runtime/presets/default/components/KPanel/KPanel.vue.d.ts +3 -0
  124. package/dist/runtime/presets/default/components/KRadiobox/KRadiobox.vue +30 -29
  125. package/dist/runtime/presets/default/components/KRangeSlider/KRangeSlider.vue +158 -125
  126. package/dist/runtime/presets/default/components/KSlider/KSlider.vue +123 -100
  127. package/dist/runtime/presets/default/components/KTabs/KTabItem.vue +40 -37
  128. package/dist/runtime/presets/default/components/KTabs/KTabs.vue +9 -6
  129. package/dist/runtime/presets/default/components/KTextarea/KTextarea.vue +23 -20
  130. package/dist/runtime/presets/default/components/KTextbox/KTextbox.d.vue.ts +2 -1
  131. package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue +49 -36
  132. package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue.d.ts +2 -1
  133. package/dist/runtime/presets/default/components/KTree/KTree.vue +102 -80
  134. package/dist/runtime/presets/default/components/KTreePicker/KTreePicker.vue +55 -34
  135. package/dist/runtime/presets/default/components/KTreeView/KTreeCell.vue +31 -30
  136. package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue +34 -27
  137. package/package.json +5 -5
@@ -23,48 +23,50 @@
23
23
  KButton(@click="goToNext" :href="getPageHref(dp.currentPage.value + 1)" size="small" variant="outline") ›
24
24
  </template>
25
25
 
26
- <script setup>
27
- import { computed } from "vue";
28
- const props = defineProps({
29
- dp: { type: null, required: true },
30
- totalPages: { type: Number, required: true },
31
- getPageHref: { type: Function, required: true },
32
- visiblePages: { type: Array, required: true },
33
- showPrevButton: { type: Boolean, required: true },
34
- showNextButton: { type: Boolean, required: true },
35
- showFirstEllipsis: { type: Boolean, required: true },
36
- showLastEllipsis: { type: Boolean, required: true },
37
- pageClicked: { type: Function, required: true },
38
- goToPrev: { type: Function, required: true },
39
- goToNext: { type: Function, required: true },
40
- goToFirst: { type: Function, required: true },
41
- goToLast: { type: Function, required: true }
42
- });
26
+ <script setup lang="ts">
27
+ import { computed } from 'vue'
28
+
29
+ const props = defineProps<{
30
+ dp: any
31
+ totalPages: number
32
+ getPageHref: (page: number) => string | undefined
33
+ visiblePages: number[]
34
+ showPrevButton: boolean
35
+ showNextButton: boolean
36
+ showFirstEllipsis: boolean
37
+ showLastEllipsis: boolean
38
+ pageClicked: (item: number) => void
39
+ goToPrev: () => void
40
+ goToNext: () => void
41
+ goToFirst: () => void
42
+ goToLast: () => void
43
+ }>()
43
44
  </script>
44
45
 
45
- <style scoped>
46
+ <style lang="scss" scoped>
46
47
  .k-pagination {
47
- text-align: right;
48
- }
49
- .k-pagination ul {
50
- list-style-type: none;
51
- padding: 0px;
52
- margin: 0px;
53
- display: flex;
54
- flex-direction: row;
55
- flex-wrap: wrap;
56
- align-content: center;
57
- justify-content: flex-end;
58
- gap: 5px;
59
- }
60
- .k-pagination ul li {
61
- display: flex;
62
- align-items: center;
63
- }
64
- .k-pagination ul li .ellipsis {
65
- padding: 8px 12px;
66
- color: #666;
67
- font-weight: bold;
68
- user-select: none;
48
+ text-align: right;
49
+ ul {
50
+ list-style-type: none;
51
+ padding: 0px;
52
+ margin: 0px;
53
+ display: flex;
54
+ flex-direction: row;
55
+ flex-wrap: wrap;
56
+ align-content: center;
57
+ justify-content: flex-end;
58
+ gap: 5px;
59
+ li {
60
+ display: flex;
61
+ align-items: center;
62
+
63
+ .ellipsis {
64
+ padding: 8px 12px;
65
+ color: #666;
66
+ font-weight: bold;
67
+ user-select: none;
68
+ }
69
+ }
70
+ }
69
71
  }
70
72
  </style>
@@ -2,8 +2,11 @@ type __VLS_Props = {
2
2
  noGap?: boolean;
3
3
  flexContent?: boolean;
4
4
  scrollable?: boolean;
5
+ type?: 'default' | 'primary' | 'danger' | 'success' | 'warning' | 'info';
6
+ title?: string;
5
7
  };
6
8
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
9
+ type: "default" | "primary" | "danger" | "success" | "warning" | "info";
7
10
  noGap: boolean;
8
11
  flexContent: boolean;
9
12
  scrollable: boolean;
@@ -1,47 +1,108 @@
1
1
  <template lang="pug">
2
- .KPanel
2
+ .KPanel(:class="[`type-${type}`]")
3
3
  KGrid(direction="column" align="strech" :no-gap="noGap" wrap="nowrap").full-height
4
- .KPanel--header(v-if="$slots.header")
5
- slot(name="header")
4
+ .KPanel--header(v-if="$slots.header || title")
5
+ slot(name="header") {{ title }}
6
6
  .KPanel--content(:class="{'flex-content': flexContent, 'scrollable': scrollable}")
7
7
  slot
8
8
  .KPanel--footer(v-if="$slots.footer")
9
9
  slot(name="footer")
10
10
  </template>
11
11
 
12
- <script setup>
13
- const props = defineProps({
14
- noGap: { type: Boolean, required: false, default: false },
15
- flexContent: { type: Boolean, required: false, default: false },
16
- scrollable: { type: Boolean, required: false, default: false }
17
- });
12
+ <script lang="ts" setup>
13
+ const props = withDefaults(defineProps<{
14
+ noGap?: boolean
15
+ flexContent?: boolean
16
+ scrollable?: boolean
17
+ type?: 'default' | 'primary' | 'danger' | 'success' | 'warning' | 'info'
18
+ title?: string
19
+ }>(), {
20
+ scrollable: false,
21
+ noGap: true,
22
+ flexContent: false,
23
+ type: 'default'
24
+ })
18
25
  </script>
19
26
 
20
- <style scoped>
27
+ <style lang="scss" scoped>
21
28
  .KPanel {
22
- border-radius: var(--box-border-radius);
23
- border: var(--box-border);
24
- box-shadow: var(--box-shadow);
25
- background-color: var(--background-color-light);
26
- width: 100%;
27
- }
28
- .KPanel .full-height {
29
- height: 100%;
30
- }
31
- .KPanel--header {
32
- padding: var(--component-gap);
33
- background-color: var(--background-color-medium);
34
- }
35
- .KPanel--content {
36
- padding: var(--box-padding);
37
- }
38
- .KPanel--content.scrollable {
39
- overflow-y: auto;
40
- }
41
- .KPanel--content.flex-content {
42
- flex-grow: 1;
43
- }
44
- .KPanel--footer {
45
- padding: var(--box-padding);
29
+ --current-panel-bg: var(--panel-bg-default);
30
+ --current-panel-header-bg: var(--panel-header-bg-default);
31
+ --current-panel-footer-bg: var(--panel-footer-bg-default);
32
+
33
+ border-radius: var(--border-radius-lg);
34
+ border: 1px solid var(--neutral-200);
35
+ box-shadow: var(--shadow-md);
36
+ background-color: color-mix(in srgb, var(--current-panel-bg), transparent calc((1 - var(--panel-bg-opacity)) * 100%));
37
+ backdrop-filter: blur(var(--panel-blur));
38
+ width: 100%;
39
+ display: flex;
40
+ flex-direction: column;
41
+ overflow: hidden;
42
+ transition: transform var(--transition-normal), box-shadow var(--transition-normal);
43
+
44
+ &.type-primary {
45
+ --current-panel-bg: var(--panel-bg-primary);
46
+ --current-panel-header-bg: var(--panel-header-bg-primary);
47
+ --current-panel-footer-bg: var(--panel-footer-bg-primary);
48
+ }
49
+ &.type-success {
50
+ --current-panel-bg: var(--panel-bg-success);
51
+ --current-panel-header-bg: var(--panel-header-bg-success);
52
+ --current-panel-footer-bg: var(--panel-footer-bg-success);
53
+ }
54
+ &.type-warning {
55
+ --current-panel-bg: var(--panel-bg-warning);
56
+ --current-panel-header-bg: var(--panel-header-bg-warning);
57
+ --current-panel-footer-bg: var(--panel-footer-bg-warning);
58
+ }
59
+ &.type-danger {
60
+ --current-panel-bg: var(--panel-bg-danger);
61
+ --current-panel-header-bg: var(--panel-header-bg-danger);
62
+ --current-panel-footer-bg: var(--panel-footer-bg-danger);
63
+ }
64
+ &.type-info {
65
+ --current-panel-bg: var(--panel-bg-info);
66
+ --current-panel-header-bg: var(--panel-header-bg-info);
67
+ --current-panel-footer-bg: var(--panel-footer-bg-info);
68
+ }
69
+
70
+ &:hover {
71
+ transform: translateY(-2px);
72
+ box-shadow: var(--shadow-lg);
73
+ }
74
+
75
+ .full-height {
76
+ height: 100%;
77
+ }
78
+
79
+ &--header {
80
+ padding: var(--gap-md);
81
+ background-color: color-mix(in srgb, var(--current-panel-header-bg), transparent 92%);
82
+ border-bottom: 1px solid var(--neutral-200);
83
+ font-weight: var(--font-weight-semibold);
84
+ color: var(--font-color-heading);
85
+ font-size: var(--font-size-lg);
86
+ }
87
+
88
+ &--content {
89
+ padding: var(--gap-md);
90
+ flex: 1;
91
+
92
+ &.scrollable {
93
+ overflow-y: auto;
94
+ }
95
+
96
+ &.flex-content {
97
+ display: flex;
98
+ flex-direction: column;
99
+ }
100
+ }
101
+
102
+ &--footer {
103
+ padding: var(--gap-md);
104
+ background-color: color-mix(in srgb, var(--current-panel-footer-bg), transparent 92%);
105
+ border-top: 1px solid var(--neutral-200);
106
+ }
46
107
  }
47
108
  </style>
@@ -2,8 +2,11 @@ type __VLS_Props = {
2
2
  noGap?: boolean;
3
3
  flexContent?: boolean;
4
4
  scrollable?: boolean;
5
+ type?: 'default' | 'primary' | 'danger' | 'success' | 'warning' | 'info';
6
+ title?: string;
5
7
  };
6
8
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
9
+ type: "default" | "primary" | "danger" | "success" | "warning" | "info";
7
10
  noGap: boolean;
8
11
  flexContent: boolean;
9
12
  scrollable: boolean;
@@ -7,37 +7,38 @@ label.KRadiobox
7
7
  slot
8
8
  </template>
9
9
 
10
- <script setup>
11
- defineProps({
12
- model: { type: null, required: true },
13
- label: { type: String, required: false },
14
- value: { type: String, required: false },
15
- disabled: { type: Boolean, required: false }
16
- });
17
- const model = defineModel();
10
+ <script lang="ts" setup>
11
+ defineProps<{
12
+ model: any
13
+ label?: string
14
+ value?: string
15
+ disabled?: boolean
16
+ }>()
17
+
18
+ const model = defineModel()
18
19
  </script>
19
20
 
20
- <style scoped>
21
+ <style lang="scss" scoped>
21
22
  .KRadiobox {
22
- display: flex;
23
- gap: 5px;
24
- }
25
- .KRadiobox input {
26
- display: none;
27
- }
28
- .KRadiobox .icon-container {
29
- border: var(--input-border);
30
- width: var(--box-padding);
31
- height: var(--box-padding);
32
- text-align: center;
33
- line-height: var(--box-padding);
34
- border-radius: var(--input-border-radius);
35
- background-color: var(--checkbox-bg);
36
- }
37
- .KRadiobox .icon {
38
- display: none;
39
- }
40
- .KRadiobox :checked + .icon-container > .icon {
41
- display: block;
23
+ display: flex;
24
+ gap: 5px;
25
+ input {
26
+ display: none;
27
+ }
28
+ .icon-container {
29
+ border: var(--input-border);
30
+ width: var(--box-padding);
31
+ height: var(--box-padding);
32
+ text-align: center;
33
+ line-height: var(--box-padding);
34
+ border-radius: var(--input-border-radius);
35
+ background-color: var(--checkbox-bg);
36
+ }
37
+ .icon {
38
+ display: none;
39
+ }
40
+ :checked + .icon-container > .icon {
41
+ display: block;
42
+ }
42
43
  }
43
44
  </style>
@@ -23,134 +23,167 @@
23
23
  )
24
24
  </template>
25
25
 
26
- <script setup>
27
- import { computed } from "vue";
28
- const props = defineProps({
29
- rangeMin: { type: Number, required: true },
30
- rangeMax: { type: Number, required: true },
31
- rangeStep: { type: Number, required: true },
32
- isDisabled: { type: Boolean, required: true },
33
- currentMinValue: { type: Number, required: true },
34
- currentMaxValue: { type: Number, required: true },
35
- minPercent: { type: Number, required: true },
36
- maxPercent: { type: Number, required: true }
37
- });
38
- const emit = defineEmits(["update:minValue", "update:maxValue"]);
39
- const updateMinValue = (event) => {
40
- const value = parseFloat(event.target.value);
41
- if (value <= props.currentMaxValue) {
42
- emit("update:minValue", value);
43
- }
44
- };
45
- const updateMaxValue = (event) => {
46
- const value = parseFloat(event.target.value);
47
- if (value >= props.currentMinValue) {
48
- emit("update:maxValue", value);
49
- }
50
- };
51
- const handleTrackClick = (event) => {
52
- if (props.isDisabled) return;
53
- const target = event.currentTarget;
54
- const rect = target.getBoundingClientRect();
55
- const clickX = event.clientX - rect.left;
56
- const percentage = clickX / rect.width;
57
- const rawValue = props.rangeMin + percentage * (props.rangeMax - props.rangeMin);
58
- const steppedValue = Math.round(rawValue / props.rangeStep) * props.rangeStep;
59
- const value = Math.max(props.rangeMin, Math.min(props.rangeMax, steppedValue));
60
- const distanceToMin = Math.abs(value - props.currentMinValue);
61
- const distanceToMax = Math.abs(value - props.currentMaxValue);
62
- if (distanceToMin < distanceToMax) {
63
- if (value <= props.currentMaxValue) {
64
- emit("update:minValue", value);
65
- }
66
- } else {
67
- if (value >= props.currentMinValue) {
68
- emit("update:maxValue", value);
69
- }
70
- }
71
- };
72
- </script>
26
+ <script lang="ts" setup>
27
+ import { computed } from 'vue'
73
28
 
74
- <style scoped>
75
- .KRangeSlider {
76
- position: relative;
77
- padding: 20px 0;
78
- }
79
- .KRangeSlider.disabled {
80
- opacity: 0.5;
81
- cursor: not-allowed;
82
- }
83
- .KRangeSlider .slider-container {
84
- position: relative;
85
- height: 6px;
86
- cursor: pointer;
87
- }
88
- .KRangeSlider .slider-track {
89
- position: absolute;
90
- width: 100%;
91
- height: 6px;
92
- background-color: var(--neutral-200);
93
- border-radius: 3px;
94
- }
95
- .KRangeSlider .slider-range {
96
- position: absolute;
97
- height: 6px;
98
- background-color: var(--primary-500);
99
- border-radius: 3px;
100
- z-index: 1;
101
- }
102
- .KRangeSlider .slider-input {
103
- position: absolute;
104
- width: 100%;
105
- height: 1px;
106
- background: transparent;
107
- pointer-events: none;
108
- -webkit-appearance: none;
109
- appearance: none;
110
- }
111
- .KRangeSlider .slider-input::-webkit-slider-thumb {
112
- -webkit-appearance: none;
113
- appearance: none;
114
- width: 18px;
115
- height: 18px;
116
- background-color: var(--primary-500);
117
- border: 2px solid white;
118
- border-radius: 50%;
119
- cursor: pointer;
120
- pointer-events: auto;
121
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
122
- transition: transform 0.15s ease;
123
- }
124
- .KRangeSlider .slider-input::-webkit-slider-thumb:hover {
125
- transform: scale(1.15);
126
- }
127
- .KRangeSlider .slider-input::-moz-range-thumb {
128
- width: 18px;
129
- height: 18px;
130
- background-color: var(--primary-500);
131
- border: 2px solid white;
132
- border-radius: 50%;
133
- cursor: pointer;
134
- pointer-events: auto;
135
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
136
- transition: transform 0.15s ease;
137
- }
138
- .KRangeSlider .slider-input::-moz-range-thumb:hover {
139
- transform: scale(1.15);
140
- }
141
- .KRangeSlider .slider-input:disabled {
142
- cursor: not-allowed;
143
- }
144
- .KRangeSlider .slider-input:disabled::-webkit-slider-thumb {
145
- cursor: not-allowed;
29
+ // Default template for KRangeSlider
30
+ const props = defineProps<{
31
+ rangeMin: number
32
+ rangeMax: number
33
+ rangeStep: number
34
+ isDisabled: boolean
35
+ currentMinValue: number
36
+ currentMaxValue: number
37
+ minPercent: number
38
+ maxPercent: number
39
+ }>()
40
+
41
+ const emit = defineEmits<{
42
+ (e: 'update:minValue', value: number): void
43
+ (e: 'update:maxValue', value: number): void
44
+ }>()
45
+
46
+ const updateMinValue = (event: Event) => {
47
+ const value = parseFloat((event.target as HTMLInputElement).value)
48
+ // Ensure min doesn't exceed max
49
+ if (value <= props.currentMaxValue) {
50
+ emit('update:minValue', value)
51
+ }
146
52
  }
147
- .KRangeSlider .slider-input:disabled::-moz-range-thumb {
148
- cursor: not-allowed;
53
+
54
+ const updateMaxValue = (event: Event) => {
55
+ const value = parseFloat((event.target as HTMLInputElement).value)
56
+ // Ensure max doesn't go below min
57
+ if (value >= props.currentMinValue) {
58
+ emit('update:maxValue', value)
59
+ }
149
60
  }
150
- .KRangeSlider .slider-min {
151
- z-index: 3;
61
+
62
+ const handleTrackClick = (event: MouseEvent) => {
63
+ if (props.isDisabled) return
64
+
65
+ const target = event.currentTarget as HTMLElement
66
+ const rect = target.getBoundingClientRect()
67
+ const clickX = event.clientX - rect.left
68
+ const percentage = clickX / rect.width
69
+ const rawValue = props.rangeMin + (percentage * (props.rangeMax - props.rangeMin))
70
+
71
+ // Round to step
72
+ const steppedValue = Math.round(rawValue / props.rangeStep) * props.rangeStep
73
+ const value = Math.max(props.rangeMin, Math.min(props.rangeMax, steppedValue))
74
+
75
+ // Determine which handle is closer
76
+ const distanceToMin = Math.abs(value - props.currentMinValue)
77
+ const distanceToMax = Math.abs(value - props.currentMaxValue)
78
+
79
+ if (distanceToMin < distanceToMax) {
80
+ // Move min handle
81
+ if (value <= props.currentMaxValue) {
82
+ emit('update:minValue', value)
83
+ }
84
+ } else {
85
+ // Move max handle
86
+ if (value >= props.currentMinValue) {
87
+ emit('update:maxValue', value)
88
+ }
89
+ }
152
90
  }
153
- .KRangeSlider .slider-max {
154
- z-index: 4;
91
+ </script>
92
+
93
+ <style lang="scss" scoped>
94
+ .KRangeSlider {
95
+ position: relative;
96
+ padding: 20px 0;
97
+
98
+ &.disabled {
99
+ opacity: 0.5;
100
+ cursor: not-allowed;
101
+ }
102
+
103
+ .slider-container {
104
+ position: relative;
105
+ height: 6px;
106
+ cursor: pointer;
107
+ }
108
+
109
+ .slider-track {
110
+ position: absolute;
111
+ width: 100%;
112
+ height: 6px;
113
+ background-color: var(--neutral-200);
114
+ border-radius: 3px;
115
+ }
116
+
117
+ .slider-range {
118
+ position: absolute;
119
+ height: 6px;
120
+ background-color: var(--primary-500);
121
+ border-radius: 3px;
122
+ z-index: 1;
123
+ }
124
+
125
+ .slider-input {
126
+ position: absolute;
127
+ width: 100%;
128
+ height: 1px;
129
+ background: transparent;
130
+ pointer-events: none;
131
+ -webkit-appearance: none;
132
+ appearance: none;
133
+
134
+ &::-webkit-slider-thumb {
135
+ -webkit-appearance: none;
136
+ appearance: none;
137
+ width: 18px;
138
+ height: 18px;
139
+ background-color: var(--primary-500);
140
+ border: 2px solid white;
141
+ border-radius: 50%;
142
+ cursor: pointer;
143
+ pointer-events: auto;
144
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
145
+ transition: transform 0.15s ease;
146
+
147
+ &:hover {
148
+ transform: scale(1.15);
149
+ }
150
+ }
151
+
152
+ &::-moz-range-thumb {
153
+ width: 18px;
154
+ height: 18px;
155
+ background-color: var(--primary-500);
156
+ border: 2px solid white;
157
+ border-radius: 50%;
158
+ cursor: pointer;
159
+ pointer-events: auto;
160
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
161
+ transition: transform 0.15s ease;
162
+
163
+ &:hover {
164
+ transform: scale(1.15);
165
+ }
166
+ }
167
+
168
+ &:disabled {
169
+ cursor: not-allowed;
170
+
171
+ &::-webkit-slider-thumb {
172
+ cursor: not-allowed;
173
+ }
174
+
175
+ &::-moz-range-thumb {
176
+ cursor: not-allowed;
177
+ }
178
+ }
179
+ }
180
+
181
+ .slider-min {
182
+ z-index: 3;
183
+ }
184
+
185
+ .slider-max {
186
+ z-index: 4;
187
+ }
155
188
  }
156
189
  </style>