@xleddyl/443-components-vue 0.16.30 → 0.16.32
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/CATALOG.md +1 -1
- package/README.md +2 -1
- package/dist/components/forms/NumberInput.vue +40 -9
- package/dist/components/forms/NumberInput.vue.d.ts +2 -0
- package/dist/grid/cells/BadgeCell.vue +51 -2
- package/dist/grid/data-grid.css +1 -0
- package/dist/locale/index.d.ts +1 -0
- package/dist/locale/index.mjs +2 -1
- package/dist/locale/types.d.ts +1 -0
- package/dist/nuxt/module.d.ts +2 -0
- package/dist/nuxt/module.mjs +1 -0
- package/dist/nuxt/runtime/locale.mjs +5 -1
- package/package.json +1 -1
package/CATALOG.md
CHANGED
|
@@ -171,7 +171,7 @@ All field components work inside `FormField` and take `invalid`, `disabled`, `re
|
|
|
171
171
|
| `Combobox` | Searchable select. Local filter, async `search`, `multiple` with tags, `creatable`. | Models: `v-model`, `v-model:query`. Props: `options` (`label`, `value`, `description`, `icon`, `color` (dot and tag color), `group` (divider with the group name, also the tooltip of a selected tag), `keywords`), `search(query, signal)`, `filter`, `multiple`, `hideTags`, `creatable`, `createActions`, `createTransform`, `createValidate` (a returned string is the inline error), `debounce`, `minQueryLength`, `maxSelected`, `clearable`, `loading`, `placeholder`, `emptyText`. Slots: `option`, `empty`, `header` (top of the panel, for example quick filter pills). Events: `create`, `open`, `close`. | `forms/combobox.vue` |
|
|
172
172
|
| `TreeSelect` | Pick one node of a hierarchy (category, folder) with a drill-down panel, one level at a time. | Model: `TreeNodeId or null`. Props: `nodes` (`TreeNode`: `id`, `label`, `description`, `icon`, `disabled`, `children`), `leavesOnly` (parents only navigate), `separator` (path in the control and in search results, default `' / '`), `clearable`, `placeholder`, `searchPlaceholder`, `emptyText`, `icon`. Search lists every match with its path. Slots: `node` (`node`, `selected`, `path`), `empty`. Events: `open`, `close`. | `forms/tree-select.vue` |
|
|
173
173
|
| `Switch` | On or off setting that applies at once. | Model: boolean. Props: `label`, `description`, `labelPosition`, `checkedIcon`, `uncheckedIcon`, `name`. Slots: default, `description`. | `forms/switch.vue` |
|
|
174
|
-
| `NumberInput` | Locale aware number with stepper, min, max, step. | Model: number or null. Props: `min`, `max`, `step`, `largeStep`, `locale`, `formatOptions` (currency, percent), `stepper`, `wheel`, `align`, `icon`, `placeholder`.
|
|
174
|
+
| `NumberInput` | Locale aware number with stepper, min, max, step. | Model: number or null. Props: `min`, `max`, `step`, `largeStep`, `locale`, `formatOptions` (currency, percent), `decimalSeparator` (`'.'` or `','`, default from the locale), `stepper`, `wheel`, `align`, `icon`, `placeholder`. Typing keeps only digits, one decimal separator (a typed `.` or `,` becomes the separator) and a leading `-` when `min` allows negatives. | `forms/number-input.vue` |
|
|
175
175
|
| `PasswordInput` | Password with show or hide, optional generator, copy and strength meter. | Model: string. Props: `generate` (true or a function), `copy`, `strength`, `minLength`, `autocomplete`. Event: `generate`. | `forms/password-input.vue` |
|
|
176
176
|
| `PinInput` | One time code or PIN in separate cells. | Model: string. Props: `length`, `mode` (numeric, alphanumeric, alphabetic), `mask`, `uppercase`, `separatorAfter`, `autocomplete`. Event: `complete(value)`. | `forms/pin-input.vue` |
|
|
177
177
|
| `InputGroup` | Join an input with addons or buttons on its sides. | Props: `label`, `size`, `block`. Slot: default (inputs, `InputAddon`, `Button`). | `forms/input-group.vue` |
|
package/README.md
CHANGED
|
@@ -49,6 +49,7 @@ Every component is registered with the prefix (`Button.vue` becomes `<KButton>`)
|
|
|
49
49
|
| `cssLayers` | `'theme, base, k, components, utilities'` | Cascade layer order declared before any other CSS. The library layer `k` sits after the `theme` and `base` layers of Tailwind (so preflight does not reset components) and before `components` and `utilities` (so host classes win). `false` declares nothing. See [Scoping](#scoping). |
|
|
50
50
|
| `locale` | `'en'` | Language of the built-in copy: `'en'`, `'it'`, `'de'`, or any code completed with `messages`. With `@nuxtjs/i18n` the current i18n locale wins. See [Languages](#languages). |
|
|
51
51
|
| `messages` | `{}` | Overrides per locale code, for example `{ it: { common: { cancel: 'Indietro' } } }`. |
|
|
52
|
+
| `decimalSeparator` | locale | Decimal separator of `NumberInput` in display and editing, for example `'.'` in an Italian app. A typed `.` or `,` becomes this separator, and the display drops the group separators. |
|
|
52
53
|
| `routeState.location` | `'query'` | Where `useRouteState` and the settings modal `route` keep their value by default: `'query'` (`?family=fam_1`) or `'hash'` (`#family/fam_1`). See [Deep links](#deep-links). |
|
|
53
54
|
| `composables` | `true` | Auto-imports the composables. |
|
|
54
55
|
| `global` | `false` | Puts `k-root` and `data-theme` on `<html>` for apps that are dashboard only. |
|
|
@@ -881,7 +882,7 @@ Accessibility related props and defaults:
|
|
|
881
882
|
- `DataGrid` `showEdges` and `showJump` reach the footer pager (first and last page buttons, page number input). `loading` also keeps the pager from resetting the page while a server total is unknown.
|
|
882
883
|
- `DataGrid` registers the AG Grid cell editors (text, large text, number, date, checkbox, select, custom and undo/redo) when `editable` is set or when a column or `gridOptions.defaultColDef` has `editable` at mount. `registerGridEditorModules()` from `/grid` does it by hand, before the first grid mounts, for columns that become editable later.
|
|
883
884
|
- `ImageCell` takes `fit` (`'cover'` default, or `'contain'` for logos) and `size` (any CSS length, default `1.75rem`) in `cellRendererParams`. `EmptyCell` (the hidden "Empty" dash) is exported from `/grid` for custom renderers.
|
|
884
|
-
- `BadgeCell` takes `variant` (`BadgeVariant`, `'soft' | 'solid' | 'outline'`) in `cellRendererParams`: set, the cell renders a `KBadge` with that variant and the resolved tone (`size`, `BadgeSize`, default `'sm'`); unset keeps the compact grid pill. `badgeClass` (`string | ((value, data) => string | undefined)`) adds host classes to the badge, to set the per instance badge tokens (`--k-badge-background`, `--k-badge-color`, `--k-badge-border-color`, which the grid pill also reads) for values outside `Tone`. `BadgeCellParams<T>` types the row of `data`. When the value is an array, the cell renders one badge per item (each item resolves its own `tones`, `labels` and `badgeClass`), on one line
|
|
885
|
+
- `BadgeCell` takes `variant` (`BadgeVariant`, `'soft' | 'solid' | 'outline'`) in `cellRendererParams`: set, the cell renders a `KBadge` with that variant and the resolved tone (`size`, `BadgeSize`, default `'sm'`); unset keeps the compact grid pill. `badgeClass` (`string | ((value, data) => string | undefined)`) adds host classes to the badge, to set the per instance badge tokens (`--k-badge-background`, `--k-badge-color`, `--k-badge-border-color`, which the grid pill also reads) for values outside `Tone`. `BadgeCellParams<T>` types the row of `data`. When the value is an array, the cell renders one badge per item (each item resolves its own `tones`, `labels` and `badgeClass`), on one line, with the full list in the `title` attribute. The cell shows only the badges that fit its width and a `+N` badge for the rest, and measures again when the column is resized. `max` (a number) also limits the badges to the first items, with a `+N` badge for the rest (announced as "N more", `grid.moreValues`); `wrap: true` lets the badges wrap onto more lines (pair it with `autoHeight` on the column). Give an array column a `valueFormatter` (`(params) => params.value.join(', ')`): AG Grid infers an object type for arrays and uses the formatter for export, copy and the quick filter. Single values render as before.
|
|
885
886
|
- `DataGrid` `spreadsheet` turns on Excel like editing on AG Grid Community (no Enterprise modules): it registers the editor modules and the AG Grid `ScrollApiModule` (`registerGridSpreadsheetModules()` from `/grid` does it by hand) and leaves the normal grid unchanged when it is off. Set `rowIdKey` or `getRowId`: changes, dirty cells and undo refer to row ids, never to indexes.
|
|
886
887
|
- Selection: click selects a cell; drag, Shift+click and Shift+arrows extend a rectangular range (Shift+Cmd/Ctrl+arrow to the edge); Cmd/Ctrl+A selects every cell. The range follows the displayed row order (after sort, filter and quick search) and the displayed column order; the row selection checkbox column is not part of it. Escape collapses the range to the active cell.
|
|
887
888
|
- Keyboard: arrows and Tab move the active cell, Enter, F2 or typing start the AG Grid editor, Escape cancels it. While an editor (or any input) has focus no shortcut fires.
|
|
@@ -90,6 +90,7 @@ const props = defineProps({
|
|
|
90
90
|
step: { type: Number, required: false, default: 1 },
|
|
91
91
|
largeStep: { type: Number, required: false },
|
|
92
92
|
locale: { type: String, required: false },
|
|
93
|
+
decimalSeparator: { type: String, required: false },
|
|
93
94
|
formatOptions: { type: null, required: false },
|
|
94
95
|
wheel: { type: Boolean, required: false },
|
|
95
96
|
stepper: { type: Boolean, required: false, default: true },
|
|
@@ -134,6 +135,12 @@ const separators = computed(() => {
|
|
|
134
135
|
group: parts.find((part) => part.type === "group")?.value ?? ","
|
|
135
136
|
};
|
|
136
137
|
});
|
|
138
|
+
const decimalSeparator = computed(
|
|
139
|
+
() => props.decimalSeparator ?? appLocale.value.decimalSeparator ?? separators.value.decimal
|
|
140
|
+
);
|
|
141
|
+
const customSeparator = computed(() => decimalSeparator.value !== separators.value.decimal);
|
|
142
|
+
const allowsFraction = computed(() => props.formatOptions?.maximumFractionDigits !== 0);
|
|
143
|
+
const allowsNegative = computed(() => props.min === void 0 || props.min < 0);
|
|
137
144
|
const stepDecimals = computed(() => {
|
|
138
145
|
const text = String(props.step);
|
|
139
146
|
return text.includes(".") ? text.split(".")[1].length : 0;
|
|
@@ -141,9 +148,15 @@ const stepDecimals = computed(() => {
|
|
|
141
148
|
const inputmode = computed(
|
|
142
149
|
() => props.step % 1 === 0 && (props.min ?? -1) >= 0 && !props.formatOptions?.maximumFractionDigits ? "numeric" : "decimal"
|
|
143
150
|
);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
)
|
|
151
|
+
function withSeparator(formatted) {
|
|
152
|
+
return formatted.map(
|
|
153
|
+
(part) => part.type === "decimal" ? decimalSeparator.value : part.type === "group" ? "" : part.value
|
|
154
|
+
).join("");
|
|
155
|
+
}
|
|
156
|
+
const display = computed(() => {
|
|
157
|
+
if (model.value === null || model.value === void 0 || Number.isNaN(model.value)) return "";
|
|
158
|
+
return customSeparator.value ? withSeparator(formatter.value.formatToParts(model.value)) : formatter.value.format(model.value);
|
|
159
|
+
});
|
|
147
160
|
const interactive = computed(() => !control.disabled.value && !props.readonly);
|
|
148
161
|
const canDecrement = computed(
|
|
149
162
|
() => interactive.value && (props.min === void 0 || (model.value ?? Infinity) > props.min)
|
|
@@ -153,13 +166,23 @@ const canIncrement = computed(
|
|
|
153
166
|
);
|
|
154
167
|
function toEditString(value) {
|
|
155
168
|
if (value === null || value === void 0 || Number.isNaN(value)) return "";
|
|
156
|
-
|
|
169
|
+
const edited = editFormatter.value.formatToParts(isPercent.value ? value * 100 : value);
|
|
170
|
+
return withSeparator(edited);
|
|
171
|
+
}
|
|
172
|
+
function sanitize(text) {
|
|
173
|
+
const cleaned = text.replace(/[^\d.,-]/g, "");
|
|
174
|
+
const negative = allowsNegative.value && cleaned.startsWith("-");
|
|
175
|
+
const unsigned = cleaned.replace(/-/g, "");
|
|
176
|
+
const mixed = unsigned.includes(".") && unsigned.includes(",");
|
|
177
|
+
const index = mixed ? Math.max(unsigned.lastIndexOf("."), unsigned.lastIndexOf(",")) : unsigned.search(/[.,]/);
|
|
178
|
+
const whole = (index < 0 ? unsigned : unsigned.slice(0, index)).replace(/[.,]/g, "");
|
|
179
|
+
const fraction = index < 0 ? null : unsigned.slice(index + 1).replace(/[.,]/g, "");
|
|
180
|
+
const sign = negative ? "-" : "";
|
|
181
|
+
if (fraction === null || !allowsFraction.value) return sign + whole;
|
|
182
|
+
return `${sign}${whole}${decimalSeparator.value}${fraction}`;
|
|
157
183
|
}
|
|
158
184
|
function parse(text) {
|
|
159
|
-
const
|
|
160
|
-
let normalized = text.replace(/\s/g, "").split(group).join("");
|
|
161
|
-
if (decimal !== ".") normalized = normalized.split(decimal).join(".");
|
|
162
|
-
normalized = normalized.replace(/[^\d.\-+eE]/g, "");
|
|
185
|
+
const normalized = sanitize(text.replace(/\s/g, "")).replace(decimalSeparator.value, ".");
|
|
163
186
|
if (!normalized || normalized === "-" || normalized === ".") return null;
|
|
164
187
|
const parsed = Number(normalized);
|
|
165
188
|
if (Number.isNaN(parsed)) return void 0;
|
|
@@ -200,7 +223,15 @@ function commit() {
|
|
|
200
223
|
draft.value = toEditString(model.value);
|
|
201
224
|
}
|
|
202
225
|
function onInput(event) {
|
|
203
|
-
|
|
226
|
+
const input = event.target;
|
|
227
|
+
const raw = input.value;
|
|
228
|
+
const next = sanitize(raw);
|
|
229
|
+
if (next !== raw) {
|
|
230
|
+
const caret = Math.max(0, (input.selectionStart ?? raw.length) - (raw.length - next.length));
|
|
231
|
+
input.value = next;
|
|
232
|
+
input.setSelectionRange(caret, caret);
|
|
233
|
+
}
|
|
234
|
+
draft.value = next;
|
|
204
235
|
const parsed = parse(draft.value);
|
|
205
236
|
if (parsed !== void 0) model.value = parsed;
|
|
206
237
|
}
|
|
@@ -6,6 +6,7 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
6
6
|
step?: (string | number) | undefined;
|
|
7
7
|
largeStep?: number;
|
|
8
8
|
locale?: string;
|
|
9
|
+
decimalSeparator?: string;
|
|
9
10
|
formatOptions?: Intl.NumberFormatOptions;
|
|
10
11
|
wheel?: boolean;
|
|
11
12
|
stepper?: boolean;
|
|
@@ -250,6 +251,7 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
250
251
|
step?: (string | number) | undefined;
|
|
251
252
|
largeStep?: number;
|
|
252
253
|
locale?: string;
|
|
254
|
+
decimalSeparator?: string;
|
|
253
255
|
formatOptions?: Intl.NumberFormatOptions;
|
|
254
256
|
wheel?: boolean;
|
|
255
257
|
stepper?: boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<span
|
|
3
3
|
v-if="isList && entries.length"
|
|
4
|
+
ref="root"
|
|
4
5
|
class="k-data-grid-badges"
|
|
5
6
|
:class="{ 'is-wrap': params.wrap }"
|
|
6
7
|
:title="fullText"
|
|
@@ -58,7 +59,8 @@
|
|
|
58
59
|
</template>
|
|
59
60
|
|
|
60
61
|
<script setup>
|
|
61
|
-
import { computed } from "vue";
|
|
62
|
+
import { computed, nextTick, ref, watch } from "vue";
|
|
63
|
+
import { useResizeObserver } from "../../internal/core/resize";
|
|
62
64
|
import Badge from "../../components/data/Badge.vue";
|
|
63
65
|
import { paletteClass } from "../../components/core/palette";
|
|
64
66
|
import { formatLocaleMessage } from "../../locale";
|
|
@@ -105,8 +107,55 @@ const limit = computed(() => {
|
|
|
105
107
|
const max = props.params.max;
|
|
106
108
|
return max === void 0 || max < 1 ? entries.value.length : Math.floor(max);
|
|
107
109
|
});
|
|
108
|
-
const
|
|
110
|
+
const root = ref(null);
|
|
111
|
+
const available = ref(Number.POSITIVE_INFINITY);
|
|
112
|
+
const widths = ref(null);
|
|
113
|
+
const moreWidth = ref(0);
|
|
114
|
+
const fitted = computed(() => {
|
|
115
|
+
const measured = widths.value;
|
|
116
|
+
if (props.params.wrap || !measured) return limit.value;
|
|
117
|
+
const gap = 4;
|
|
118
|
+
const total = entries.value.length;
|
|
119
|
+
let used = 0;
|
|
120
|
+
for (let index = 0; index < limit.value; index += 1) {
|
|
121
|
+
const next = used + (index ? gap : 0) + (measured[index] ?? 0);
|
|
122
|
+
const reserve = index + 1 < total ? gap + moreWidth.value : 0;
|
|
123
|
+
if (next + reserve > available.value) return Math.max(index, 1);
|
|
124
|
+
used = next;
|
|
125
|
+
}
|
|
126
|
+
return limit.value;
|
|
127
|
+
});
|
|
128
|
+
const shown = computed(() => entries.value.slice(0, fitted.value));
|
|
109
129
|
const hiddenCount = computed(() => entries.value.length - shown.value.length);
|
|
130
|
+
function badgeElements() {
|
|
131
|
+
return Array.from(root.value?.children ?? []).filter(
|
|
132
|
+
(element) => element instanceof HTMLElement && !element.classList.contains("k-data-grid-badge-more") && !element.classList.contains("k-visually-hidden")
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
function measure() {
|
|
136
|
+
if (!root.value) return;
|
|
137
|
+
available.value = root.value.clientWidth;
|
|
138
|
+
const more = root.value.querySelector(".k-data-grid-badge-more");
|
|
139
|
+
if (more) moreWidth.value = more.offsetWidth;
|
|
140
|
+
}
|
|
141
|
+
async function measureBadges() {
|
|
142
|
+
widths.value = null;
|
|
143
|
+
await nextTick();
|
|
144
|
+
if (!root.value) return;
|
|
145
|
+
widths.value = badgeElements().map((element) => element.offsetWidth);
|
|
146
|
+
moreWidth.value ||= 32;
|
|
147
|
+
measure();
|
|
148
|
+
await nextTick();
|
|
149
|
+
measure();
|
|
150
|
+
}
|
|
151
|
+
watch(
|
|
152
|
+
() => entries.value.map((entry) => entry.key + entry.text).join("|"),
|
|
153
|
+
() => {
|
|
154
|
+
if (!props.params.wrap) measureBadges();
|
|
155
|
+
},
|
|
156
|
+
{ immediate: true }
|
|
157
|
+
);
|
|
158
|
+
useResizeObserver(() => [root.value], measure);
|
|
110
159
|
const fullText = computed(() => entries.value.map((entry) => entry.text).join(", "));
|
|
111
160
|
const moreText = computed(
|
|
112
161
|
() => formatLocaleMessage(
|
package/dist/grid/data-grid.css
CHANGED
package/dist/locale/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface DefineLocaleOptions {
|
|
|
10
10
|
dir?: 'ltr' | 'rtl';
|
|
11
11
|
messages?: DeepPartial<KMessages>;
|
|
12
12
|
base?: KLocale;
|
|
13
|
+
decimalSeparator?: string;
|
|
13
14
|
}
|
|
14
15
|
export declare function defineLocale(options: DefineLocaleOptions): KLocale;
|
|
15
16
|
export declare function formatLocaleMessage(code: string, template: string, params?: MessageParams): string;
|
package/dist/locale/index.mjs
CHANGED
|
@@ -20,7 +20,8 @@ export function defineLocale(options) {
|
|
|
20
20
|
return {
|
|
21
21
|
code: options.code,
|
|
22
22
|
dir: options.dir ?? base.dir,
|
|
23
|
-
messages: mergeMessages(base.messages, options.messages)
|
|
23
|
+
messages: mergeMessages(base.messages, options.messages),
|
|
24
|
+
decimalSeparator: options.decimalSeparator ?? options.base?.decimalSeparator
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
function pluralForm(code, forms, count) {
|
package/dist/locale/types.d.ts
CHANGED
package/dist/nuxt/module.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export interface ModuleOptions {
|
|
|
41
41
|
fonts: boolean | ThemePreset[];
|
|
42
42
|
locale: string;
|
|
43
43
|
messages: Record<string, DeepPartial<KMessages>>;
|
|
44
|
+
decimalSeparator?: '.' | ',';
|
|
44
45
|
routeState: {
|
|
45
46
|
location?: 'query' | 'hash';
|
|
46
47
|
};
|
|
@@ -53,6 +54,7 @@ export interface KRuntimeConfig {
|
|
|
53
54
|
presetDefault: ThemePreset;
|
|
54
55
|
locale: string;
|
|
55
56
|
messages: Record<string, DeepPartial<KMessages>>;
|
|
57
|
+
decimalSeparator?: '.' | ',';
|
|
56
58
|
routeLocation: 'query' | 'hash';
|
|
57
59
|
}
|
|
58
60
|
declare module '@nuxt/schema' {
|
package/dist/nuxt/module.mjs
CHANGED
|
@@ -119,6 +119,7 @@ export default defineNuxtModule({
|
|
|
119
119
|
presetDefault,
|
|
120
120
|
locale: options.locale,
|
|
121
121
|
messages: options.messages,
|
|
122
|
+
decimalSeparator: options.decimalSeparator,
|
|
122
123
|
routeLocation: options.routeState.location === "hash" ? "hash" : "query"
|
|
123
124
|
};
|
|
124
125
|
Object.assign(nuxt.options.runtimeConfig.public, { k: runtimeConfig });
|
|
@@ -12,7 +12,11 @@ export default defineNuxtPlugin({
|
|
|
12
12
|
);
|
|
13
13
|
const locale = computed(() => {
|
|
14
14
|
const language = code.value.split("-")[0];
|
|
15
|
-
const base = defineLocale({
|
|
15
|
+
const base = defineLocale({
|
|
16
|
+
code: language,
|
|
17
|
+
messages: config.messages?.[language],
|
|
18
|
+
decimalSeparator: config.decimalSeparator
|
|
19
|
+
});
|
|
16
20
|
if (language === code.value) return base;
|
|
17
21
|
return defineLocale({ code: code.value, base, messages: config.messages?.[code.value] });
|
|
18
22
|
});
|
package/package.json
CHANGED