@katlux/preset-modern 0.1.1-alpha.120 → 0.1.1-alpha.121
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/README.md +37 -120
- package/dist/module.json +1 -1
- package/dist/runtime/components/KDatatable/KDatatable.d.vue.ts +4 -4
- package/dist/runtime/components/KDatatable/KDatatable.vue +19 -3
- package/dist/runtime/components/KDatatable/KDatatable.vue.d.ts +4 -4
- package/dist/runtime/components/KMaskTextbox/KMaskTextbox.vue +1 -76
- package/dist/runtime/components/KRangeSlider/KRangeSlider.vue +18 -35
- package/dist/runtime/components/KSlider/KSlider.vue +11 -18
- package/dist/runtime/components/KTextbox/KTextbox.d.vue.ts +4 -1
- package/dist/runtime/components/KTextbox/KTextbox.vue +23 -10
- package/dist/runtime/components/KTextbox/KTextbox.vue.d.ts +4 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,138 +1,55 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @katlux/preset-modern
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@katlux/preset-modern)
|
|
4
|
+
[](./LICENSE)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
### ✅ KButton
|
|
8
|
-
- Gradient backgrounds for all button types
|
|
9
|
-
- Smooth hover lift animation
|
|
10
|
-
- Enhanced shadows for depth
|
|
11
|
-
- Icon slot support
|
|
12
|
-
- Custom animated loading spinner
|
|
13
|
-
|
|
14
|
-
### ✅ KCheckbox
|
|
15
|
-
- Gradient-filled checkmark on selection
|
|
16
|
-
- Smooth check animation with pop effect
|
|
17
|
-
- Hover glow effect
|
|
18
|
-
- Rounded corners
|
|
19
|
-
- Disabled state styling
|
|
20
|
-
|
|
21
|
-
### ✅ KTextbox
|
|
22
|
-
- Clean, minimal design
|
|
23
|
-
- Focus ring with brand color
|
|
24
|
-
- Animated clear button
|
|
25
|
-
- Smooth transitions
|
|
26
|
-
- Enhanced placeholder styling
|
|
27
|
-
|
|
28
|
-
### ✅ KTextarea
|
|
29
|
-
- Consistent styling with KTextbox
|
|
30
|
-
- Focus ring animation
|
|
31
|
-
- Smooth border transitions
|
|
32
|
-
- Comfortable padding
|
|
33
|
-
- Disabled state support
|
|
34
|
-
|
|
35
|
-
## Design Features
|
|
36
|
-
|
|
37
|
-
### Color Palette
|
|
38
|
-
- Primary: `#667eea` → `#764ba2` (gradient)
|
|
39
|
-
- Focus ring: `rgba(102, 126, 234, 0.1)`
|
|
40
|
-
- Borders: `#e5e7eb` (default), `#667eea` (focus)
|
|
41
|
-
- Text: `#1f2937` (primary), `#9ca3af` (placeholder)
|
|
42
|
-
|
|
43
|
-
### Animations
|
|
44
|
-
- Cubic-bezier easing: `cubic-bezier(0.4, 0, 0.2, 1)`
|
|
45
|
-
- Transition duration: `0.3s` (standard), `0.2s` (quick)
|
|
46
|
-
- Transform effects: lift, scale, pop
|
|
47
|
-
|
|
48
|
-
### Spacing
|
|
49
|
-
- Border radius: `10-14px` (depending on component)
|
|
50
|
-
- Padding: `12-16px`
|
|
51
|
-
- Focus ring: `3px` offset
|
|
52
|
-
- Gaps: `8-12px`
|
|
53
|
-
|
|
54
|
-
## Usage Examples
|
|
55
|
-
|
|
56
|
-
### KButton with Icon
|
|
57
|
-
```vue
|
|
58
|
-
<KButton type="primary">
|
|
59
|
-
<template #icon>
|
|
60
|
-
<Icon name="mdi:check" />
|
|
61
|
-
</template>
|
|
62
|
-
Save Changes
|
|
63
|
-
</KButton>
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### KCheckbox
|
|
67
|
-
```vue
|
|
68
|
-
<KCheckbox v-model="accepted">
|
|
69
|
-
I accept the terms and conditions
|
|
70
|
-
</KCheckbox>
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### KTextbox with Clear
|
|
74
|
-
```vue
|
|
75
|
-
<KTextbox
|
|
76
|
-
v-model="searchQuery"
|
|
77
|
-
placeholder="Search..."
|
|
78
|
-
:showClear="true"
|
|
79
|
-
/>
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### KTextarea
|
|
83
|
-
```vue
|
|
84
|
-
<KTextarea
|
|
85
|
-
v-model="description"
|
|
86
|
-
placeholder="Enter description..."
|
|
87
|
-
:rows="6"
|
|
88
|
-
/>
|
|
89
|
-
```
|
|
6
|
+
Modern design preset and CSS custom property overrides for `@katlux/toolkit` components.
|
|
90
7
|
|
|
91
8
|
## Installation
|
|
92
9
|
|
|
93
|
-
Katlux is a zero-configuration Nuxt module. When you install this preset, the core `@katlux/toolkit` is automatically provisioned for you.
|
|
94
|
-
|
|
95
10
|
### Option 1: Using Nuxt CLI (Recommended)
|
|
96
11
|
```bash
|
|
97
12
|
npx nuxi module add @katlux/preset-modern@alpha
|
|
98
13
|
```
|
|
99
|
-
This single command installs the package and adds it to your `nuxt.config.ts`.
|
|
100
14
|
|
|
101
15
|
### Option 2: Manual Installation
|
|
102
|
-
1. Install via
|
|
103
|
-
```bash
|
|
104
|
-
npm install @katlux/preset-modern@alpha
|
|
105
|
-
```
|
|
16
|
+
1. Install via npm (automatically provisions `@katlux/toolkit` and `@katlux/providers`):
|
|
17
|
+
```bash
|
|
18
|
+
npm install @katlux/preset-modern@alpha
|
|
19
|
+
```
|
|
106
20
|
|
|
107
21
|
2. Register the module in `nuxt.config.ts`:
|
|
108
|
-
```ts
|
|
109
|
-
export default defineNuxtConfig({
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
})
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
- KCombobox
|
|
128
|
-
-
|
|
129
|
-
-
|
|
130
|
-
|
|
131
|
-
|
|
22
|
+
```ts
|
|
23
|
+
export default defineNuxtConfig({
|
|
24
|
+
modules: [
|
|
25
|
+
'@katlux/preset-modern'
|
|
26
|
+
]
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
3. Activate the preset in `app.config.ts`:
|
|
31
|
+
```ts
|
|
32
|
+
export default defineAppConfig({
|
|
33
|
+
katluxToolkit: {
|
|
34
|
+
activePreset: 'modern'
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
- **Full Component Coverage**: Provides styled templates and CSS token overrides across Katlux components (`KButton`, `KCheckbox`, `KRadiobox`, `KCombobox`, `KDatatable`, `KDataIterator`, `KDatePicker`, `KDateTimePicker`, `KModal`, `KPanel`, `KTabs`, `KTextbox`, `KTextarea`, `KTree`, `KTreeView`, `KGantt`, and more).
|
|
42
|
+
- **Composable Preset Cascade**: Uses `[data-preset~="modern"]` attribute selectors without `!important`, allowing seamless runtime switching and layering (e.g. `activePreset: ['dark', 'modern']`).
|
|
43
|
+
- **Virtualization Parity**: `KDatatable` and `KDataIterator` share `useVirtualDataset` for consistent sticky headers, row heights, and selection behavior.
|
|
44
|
+
|
|
45
|
+
## Documentation & Changelog
|
|
46
|
+
|
|
47
|
+
- **Monorepo Repository**: [https://github.com/katlux-ui/KatluxShowcase](https://github.com/katlux-ui/KatluxShowcase)
|
|
48
|
+
- **Changelog & Migration Guide**: [CHANGELOG.md](https://github.com/katlux-ui/KatluxShowcase/blob/dev/CHANGELOG.md)
|
|
132
49
|
|
|
133
50
|
## License & Trademark Policy
|
|
134
51
|
|
|
135
|
-
The code in this repository is completely free and open-source under the Apache 2.0 License.
|
|
136
|
-
However, **Katlux™** and the Katlux logo are unregistered trademarks of the Katlux project.
|
|
52
|
+
The code in this repository is completely free and open-source under the **Apache 2.0 License** (see [LICENSE](./LICENSE)).
|
|
53
|
+
However, **Katlux™** and the Katlux logo are unregistered trademarks of the Katlux project.
|
|
137
54
|
|
|
138
55
|
To protect our users from fraud, you may not use the "Katlux" name or logo to brand your own modified forks, derivative works, or malicious distributions without explicit permission. You are, however, completely free to state "Built with Katlux" in your projects!
|
package/dist/module.json
CHANGED
|
@@ -38,15 +38,15 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
38
38
|
"onUpdate:currentPage"?: ((value: number) => any) | undefined;
|
|
39
39
|
"onUpdate:pageSize"?: ((value: number) => any) | undefined;
|
|
40
40
|
}>, {
|
|
41
|
-
buffer: number;
|
|
42
|
-
bulkActions: Array<IKDatatableAction>;
|
|
43
41
|
selectedRows: any[];
|
|
44
42
|
selectAll: boolean;
|
|
43
|
+
unselectedRows: any[];
|
|
44
|
+
selectAllScope: "page" | "dataset";
|
|
45
|
+
buffer: number;
|
|
46
|
+
bulkActions: Array<IKDatatableAction>;
|
|
45
47
|
viewportHeight: number;
|
|
46
48
|
visibleFields: Array<string> | null;
|
|
47
49
|
rowActions: Array<IKDatatableAction>;
|
|
48
|
-
selectAllScope: "page" | "dataset";
|
|
49
|
-
unselectedRows: any[];
|
|
50
50
|
cellSlots: Record<string, any>;
|
|
51
51
|
headerSlots: Record<string, any>;
|
|
52
52
|
columnHeaders: Record<string, string>;
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
v-for="(row, index) in displayRows"
|
|
48
48
|
:key="getRowKey(row, index)"
|
|
49
49
|
:class="{ 'selected': isRowSelected(row), 'active-focus': focusedIndex === (props.virtualScroll ? startIndex + index : index) }"
|
|
50
|
+
:style="getRowStyle(row, index)"
|
|
50
51
|
)
|
|
51
52
|
td.check-cell(v-if="props.bulkActions && props.bulkActions.length > 0")
|
|
52
53
|
KCheckbox(:model-value="isRowSelected(row)" @update:model-value="toggleRow(row)" :idKey="rowIdKey")
|
|
@@ -206,18 +207,33 @@ const getColumnStyle = (field) => {
|
|
|
206
207
|
if (!w) return void 0;
|
|
207
208
|
return { width: w, whiteSpace: "nowrap" };
|
|
208
209
|
};
|
|
210
|
+
const getRowStyle = (row, index) => {
|
|
211
|
+
if (typeof props.itemHeight !== "function") return void 0;
|
|
212
|
+
const absIndex = props.virtualScroll ? startIndex.value + index : index;
|
|
213
|
+
const h = props.itemHeight(row, absIndex);
|
|
214
|
+
if (typeof h === "number" && Number.isFinite(h) && h > 0) {
|
|
215
|
+
return {
|
|
216
|
+
"--k-datatable-row-height": `${h}px`,
|
|
217
|
+
height: `${h}px`
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
return void 0;
|
|
221
|
+
};
|
|
209
222
|
const rootStyle = computed(() => {
|
|
210
|
-
const
|
|
223
|
+
const styles = {};
|
|
224
|
+
if (typeof props.itemHeight === "number" && props.itemHeight > 0) {
|
|
225
|
+
styles["--k-datatable-row-height"] = `${props.itemHeight}px`;
|
|
226
|
+
}
|
|
211
227
|
if (props.virtualScroll) {
|
|
212
228
|
return {
|
|
213
229
|
...containerCssVars.value,
|
|
214
230
|
"--k-datatable-viewport-height": `${props.viewportHeight || 500}px`,
|
|
215
|
-
|
|
231
|
+
...styles
|
|
216
232
|
};
|
|
217
233
|
}
|
|
218
234
|
return {
|
|
219
235
|
"--page-size": String(effectivePageSize.value),
|
|
220
|
-
|
|
236
|
+
...styles
|
|
221
237
|
};
|
|
222
238
|
});
|
|
223
239
|
const totalColspan = computed(() => {
|
|
@@ -38,15 +38,15 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
38
38
|
"onUpdate:currentPage"?: ((value: number) => any) | undefined;
|
|
39
39
|
"onUpdate:pageSize"?: ((value: number) => any) | undefined;
|
|
40
40
|
}>, {
|
|
41
|
-
buffer: number;
|
|
42
|
-
bulkActions: Array<IKDatatableAction>;
|
|
43
41
|
selectedRows: any[];
|
|
44
42
|
selectAll: boolean;
|
|
43
|
+
unselectedRows: any[];
|
|
44
|
+
selectAllScope: "page" | "dataset";
|
|
45
|
+
buffer: number;
|
|
46
|
+
bulkActions: Array<IKDatatableAction>;
|
|
45
47
|
viewportHeight: number;
|
|
46
48
|
visibleFields: Array<string> | null;
|
|
47
49
|
rowActions: Array<IKDatatableAction>;
|
|
48
|
-
selectAllScope: "page" | "dataset";
|
|
49
|
-
unselectedRows: any[];
|
|
50
50
|
cellSlots: Record<string, any>;
|
|
51
51
|
headerSlots: Record<string, any>;
|
|
52
52
|
columnHeaders: Record<string, string>;
|
|
@@ -10,14 +10,11 @@
|
|
|
10
10
|
:validation="validation"
|
|
11
11
|
:validationText="validationText"
|
|
12
12
|
@update:modelValue="handleUpdate"
|
|
13
|
-
@beforeinput="handleBeforeInput"
|
|
14
13
|
)
|
|
15
14
|
</template>
|
|
16
15
|
|
|
17
16
|
<script setup>
|
|
18
|
-
|
|
19
|
-
import { getMaskPatternDef } from "#toolkit/components/KMaskTextbox/KMaskTextbox.logic";
|
|
20
|
-
const props = defineProps({
|
|
17
|
+
defineProps({
|
|
21
18
|
label: { type: String, required: false },
|
|
22
19
|
maskedValue: { type: String, required: true },
|
|
23
20
|
placeholder: { type: String, required: true },
|
|
@@ -27,78 +24,6 @@ const props = defineProps({
|
|
|
27
24
|
validationText: { type: String, required: false }
|
|
28
25
|
});
|
|
29
26
|
const emit = defineEmits(["update:maskedValue", "clear"]);
|
|
30
|
-
const handleBeforeInput = (event) => {
|
|
31
|
-
if (!event.data || event.inputType !== "insertText") {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const char = event.data;
|
|
35
|
-
if (!/[0-9]/.test(char)) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const target = event.target;
|
|
39
|
-
const cursorPos = target.selectionStart || 0;
|
|
40
|
-
const currentValue = target.value;
|
|
41
|
-
let maskIdx = 0;
|
|
42
|
-
let valIdx = 0;
|
|
43
|
-
while (valIdx < cursorPos && maskIdx < props.mask.length) {
|
|
44
|
-
const def = getMaskPatternDef(props.mask, maskIdx);
|
|
45
|
-
if (def) {
|
|
46
|
-
let consumed = 0;
|
|
47
|
-
while (consumed < def.length && valIdx < currentValue.length) {
|
|
48
|
-
if (def.pattern.test(currentValue[valIdx])) {
|
|
49
|
-
consumed++;
|
|
50
|
-
}
|
|
51
|
-
valIdx++;
|
|
52
|
-
if (valIdx >= cursorPos) break;
|
|
53
|
-
}
|
|
54
|
-
maskIdx += def.length;
|
|
55
|
-
} else {
|
|
56
|
-
valIdx++;
|
|
57
|
-
maskIdx++;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const patternType = props.mask.substring(maskIdx, maskIdx + 4);
|
|
61
|
-
const digit = parseInt(char, 10);
|
|
62
|
-
let digitsInPattern = 0;
|
|
63
|
-
let scanIdx = cursorPos;
|
|
64
|
-
while (scanIdx > 0 && digitsInPattern < 10) {
|
|
65
|
-
scanIdx--;
|
|
66
|
-
const ch = currentValue[scanIdx];
|
|
67
|
-
if (/[0-9]/.test(ch)) {
|
|
68
|
-
digitsInPattern++;
|
|
69
|
-
} else {
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (patternType.startsWith("DD")) {
|
|
74
|
-
if (digitsInPattern === 0) {
|
|
75
|
-
if (digit > 3) event.preventDefault();
|
|
76
|
-
} else if (digitsInPattern === 1) {
|
|
77
|
-
const firstDigit = parseInt(currentValue[cursorPos - 1], 10);
|
|
78
|
-
if (firstDigit === 0 && digit === 0) event.preventDefault();
|
|
79
|
-
if (firstDigit === 3 && digit > 1) event.preventDefault();
|
|
80
|
-
}
|
|
81
|
-
} else if (patternType.startsWith("MM")) {
|
|
82
|
-
if (digitsInPattern === 0) {
|
|
83
|
-
if (digit > 1) event.preventDefault();
|
|
84
|
-
} else if (digitsInPattern === 1) {
|
|
85
|
-
const firstDigit = parseInt(currentValue[cursorPos - 1], 10);
|
|
86
|
-
if (firstDigit === 0 && digit === 0) event.preventDefault();
|
|
87
|
-
if (firstDigit === 1 && digit > 2) event.preventDefault();
|
|
88
|
-
}
|
|
89
|
-
} else if (patternType.startsWith("HH")) {
|
|
90
|
-
if (digitsInPattern === 0) {
|
|
91
|
-
if (digit > 2) event.preventDefault();
|
|
92
|
-
} else if (digitsInPattern === 1) {
|
|
93
|
-
const firstDigit = parseInt(currentValue[cursorPos - 1], 10);
|
|
94
|
-
if (firstDigit === 2 && digit > 3) event.preventDefault();
|
|
95
|
-
}
|
|
96
|
-
} else if (patternType.startsWith("mm") || patternType.startsWith("ss")) {
|
|
97
|
-
if (digitsInPattern === 0) {
|
|
98
|
-
if (digit > 5) event.preventDefault();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
27
|
const handleUpdate = (value) => {
|
|
103
28
|
emit("update:maskedValue", value);
|
|
104
29
|
};
|
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
.KRangeSlider(:class="{ disabled: isDisabled }")
|
|
3
3
|
label.k-input-label(v-if="label") {{ label }}
|
|
4
|
-
.slider-container
|
|
4
|
+
.slider-container
|
|
5
5
|
.slider-track
|
|
6
6
|
.slider-range(:style="{ '--range-start': minPercent + '%', '--range-width': (maxPercent - minPercent) + '%' }")
|
|
7
7
|
input.slider-input.slider-min(
|
|
8
|
+
v-model.number="minInputValue"
|
|
8
9
|
type="range"
|
|
9
10
|
:min="rangeMin"
|
|
10
11
|
:max="rangeMax"
|
|
11
12
|
:step="rangeStep"
|
|
12
|
-
:value="currentMinValue"
|
|
13
13
|
:disabled="isDisabled"
|
|
14
|
-
@input="updateMinValue"
|
|
15
14
|
)
|
|
16
15
|
input.slider-input.slider-max(
|
|
16
|
+
v-model.number="maxInputValue"
|
|
17
17
|
type="range"
|
|
18
18
|
:min="rangeMin"
|
|
19
19
|
:max="rangeMax"
|
|
20
20
|
:step="rangeStep"
|
|
21
|
-
:value="currentMaxValue"
|
|
22
21
|
:disabled="isDisabled"
|
|
23
|
-
@input="updateMaxValue"
|
|
24
22
|
)
|
|
25
23
|
</template>
|
|
26
24
|
|
|
@@ -38,39 +36,24 @@ const props = defineProps({
|
|
|
38
36
|
maxPercent: { type: Number, required: true }
|
|
39
37
|
});
|
|
40
38
|
const emit = defineEmits(["update:minValue", "update:maxValue"]);
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const updateMaxValue = (event) => {
|
|
48
|
-
const value = parseFloat(event.target.value);
|
|
49
|
-
if (value >= props.currentMinValue) {
|
|
50
|
-
emit("update:maxValue", value);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const handleTrackClick = (event) => {
|
|
54
|
-
if (props.isDisabled) return;
|
|
55
|
-
const target = event.currentTarget;
|
|
56
|
-
const rect = target.getBoundingClientRect();
|
|
57
|
-
const clickX = event.clientX - rect.left;
|
|
58
|
-
const percentage = clickX / rect.width;
|
|
59
|
-
const rawValue = props.rangeMin + percentage * (props.rangeMax - props.rangeMin);
|
|
60
|
-
const steppedValue = Math.round(rawValue / props.rangeStep) * props.rangeStep;
|
|
61
|
-
const value = Math.max(props.rangeMin, Math.min(props.rangeMax, steppedValue));
|
|
62
|
-
const distanceToMin = Math.abs(value - props.currentMinValue);
|
|
63
|
-
const distanceToMax = Math.abs(value - props.currentMaxValue);
|
|
64
|
-
if (distanceToMin < distanceToMax) {
|
|
65
|
-
if (value <= props.currentMaxValue) {
|
|
66
|
-
emit("update:minValue", value);
|
|
39
|
+
const minInputValue = computed({
|
|
40
|
+
get: () => props.currentMinValue,
|
|
41
|
+
set: (val) => {
|
|
42
|
+
const numeric = Number(val);
|
|
43
|
+
if (!Number.isNaN(numeric) && numeric <= props.currentMaxValue) {
|
|
44
|
+
emit("update:minValue", numeric);
|
|
67
45
|
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const maxInputValue = computed({
|
|
49
|
+
get: () => props.currentMaxValue,
|
|
50
|
+
set: (val) => {
|
|
51
|
+
const numeric = Number(val);
|
|
52
|
+
if (!Number.isNaN(numeric) && numeric >= props.currentMinValue) {
|
|
53
|
+
emit("update:maxValue", numeric);
|
|
71
54
|
}
|
|
72
55
|
}
|
|
73
|
-
};
|
|
56
|
+
});
|
|
74
57
|
</script>
|
|
75
58
|
|
|
76
59
|
<style scoped>
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
.KSlider(:class="{ disabled: isDisabled }")
|
|
3
3
|
label.k-input-label(v-if="label") {{ label }}
|
|
4
|
-
.slider-container
|
|
4
|
+
.slider-container
|
|
5
5
|
.slider-track
|
|
6
6
|
.slider-fill(:style="{ '--slider-fill': valuePercent + '%' }")
|
|
7
7
|
input.slider-input(
|
|
8
|
+
v-model.number="sliderValue"
|
|
8
9
|
type="range"
|
|
9
10
|
:min="rangeMin"
|
|
10
11
|
:max="rangeMax"
|
|
11
12
|
:step="rangeStep"
|
|
12
|
-
:value="currentValue"
|
|
13
13
|
:disabled="isDisabled"
|
|
14
|
-
@input="updateValue"
|
|
15
14
|
)
|
|
16
15
|
</template>
|
|
17
16
|
|
|
@@ -27,21 +26,15 @@ const props = defineProps({
|
|
|
27
26
|
valuePercent: { type: Number, required: true }
|
|
28
27
|
});
|
|
29
28
|
const emit = defineEmits(["update:value"]);
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const percentage = clickX / rect.width;
|
|
40
|
-
const rawValue = props.rangeMin + percentage * (props.rangeMax - props.rangeMin);
|
|
41
|
-
const steppedValue = Math.round(rawValue / props.rangeStep) * props.rangeStep;
|
|
42
|
-
const value = Math.max(props.rangeMin, Math.min(props.rangeMax, steppedValue));
|
|
43
|
-
emit("update:value", value);
|
|
44
|
-
};
|
|
29
|
+
const sliderValue = computed({
|
|
30
|
+
get: () => props.currentValue,
|
|
31
|
+
set: (val) => {
|
|
32
|
+
const numeric = Number(val);
|
|
33
|
+
if (!Number.isNaN(numeric)) {
|
|
34
|
+
emit("update:value", Math.max(props.rangeMin, Math.min(props.rangeMax, numeric)));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
45
38
|
</script>
|
|
46
39
|
|
|
47
40
|
<style scoped>
|
|
@@ -3,12 +3,15 @@ type __VLS_Props = {
|
|
|
3
3
|
text: string;
|
|
4
4
|
showClear: boolean;
|
|
5
5
|
clear: () => void;
|
|
6
|
+
loading?: boolean;
|
|
6
7
|
placeholder: string;
|
|
7
8
|
type: string;
|
|
8
9
|
validation?: 'success' | 'warning' | 'error' | null;
|
|
9
10
|
validationText?: string;
|
|
10
11
|
};
|
|
11
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
12
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
13
|
+
focus: () => void | undefined;
|
|
14
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
12
15
|
"update:text": (value: string) => any;
|
|
13
16
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
14
17
|
"onUpdate:text"?: ((value: string) => any) | undefined;
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
.KTextbox-wrapper(:class="$attrs.class" :style="$attrs.style")
|
|
3
3
|
label.k-input-label(v-if="label") {{ label }}
|
|
4
|
-
.KTextbox.modern-textbox(:class="validation ? `is-${validation}` : ''")
|
|
5
|
-
input(v-bind="inputAttrs" :type="props.type" v-model="text" :placeholder="placeholder")
|
|
6
|
-
.
|
|
7
|
-
|
|
4
|
+
.KTextbox.modern-textbox(:class="[validation ? `is-${validation}` : '', { 'is-loading': loading }]")
|
|
5
|
+
input(ref="inputRef" v-bind="inputAttrs" :type="props.type" v-model="text" :placeholder="placeholder" :aria-busy="loading ? 'true' : undefined")
|
|
6
|
+
.KTextbox__actions(v-if="loading || showClear")
|
|
7
|
+
KLoader.KTextbox__loader(v-if="loading" :loading="loading" size="small")
|
|
8
|
+
.clear-button(v-if="showClear" @click.stop="clear" @mousedown.stop role="button" :aria-label="t('Clear input')")
|
|
9
|
+
KIcon(iconname="close" width="16" height="16")
|
|
8
10
|
span.validation-text(v-if="validation && ['success', 'warning', 'error'].includes(validation) && validationText" :class="`is-${validation}`") {{ validationText }}
|
|
9
11
|
</template>
|
|
10
12
|
|
|
11
13
|
<script setup>
|
|
12
|
-
import { computed, useAttrs } from "vue";
|
|
14
|
+
import { computed, ref, useAttrs } from "vue";
|
|
13
15
|
import { useKatluxI18n } from "#toolkit/composables/useKatluxI18n";
|
|
14
16
|
const { t } = useKatluxI18n();
|
|
17
|
+
const inputRef = ref(null);
|
|
18
|
+
defineExpose({
|
|
19
|
+
focus: () => inputRef.value?.focus?.()
|
|
20
|
+
});
|
|
15
21
|
defineOptions({
|
|
16
22
|
inheritAttrs: false
|
|
17
23
|
});
|
|
@@ -20,6 +26,7 @@ const props = defineProps({
|
|
|
20
26
|
text: { type: String, required: true },
|
|
21
27
|
showClear: { type: Boolean, required: true },
|
|
22
28
|
clear: { type: Function, required: true },
|
|
29
|
+
loading: { type: Boolean, required: false },
|
|
23
30
|
placeholder: { type: String, required: true },
|
|
24
31
|
type: { type: String, required: true },
|
|
25
32
|
validation: { type: [String, null], required: false },
|
|
@@ -80,11 +87,17 @@ const inputAttrs = computed(() => {
|
|
|
80
87
|
.KTextbox.modern-textbox input::placeholder {
|
|
81
88
|
color: var(--neutral-400);
|
|
82
89
|
}
|
|
90
|
+
.KTextbox.modern-textbox .KTextbox__actions {
|
|
91
|
+
display: flex;
|
|
92
|
+
align-items: center;
|
|
93
|
+
gap: var(--gap-sm);
|
|
94
|
+
padding-right: var(--component-gap);
|
|
95
|
+
flex-shrink: 0;
|
|
96
|
+
}
|
|
97
|
+
.KTextbox.modern-textbox .KTextbox__loader {
|
|
98
|
+
flex-shrink: 0;
|
|
99
|
+
}
|
|
83
100
|
.KTextbox.modern-textbox .clear-button {
|
|
84
|
-
position: absolute;
|
|
85
|
-
right: var(--component-gap);
|
|
86
|
-
top: 50%;
|
|
87
|
-
transform: translateY(-50%);
|
|
88
101
|
display: flex;
|
|
89
102
|
align-items: center;
|
|
90
103
|
justify-content: center;
|
|
@@ -98,6 +111,6 @@ const inputAttrs = computed(() => {
|
|
|
98
111
|
color: var(--neutral-700);
|
|
99
112
|
}
|
|
100
113
|
.KTextbox.modern-textbox .clear-button:active {
|
|
101
|
-
transform:
|
|
114
|
+
transform: scale(0.95);
|
|
102
115
|
}
|
|
103
116
|
</style>
|
|
@@ -3,12 +3,15 @@ type __VLS_Props = {
|
|
|
3
3
|
text: string;
|
|
4
4
|
showClear: boolean;
|
|
5
5
|
clear: () => void;
|
|
6
|
+
loading?: boolean;
|
|
6
7
|
placeholder: string;
|
|
7
8
|
type: string;
|
|
8
9
|
validation?: 'success' | 'warning' | 'error' | null;
|
|
9
10
|
validationText?: string;
|
|
10
11
|
};
|
|
11
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
12
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
13
|
+
focus: () => void | undefined;
|
|
14
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
12
15
|
"update:text": (value: string) => any;
|
|
13
16
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
14
17
|
"onUpdate:text"?: ((value: string) => any) | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@katlux/preset-modern",
|
|
3
|
-
"version": "0.1.1-alpha.
|
|
3
|
+
"version": "0.1.1-alpha.121",
|
|
4
4
|
"description": "Modern default design preset and styling variables for Katlux components",
|
|
5
5
|
"author": "Katlux",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"**/*.sass"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@katlux/toolkit": "^0.1.1-alpha.
|
|
29
|
+
"@katlux/toolkit": "^0.1.1-alpha.147",
|
|
30
30
|
"@nuxt/kit": "^3.12.0"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|