@joniguerini/lume 0.0.0-stage → 1.9.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.
- package/LICENSE +25 -0
- package/README.md +62 -2
- package/base.css +165 -0
- package/bin/lumeui.mjs +163 -0
- package/components/alert.css +156 -0
- package/components/banner.css +98 -0
- package/components/button.css +291 -0
- package/components/calendar.css +532 -0
- package/components/carousel.css +175 -0
- package/components/chart.css +813 -0
- package/components/chat.css +670 -0
- package/components/checkbox.css +212 -0
- package/components/chip.css +224 -0
- package/components/code.css +36 -0
- package/components/color-picker.css +192 -0
- package/components/command.css +148 -0
- package/components/content.css +211 -0
- package/components/editor.css +174 -0
- package/components/feedback.css +320 -0
- package/components/filters.css +103 -0
- package/components/form.css +455 -0
- package/components/image-viewer.css +237 -0
- package/components/layers.css +138 -0
- package/components/link.css +87 -0
- package/components/loading.css +260 -0
- package/components/menu.css +180 -0
- package/components/modal.css +209 -0
- package/components/navigation.css +507 -0
- package/components/notifications.css +186 -0
- package/components/number-field.css +52 -0
- package/components/otp.css +119 -0
- package/components/panel.css +208 -0
- package/components/picker.css +207 -0
- package/components/rating.css +143 -0
- package/components/resizable.css +173 -0
- package/components/scrollbar.css +110 -0
- package/components/select.css +477 -0
- package/components/shell.css +837 -0
- package/components/slider.css +189 -0
- package/components/sortable.css +287 -0
- package/components/surfaces.css +182 -0
- package/components/switch.css +115 -0
- package/components/table.css +228 -0
- package/components/tabs.css +190 -0
- package/components/tags.css +83 -0
- package/components/toast.css +164 -0
- package/components/toolbar.css +80 -0
- package/components/upload.css +181 -0
- package/ds.css +48 -0
- package/fonts/Geist-LICENSE.txt +92 -0
- package/fonts/Geist-Variable.woff2 +0 -0
- package/fonts/GeistSerif-Regular.woff2 +0 -0
- package/fonts/JetBrainsMono-LICENSE.txt +93 -0
- package/fonts/JetBrainsMono-Variable.woff2 +0 -0
- package/fonts.css +29 -0
- package/icons/icons.d.ts +5 -0
- package/icons/icons.js +266 -0
- package/js/back-to-top.d.ts +2 -0
- package/js/back-to-top.js +62 -0
- package/js/banner.js +87 -0
- package/js/calendar.d.ts +3 -0
- package/js/calendar.js +472 -0
- package/js/carousel.d.ts +2 -0
- package/js/carousel.js +258 -0
- package/js/charts/bar.js +361 -0
- package/js/charts/core.js +604 -0
- package/js/charts/donut.js +206 -0
- package/js/charts/figures.js +97 -0
- package/js/charts/heatmap.js +410 -0
- package/js/charts/line.js +268 -0
- package/js/charts/scatter.js +211 -0
- package/js/charts.d.ts +12 -0
- package/js/charts.js +27 -0
- package/js/code-block.d.ts +3 -0
- package/js/code-block.js +32 -0
- package/js/color-picker.d.ts +4 -0
- package/js/color-picker.js +448 -0
- package/js/command-palette.js +233 -0
- package/js/composer.js +573 -0
- package/js/context-menu.d.ts +2 -0
- package/js/context-menu.js +154 -0
- package/js/date-picker.d.ts +2 -0
- package/js/date-picker.js +430 -0
- package/js/drawer.js +48 -0
- package/js/editor.d.ts +5 -0
- package/js/editor.js +615 -0
- package/js/field-support.js +77 -0
- package/js/file-upload.d.ts +2 -0
- package/js/file-upload.js +230 -0
- package/js/filters.js +266 -0
- package/js/form.d.ts +2 -0
- package/js/form.js +409 -0
- package/js/i18n.d.ts +14 -0
- package/js/i18n.js +83 -0
- package/js/image-viewer.d.ts +4 -0
- package/js/image-viewer.js +275 -0
- package/js/menu.d.ts +4 -0
- package/js/menu.js +237 -0
- package/js/messages.js +908 -0
- package/js/modal.d.ts +7 -0
- package/js/modal.js +183 -0
- package/js/notifications.d.ts +4 -0
- package/js/notifications.js +204 -0
- package/js/number-field.d.ts +2 -0
- package/js/number-field.js +175 -0
- package/js/otp-field.d.ts +2 -0
- package/js/otp-field.js +107 -0
- package/js/pagination.d.ts +3 -0
- package/js/pagination.js +143 -0
- package/js/popover.d.ts +2 -0
- package/js/popover.js +155 -0
- package/js/progress-ring.js +48 -0
- package/js/rating.d.ts +3 -0
- package/js/rating.js +130 -0
- package/js/resizable.d.ts +2 -0
- package/js/resizable.js +311 -0
- package/js/scrollbar.d.ts +2 -0
- package/js/scrollbar.js +273 -0
- package/js/segmented.js +60 -0
- package/js/select.d.ts +3 -0
- package/js/select.js +784 -0
- package/js/shell.d.ts +6 -0
- package/js/shell.js +373 -0
- package/js/slider.d.ts +2 -0
- package/js/slider.js +89 -0
- package/js/sortable.d.ts +5 -0
- package/js/sortable.js +463 -0
- package/js/stepper.d.ts +2 -0
- package/js/stepper.js +72 -0
- package/js/tabs.js +99 -0
- package/js/tag-field.d.ts +2 -0
- package/js/tag-field.js +177 -0
- package/js/theme.d.ts +9 -0
- package/js/theme.js +114 -0
- package/js/time-picker.d.ts +2 -0
- package/js/time-picker.js +279 -0
- package/js/toast.d.ts +17 -0
- package/js/toast.js +171 -0
- package/js/toolbar.d.ts +2 -0
- package/js/toolbar.js +107 -0
- package/js/tooltip.d.ts +2 -0
- package/js/tooltip.js +208 -0
- package/js/tree.d.ts +2 -0
- package/js/tree.js +168 -0
- package/lume.css +11574 -0
- package/lume.d.ts +104 -0
- package/lume.js +67 -0
- package/package.json +66 -4
- package/react/Alert.d.ts +24 -0
- package/react/Alert.js +21 -0
- package/react/AppShell.d.ts +67 -0
- package/react/AppShell.js +94 -0
- package/react/Avatar.d.ts +39 -0
- package/react/Avatar.js +40 -0
- package/react/Badge.d.ts +17 -0
- package/react/Badge.js +10 -0
- package/react/Button.d.ts +32 -0
- package/react/Button.js +17 -0
- package/react/Calendar.d.ts +48 -0
- package/react/Calendar.js +67 -0
- package/react/Carousel.d.ts +30 -0
- package/react/Carousel.js +38 -0
- package/react/Charts.d.ts +186 -0
- package/react/Charts.js +58 -0
- package/react/Chip.d.ts +34 -0
- package/react/Chip.js +26 -0
- package/react/Choice.d.ts +72 -0
- package/react/Choice.js +51 -0
- package/react/ColorPicker.d.ts +43 -0
- package/react/ColorPicker.js +73 -0
- package/react/Content.d.ts +58 -0
- package/react/Content.js +42 -0
- package/react/Controls.d.ts +97 -0
- package/react/Controls.js +118 -0
- package/react/Editor.d.ts +28 -0
- package/react/Editor.js +57 -0
- package/react/Field.d.ts +90 -0
- package/react/Field.js +65 -0
- package/react/Form.d.ts +36 -0
- package/react/Form.js +45 -0
- package/react/Icon.d.ts +13 -0
- package/react/Icon.js +8 -0
- package/react/IconButton.d.ts +19 -0
- package/react/IconButton.js +12 -0
- package/react/ImageViewer.d.ts +20 -0
- package/react/ImageViewer.js +22 -0
- package/react/InlineAction.d.ts +15 -0
- package/react/InlineAction.js +12 -0
- package/react/Layers.d.ts +118 -0
- package/react/Layers.js +115 -0
- package/react/Link.d.ts +32 -0
- package/react/Link.js +26 -0
- package/react/Loading.d.ts +67 -0
- package/react/Loading.js +49 -0
- package/react/Navigation.d.ts +181 -0
- package/react/Navigation.js +197 -0
- package/react/Notices.d.ts +43 -0
- package/react/Notices.js +89 -0
- package/react/Panel.d.ts +57 -0
- package/react/Panel.js +33 -0
- package/react/Pickers.d.ts +83 -0
- package/react/Pickers.js +70 -0
- package/react/Rating.d.ts +39 -0
- package/react/Rating.js +41 -0
- package/react/Resizable.d.ts +44 -0
- package/react/Resizable.js +30 -0
- package/react/Select.d.ts +53 -0
- package/react/Select.js +79 -0
- package/react/Sortable.d.ts +52 -0
- package/react/Sortable.js +113 -0
- package/react/Table.d.ts +60 -0
- package/react/Table.js +34 -0
- package/react/Toolbar.d.ts +45 -0
- package/react/Toolbar.js +45 -0
- package/react/cx.d.ts +2 -0
- package/react/cx.js +5 -0
- package/react/icon-names.d.ts +1 -0
- package/react/icon-names.js +2 -0
- package/react/index.d.ts +42 -0
- package/react/index.js +52 -0
- package/react/useController.d.ts +8 -0
- package/react/useController.js +16 -0
- package/react/useLocale.d.ts +5 -0
- package/react/useLocale.js +15 -0
- package/tokens.css +739 -0
- package/tokens.js +4911 -0
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seletor de cor — escolher uma cor livre ou de uma paleta.
|
|
3
|
+
*
|
|
4
|
+
* Seletor solto, desenhado num elemento:
|
|
5
|
+
* const picker = createColorPicker(document.querySelector('.ds-color-picker'), {
|
|
6
|
+
* value: '#c97b63',
|
|
7
|
+
* swatches: ['#c97b63', { value: '#3b82f6', label: 'Azul' }], // amostras; sem label, o nome é o hexadecimal
|
|
8
|
+
* onInput: (hex) => …, // enquanto arrasta
|
|
9
|
+
* onChange: (hex) => …, // ao soltar, ao escolher uma amostra ou ao confirmar o hexadecimal
|
|
10
|
+
* });
|
|
11
|
+
* picker.value; picker.setValue('#000000'); picker.destroy();
|
|
12
|
+
*
|
|
13
|
+
* Campo de cor, que abre o seletor num painel:
|
|
14
|
+
* <div class="ds-field"><input class="ds-field__input" id="cor" name="cor" type="text"></div>
|
|
15
|
+
* const field = createColorField(document.querySelector('#cor'), { value: '#c97b63', swatches, onChange });
|
|
16
|
+
* field.value; field.setValue('#3b82f6'); field.open(); field.close(); field.destroy();
|
|
17
|
+
*
|
|
18
|
+
* O valor é sempre hexadecimal em minúsculas (#rrggbb), e é o que o formulário recebe. O campo aceita digitar
|
|
19
|
+
* com ou sem #, em 3 ou 6 dígitos.
|
|
20
|
+
*
|
|
21
|
+
* Teclado: na área, ← → mudam a saturação e ↑ ↓ o brilho; no matiz, ← → (com Shift, de 10 em 10), Home e End.
|
|
22
|
+
* No campo, ↓ ou Alt+↓ abrem o painel, Esc fecha e devolve o foco.
|
|
23
|
+
*/
|
|
24
|
+
import { icon } from '../icons/icons.js';
|
|
25
|
+
import { msg } from './i18n.js';
|
|
26
|
+
import { placePanel, panelHost, inheritTheme, setFieldError } from './field-support.js';
|
|
27
|
+
|
|
28
|
+
let uid = 0;
|
|
29
|
+
const clamp = (n, a, b) => Math.min(b, Math.max(a, n));
|
|
30
|
+
const escape = (s) => String(s ?? '').replace(/&/g, '&').replace(/</g, '<').replace(/"/g, '"');
|
|
31
|
+
|
|
32
|
+
/** “c97b63”, “#C97B63”, “#abc” → “#c97b63”; null se não for uma cor. */
|
|
33
|
+
export function parseHex(text) {
|
|
34
|
+
const m = String(text ?? '').trim().replace(/^#/, '').toLowerCase();
|
|
35
|
+
if (/^[0-9a-f]{3}$/.test(m)) return `#${m.split('').map((c) => c + c).join('')}`;
|
|
36
|
+
if (/^[0-9a-f]{6}$/.test(m)) return `#${m}`;
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const hexToRgb = (hex) => [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16));
|
|
41
|
+
const rgbToHex = (rgb) => `#${rgb.map((c) => Math.round(c).toString(16).padStart(2, '0')).join('')}`;
|
|
42
|
+
|
|
43
|
+
function rgbToHsv([r, g, b]) {
|
|
44
|
+
const [R, G, B] = [r / 255, g / 255, b / 255];
|
|
45
|
+
const max = Math.max(R, G, B);
|
|
46
|
+
const d = max - Math.min(R, G, B);
|
|
47
|
+
let h = 0;
|
|
48
|
+
if (d) {
|
|
49
|
+
if (max === R) h = ((G - B) / d) % 6;
|
|
50
|
+
else if (max === G) h = (B - R) / d + 2;
|
|
51
|
+
else h = (R - G) / d + 4;
|
|
52
|
+
}
|
|
53
|
+
return { h: (h * 60 + 360) % 360, s: max ? d / max : 0, v: max };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function hsvToRgb({ h, s, v }) {
|
|
57
|
+
const f = (n) => {
|
|
58
|
+
const k = (n + h / 60) % 6;
|
|
59
|
+
return (v - v * s * Math.max(0, Math.min(k, 4 - k, 1))) * 255;
|
|
60
|
+
};
|
|
61
|
+
return [f(5), f(3), f(1)];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Preto ou branco, o que tiver mais contraste sobre a cor (para a marca da amostra). */
|
|
65
|
+
function onColor(hex) {
|
|
66
|
+
const lin = hexToRgb(hex).map((c) => {
|
|
67
|
+
const x = c / 255;
|
|
68
|
+
return x <= 0.04045 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
|
|
69
|
+
});
|
|
70
|
+
const L = 0.2126 * lin[0] + 0.7152 * lin[1] + 0.0722 * lin[2];
|
|
71
|
+
return (L + 0.05) / 0.05 > 1.05 / (L + 0.05) ? '#000' : '#fff';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const normalizeSwatches = (list = []) => list.map((s) => (typeof s === 'string' ? { value: parseHex(s), label: '' } : { value: parseHex(s.value), label: s.label ?? '' })).filter((s) => s.value);
|
|
75
|
+
|
|
76
|
+
export function createColorPicker(root, options = {}) {
|
|
77
|
+
const o = { value: '#000000', swatches: [], ...options };
|
|
78
|
+
root.classList.add('ds-color-picker');
|
|
79
|
+
let hsv = rgbToHsv(hexToRgb(parseHex(o.value) ?? '#000000'));
|
|
80
|
+
let swatches = normalizeSwatches(o.swatches);
|
|
81
|
+
let lastEmitted = '';
|
|
82
|
+
|
|
83
|
+
root.innerHTML = `<div class="ds-color-picker__area" data-part="area"><div class="ds-color-picker__thumb" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="100"></div></div>
|
|
84
|
+
<div class="ds-color-picker__hue" data-part="hue"><div class="ds-color-picker__thumb" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="360"></div></div>
|
|
85
|
+
<div class="ds-color-picker__row">
|
|
86
|
+
<span class="ds-color-picker__preview" aria-hidden="true"></span>
|
|
87
|
+
<div class="ds-field ds-field--sm"><span class="ds-field__affix" aria-hidden="true">#</span><input class="ds-field__input" type="text" maxlength="7" spellcheck="false" autocomplete="off"></div>
|
|
88
|
+
</div>
|
|
89
|
+
<div class="ds-color-picker__swatches" role="group"></div>`;
|
|
90
|
+
|
|
91
|
+
const area = root.querySelector('[data-part="area"]');
|
|
92
|
+
const hue = root.querySelector('[data-part="hue"]');
|
|
93
|
+
const areaThumb = area.firstElementChild;
|
|
94
|
+
const hueThumb = hue.firstElementChild;
|
|
95
|
+
const hexInput = root.querySelector('.ds-field__input');
|
|
96
|
+
const swatchBox = root.querySelector('.ds-color-picker__swatches');
|
|
97
|
+
|
|
98
|
+
const hex = () => rgbToHex(hsvToRgb(hsv));
|
|
99
|
+
// cinza, preto e branco não têm matiz: mantém o da alça, para ela não pular para o vermelho
|
|
100
|
+
const fromHex = (h) => {
|
|
101
|
+
const next = rgbToHsv(hexToRgb(h));
|
|
102
|
+
return next.s && next.v ? next : { ...next, h: hsv.h };
|
|
103
|
+
};
|
|
104
|
+
const pct = (n) => Math.round(n * 100);
|
|
105
|
+
|
|
106
|
+
function renderSwatches() {
|
|
107
|
+
swatchBox.hidden = !swatches.length;
|
|
108
|
+
swatchBox.innerHTML = swatches
|
|
109
|
+
.map((s) => `<button type="button" class="ds-color-picker__swatch" data-swatch="${s.value}" style="--_swatch: ${s.value}; --_on: ${onColor(s.value)}" aria-label="${escape(s.label || s.value.toUpperCase())}" aria-pressed="false">${icon('check', { size: 14 })}</button>`)
|
|
110
|
+
.join('');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function syncTexts() {
|
|
114
|
+
areaThumb.setAttribute('aria-label', msg('color.area'));
|
|
115
|
+
hueThumb.setAttribute('aria-label', msg('color.hue'));
|
|
116
|
+
hexInput.setAttribute('aria-label', msg('color.hex'));
|
|
117
|
+
swatchBox.setAttribute('aria-label', msg('color.swatches'));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function sync({ input = true } = {}) {
|
|
121
|
+
const value = hex();
|
|
122
|
+
root.style.setProperty('--_hue', String(Math.round(hsv.h)));
|
|
123
|
+
root.style.setProperty('--_color', value);
|
|
124
|
+
area.style.setProperty('--_s', String(hsv.s));
|
|
125
|
+
area.style.setProperty('--_v', String(hsv.v));
|
|
126
|
+
areaThumb.setAttribute('aria-valuenow', String(pct(hsv.s)));
|
|
127
|
+
areaThumb.setAttribute('aria-valuetext', msg('color.areaValue', pct(hsv.s), pct(hsv.v)));
|
|
128
|
+
hueThumb.setAttribute('aria-valuenow', String(Math.round(hsv.h)));
|
|
129
|
+
hueThumb.setAttribute('aria-valuetext', `${Math.round(hsv.h)}°`);
|
|
130
|
+
if (input) hexInput.value = value.slice(1).toUpperCase();
|
|
131
|
+
swatchBox.querySelectorAll('[data-swatch]').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.swatch === value)));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const emitInput = () => o.onInput?.(hex());
|
|
135
|
+
const emitChange = () => {
|
|
136
|
+
const value = hex();
|
|
137
|
+
if (value === lastEmitted) return;
|
|
138
|
+
lastEmitted = value;
|
|
139
|
+
o.onChange?.(value);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/* Arrastar na área e no matiz */
|
|
143
|
+
function drag(el, update) {
|
|
144
|
+
const move = (event) => {
|
|
145
|
+
const r = el.getBoundingClientRect();
|
|
146
|
+
update(clamp((event.clientX - r.left) / r.width, 0, 1), clamp((event.clientY - r.top) / r.height, 0, 1));
|
|
147
|
+
sync();
|
|
148
|
+
emitInput();
|
|
149
|
+
};
|
|
150
|
+
const onDown = (event) => {
|
|
151
|
+
if (event.button !== 0) return;
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
el.setPointerCapture(event.pointerId);
|
|
154
|
+
el.setAttribute('data-dragging', '');
|
|
155
|
+
el.firstElementChild.focus({ preventScroll: true });
|
|
156
|
+
move(event);
|
|
157
|
+
const up = () => {
|
|
158
|
+
el.removeAttribute('data-dragging');
|
|
159
|
+
el.removeEventListener('pointermove', move);
|
|
160
|
+
el.removeEventListener('pointerup', up);
|
|
161
|
+
el.removeEventListener('pointercancel', up);
|
|
162
|
+
emitChange();
|
|
163
|
+
};
|
|
164
|
+
el.addEventListener('pointermove', move);
|
|
165
|
+
el.addEventListener('pointerup', up);
|
|
166
|
+
el.addEventListener('pointercancel', up);
|
|
167
|
+
};
|
|
168
|
+
el.addEventListener('pointerdown', onDown);
|
|
169
|
+
return () => el.removeEventListener('pointerdown', onDown);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const undrag = [
|
|
173
|
+
drag(area, (x, y) => {
|
|
174
|
+
hsv = { ...hsv, s: x, v: 1 - y };
|
|
175
|
+
}),
|
|
176
|
+
drag(hue, (x) => {
|
|
177
|
+
hsv = { ...hsv, h: x * 360 };
|
|
178
|
+
}),
|
|
179
|
+
];
|
|
180
|
+
|
|
181
|
+
const onAreaKey = (event) => {
|
|
182
|
+
const step = event.shiftKey ? 0.1 : 0.01;
|
|
183
|
+
const moves = { ArrowLeft: ['s', -step], ArrowRight: ['s', step], ArrowDown: ['v', -step], ArrowUp: ['v', step] };
|
|
184
|
+
const m = moves[event.key];
|
|
185
|
+
if (!m) return;
|
|
186
|
+
event.preventDefault();
|
|
187
|
+
hsv = { ...hsv, [m[0]]: clamp(hsv[m[0]] + m[1], 0, 1) };
|
|
188
|
+
sync();
|
|
189
|
+
emitInput();
|
|
190
|
+
emitChange();
|
|
191
|
+
};
|
|
192
|
+
const onHueKey = (event) => {
|
|
193
|
+
const step = event.shiftKey ? 10 : 1;
|
|
194
|
+
const next = { ArrowLeft: hsv.h - step, ArrowDown: hsv.h - step, ArrowRight: hsv.h + step, ArrowUp: hsv.h + step, Home: 0, End: 359 }[event.key];
|
|
195
|
+
if (next === undefined) return;
|
|
196
|
+
event.preventDefault();
|
|
197
|
+
hsv = { ...hsv, h: clamp(next, 0, 359) };
|
|
198
|
+
sync();
|
|
199
|
+
emitInput();
|
|
200
|
+
emitChange();
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
function commitHex() {
|
|
204
|
+
const parsed = parseHex(hexInput.value);
|
|
205
|
+
if (!parsed) {
|
|
206
|
+
sync();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
hsv = fromHex(parsed);
|
|
210
|
+
sync();
|
|
211
|
+
emitInput();
|
|
212
|
+
emitChange();
|
|
213
|
+
}
|
|
214
|
+
const onHexInput = () => {
|
|
215
|
+
const parsed = hexInput.value.replace(/^#/, '').length === 6 ? parseHex(hexInput.value) : null;
|
|
216
|
+
if (!parsed) return;
|
|
217
|
+
hsv = fromHex(parsed);
|
|
218
|
+
sync({ input: false });
|
|
219
|
+
emitInput();
|
|
220
|
+
};
|
|
221
|
+
const onHexKey = (event) => {
|
|
222
|
+
if (event.key === 'Enter') {
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
commitHex();
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
const onSwatch = (event) => {
|
|
228
|
+
const b = event.target.closest('[data-swatch]');
|
|
229
|
+
if (!b) return;
|
|
230
|
+
hsv = fromHex(b.dataset.swatch);
|
|
231
|
+
sync();
|
|
232
|
+
emitInput();
|
|
233
|
+
emitChange();
|
|
234
|
+
};
|
|
235
|
+
const onLocale = () => {
|
|
236
|
+
syncTexts();
|
|
237
|
+
sync();
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
areaThumb.addEventListener('keydown', onAreaKey);
|
|
241
|
+
hueThumb.addEventListener('keydown', onHueKey);
|
|
242
|
+
hexInput.addEventListener('input', onHexInput);
|
|
243
|
+
hexInput.addEventListener('keydown', onHexKey);
|
|
244
|
+
hexInput.addEventListener('blur', commitHex);
|
|
245
|
+
swatchBox.addEventListener('click', onSwatch);
|
|
246
|
+
document.documentElement.addEventListener('ds:localechange', onLocale);
|
|
247
|
+
|
|
248
|
+
renderSwatches();
|
|
249
|
+
syncTexts();
|
|
250
|
+
sync();
|
|
251
|
+
lastEmitted = hex();
|
|
252
|
+
|
|
253
|
+
return {
|
|
254
|
+
get value() {
|
|
255
|
+
return hex();
|
|
256
|
+
},
|
|
257
|
+
setValue(next) {
|
|
258
|
+
const parsed = parseHex(next);
|
|
259
|
+
if (!parsed) return;
|
|
260
|
+
hsv = fromHex(parsed);
|
|
261
|
+
lastEmitted = parsed;
|
|
262
|
+
sync();
|
|
263
|
+
},
|
|
264
|
+
setSwatches(list) {
|
|
265
|
+
swatches = normalizeSwatches(list);
|
|
266
|
+
renderSwatches();
|
|
267
|
+
sync();
|
|
268
|
+
},
|
|
269
|
+
focus: () => areaThumb.focus(),
|
|
270
|
+
destroy() {
|
|
271
|
+
undrag.forEach((fn) => fn());
|
|
272
|
+
areaThumb.removeEventListener('keydown', onAreaKey);
|
|
273
|
+
hueThumb.removeEventListener('keydown', onHueKey);
|
|
274
|
+
hexInput.removeEventListener('blur', commitHex);
|
|
275
|
+
document.documentElement.removeEventListener('ds:localechange', onLocale);
|
|
276
|
+
root.innerHTML = '';
|
|
277
|
+
root.removeAttribute('style');
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export function createColorField(input, options = {}) {
|
|
283
|
+
const o = { swatches: [], ...options };
|
|
284
|
+
const id = `ds-colorfield-${++uid}`;
|
|
285
|
+
const field = input.closest('.ds-field');
|
|
286
|
+
if (!input.id) input.id = id;
|
|
287
|
+
input.autocomplete = 'off';
|
|
288
|
+
input.spellcheck = false;
|
|
289
|
+
input.maxLength = 7;
|
|
290
|
+
|
|
291
|
+
let value = parseHex(o.value ?? input.value);
|
|
292
|
+
let picker = null;
|
|
293
|
+
|
|
294
|
+
const swatch = document.createElement('button');
|
|
295
|
+
swatch.type = 'button';
|
|
296
|
+
swatch.className = 'ds-color-field__swatch';
|
|
297
|
+
swatch.setAttribute('aria-haspopup', 'dialog');
|
|
298
|
+
swatch.setAttribute('aria-expanded', 'false');
|
|
299
|
+
swatch.setAttribute('aria-controls', `${id}-panel`);
|
|
300
|
+
swatch.disabled = input.disabled;
|
|
301
|
+
input.before(swatch);
|
|
302
|
+
|
|
303
|
+
const panel = document.createElement('div');
|
|
304
|
+
panel.className = 'ds-picker ds-picker--color';
|
|
305
|
+
panel.id = `${id}-panel`;
|
|
306
|
+
panel.setAttribute('role', 'dialog');
|
|
307
|
+
const body = document.createElement('div');
|
|
308
|
+
panel.append(body);
|
|
309
|
+
|
|
310
|
+
const isOpen = () => panel.isConnected;
|
|
311
|
+
|
|
312
|
+
function syncField({ text = true } = {}) {
|
|
313
|
+
if (text) input.value = value ? value.toUpperCase() : '';
|
|
314
|
+
swatch.style.setProperty('--_color', value ?? 'transparent');
|
|
315
|
+
setFieldError(input, null);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function syncTexts() {
|
|
319
|
+
if (!o.placeholder) input.placeholder = '#000000';
|
|
320
|
+
swatch.setAttribute('aria-label', value ? msg('color.openWith', value.toUpperCase()) : msg('color.open'));
|
|
321
|
+
panel.setAttribute('aria-label', msg('color.picker'));
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const emit = () => {
|
|
325
|
+
o.onChange?.(value);
|
|
326
|
+
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
function setValue(next, { notify = false, text = true } = {}) {
|
|
330
|
+
const changed = next !== value;
|
|
331
|
+
value = next;
|
|
332
|
+
syncField({ text });
|
|
333
|
+
syncTexts();
|
|
334
|
+
if (notify && changed) emit();
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function open() {
|
|
338
|
+
if (isOpen() || input.disabled) return;
|
|
339
|
+
inheritTheme(panel, field);
|
|
340
|
+
panelHost(input).append(panel);
|
|
341
|
+
picker = createColorPicker(body, {
|
|
342
|
+
value: value ?? '#000000',
|
|
343
|
+
swatches: o.swatches,
|
|
344
|
+
onInput: (hex) => setValue(hex),
|
|
345
|
+
onChange: (hex) => setValue(hex, { notify: true }),
|
|
346
|
+
});
|
|
347
|
+
placePanel(panel, field);
|
|
348
|
+
swatch.setAttribute('aria-expanded', 'true');
|
|
349
|
+
picker.focus();
|
|
350
|
+
document.addEventListener('pointerdown', onOutside);
|
|
351
|
+
panel.addEventListener('keydown', onPanelKey);
|
|
352
|
+
addEventListener('resize', onReposition);
|
|
353
|
+
document.addEventListener('scroll', onReposition, true);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function close(returnFocus = false) {
|
|
357
|
+
if (!isOpen()) return;
|
|
358
|
+
picker?.destroy();
|
|
359
|
+
picker = null;
|
|
360
|
+
panel.remove();
|
|
361
|
+
swatch.setAttribute('aria-expanded', 'false');
|
|
362
|
+
document.removeEventListener('pointerdown', onOutside);
|
|
363
|
+
panel.removeEventListener('keydown', onPanelKey);
|
|
364
|
+
removeEventListener('resize', onReposition);
|
|
365
|
+
document.removeEventListener('scroll', onReposition, true);
|
|
366
|
+
if (returnFocus) input.focus({ preventScroll: true });
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const onOutside = (event) => {
|
|
370
|
+
if (!panel.contains(event.target) && !field.contains(event.target)) close();
|
|
371
|
+
};
|
|
372
|
+
const onReposition = (event) => {
|
|
373
|
+
if (event?.target && panel.contains(event.target)) return;
|
|
374
|
+
if (field.isConnected) placePanel(panel, field);
|
|
375
|
+
else close();
|
|
376
|
+
};
|
|
377
|
+
const onPanelKey = (event) => {
|
|
378
|
+
if (event.key === 'Escape') {
|
|
379
|
+
event.preventDefault();
|
|
380
|
+
event.stopPropagation();
|
|
381
|
+
close(true);
|
|
382
|
+
} else if (event.key === 'Tab') {
|
|
383
|
+
// sair do painel com Tab fecha, sem prender o foco
|
|
384
|
+
const focusables = [...panel.querySelectorAll('[tabindex="0"], input, button')];
|
|
385
|
+
const edge = event.shiftKey ? focusables[0] : focusables.at(-1);
|
|
386
|
+
if (document.activeElement === edge) {
|
|
387
|
+
event.preventDefault();
|
|
388
|
+
close(true);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
function commitText() {
|
|
394
|
+
const text = input.value.trim();
|
|
395
|
+
if (!text) {
|
|
396
|
+
if (value !== null) setValue(null, { notify: true });
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
const parsed = parseHex(text);
|
|
400
|
+
if (!parsed) {
|
|
401
|
+
setFieldError(input, msg('color.invalid'));
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
setValue(parsed, { notify: true });
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
const onKey = (event) => {
|
|
408
|
+
if (event.key === 'ArrowDown') {
|
|
409
|
+
event.preventDefault();
|
|
410
|
+
open();
|
|
411
|
+
} else if (event.key === 'Enter') commitText();
|
|
412
|
+
};
|
|
413
|
+
const onInputText = () => {
|
|
414
|
+
const parsed = input.value.replace(/^#/, '').length === 6 ? parseHex(input.value) : null;
|
|
415
|
+
if (parsed) {
|
|
416
|
+
swatch.style.setProperty('--_color', parsed);
|
|
417
|
+
picker?.setValue(parsed);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
const onSwatchClick = () => (isOpen() ? close(true) : open());
|
|
421
|
+
const onLocale = () => syncTexts();
|
|
422
|
+
|
|
423
|
+
input.addEventListener('keydown', onKey);
|
|
424
|
+
input.addEventListener('input', onInputText);
|
|
425
|
+
input.addEventListener('blur', commitText);
|
|
426
|
+
swatch.addEventListener('click', onSwatchClick);
|
|
427
|
+
document.documentElement.addEventListener('ds:localechange', onLocale);
|
|
428
|
+
|
|
429
|
+
syncField();
|
|
430
|
+
syncTexts();
|
|
431
|
+
|
|
432
|
+
return {
|
|
433
|
+
get value() {
|
|
434
|
+
return value;
|
|
435
|
+
},
|
|
436
|
+
setValue: (next) => setValue(parseHex(next)),
|
|
437
|
+
open,
|
|
438
|
+
close: () => close(),
|
|
439
|
+
destroy() {
|
|
440
|
+
close();
|
|
441
|
+
swatch.remove();
|
|
442
|
+
input.removeEventListener('keydown', onKey);
|
|
443
|
+
input.removeEventListener('input', onInputText);
|
|
444
|
+
input.removeEventListener('blur', commitText);
|
|
445
|
+
document.documentElement.removeEventListener('ds:localechange', onLocale);
|
|
446
|
+
},
|
|
447
|
+
};
|
|
448
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paleta de comandos (⌘K / Ctrl K / "/").
|
|
3
|
+
*
|
|
4
|
+
* const palette = createCommandPalette({
|
|
5
|
+
* items: () => [{ id, label, group, icon, keywords?, description?, hint?, perform }],
|
|
6
|
+
* placeholder: 'Buscar…',
|
|
7
|
+
* label: 'Busca rápida', // nome do diálogo para leitores de tela
|
|
8
|
+
* hotkeys: true, // false = só abre por palette.open() (ex.: uma paleta de demonstração)
|
|
9
|
+
* });
|
|
10
|
+
* palette.open(); palette.close(); palette.destroy(); palette.modifierLabel // '⌘' ou 'Ctrl'
|
|
11
|
+
*
|
|
12
|
+
* filterCommands(items, query) → itens encontrados, na ordem da paleta (útil para testar a busca).
|
|
13
|
+
* Padrão ARIA: combobox + listbox com aria-activedescendant.
|
|
14
|
+
*/
|
|
15
|
+
import { icon } from '../icons/icons.js';
|
|
16
|
+
import { msg } from './i18n.js';
|
|
17
|
+
|
|
18
|
+
const normalize = (s) =>
|
|
19
|
+
String(s ?? '')
|
|
20
|
+
.normalize('NFD')
|
|
21
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
22
|
+
.toLowerCase();
|
|
23
|
+
|
|
24
|
+
const escape = (s) => String(s).replace(/&/g, '&').replace(/</g, '<').replace(/"/g, '"');
|
|
25
|
+
const isTyping = (el) => el?.closest?.('input, textarea, select, [contenteditable="true"]');
|
|
26
|
+
const isMac = navigator.platform.includes('Mac');
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Sem acento e sem maiúscula; todas as palavras precisam aparecer (rótulo, grupo, descrição ou keywords).
|
|
30
|
+
* Ordem: rótulo que começa com a busca (3) → rótulo que contém (2) → só nos outros campos (1).
|
|
31
|
+
*/
|
|
32
|
+
export function scoreCommand(item, query) {
|
|
33
|
+
const words = normalize(query).trim().split(/\s+/).filter(Boolean);
|
|
34
|
+
if (!words.length) return 0;
|
|
35
|
+
const full = words.join(' ');
|
|
36
|
+
const label = normalize(item.label);
|
|
37
|
+
const haystack = `${label} ${normalize(item.group)} ${normalize(item.description)} ${normalize((item.keywords ?? []).join(' '))}`;
|
|
38
|
+
if (!words.every((w) => haystack.includes(w))) return -1;
|
|
39
|
+
return label.startsWith(full) ? 3 : label.includes(full) ? 2 : 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function filterCommands(items, query) {
|
|
43
|
+
if (!normalize(query).trim()) return items;
|
|
44
|
+
return items
|
|
45
|
+
.map((item) => ({ item, score: scoreCommand(item, query) }))
|
|
46
|
+
.filter((r) => r.score > 0)
|
|
47
|
+
.sort((a, b) => b.score - a.score)
|
|
48
|
+
.map((r) => r.item);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let instances = 0;
|
|
52
|
+
|
|
53
|
+
export function createCommandPalette({ items = [], placeholder, label, hotkeys = true } = {}) {
|
|
54
|
+
// a primeira paleta mantém os ids de sempre; as outras ganham sufixo (sem ids repetidos)
|
|
55
|
+
const n = ++instances;
|
|
56
|
+
const pre = n === 1 ? 'ds-command' : `ds-command-${n}`;
|
|
57
|
+
const dialog = document.createElement('dialog');
|
|
58
|
+
dialog.className = 'ds-command';
|
|
59
|
+
dialog.innerHTML = `
|
|
60
|
+
<div class="ds-command__search">
|
|
61
|
+
${icon('search', { size: 20 })}
|
|
62
|
+
<input class="ds-command__input" type="text" role="combobox" aria-expanded="true" aria-controls="${pre}-list"
|
|
63
|
+
aria-autocomplete="list" autocomplete="off" spellcheck="false">
|
|
64
|
+
<kbd class="ds-kbd">Esc</kbd>
|
|
65
|
+
</div>
|
|
66
|
+
<div class="ds-command__list" id="${pre}-list" role="listbox"></div>
|
|
67
|
+
<footer class="ds-command__footer" aria-hidden="true">
|
|
68
|
+
<span><kbd class="ds-kbd">↑</kbd><kbd class="ds-kbd">↓</kbd> <span data-label="navigate"></span></span>
|
|
69
|
+
<span><kbd class="ds-kbd">↵</kbd> <span data-label="open"></span></span>
|
|
70
|
+
<span><kbd class="ds-kbd">Esc</kbd> <span data-label="close"></span></span>
|
|
71
|
+
</footer>`;
|
|
72
|
+
document.body.append(dialog);
|
|
73
|
+
|
|
74
|
+
const input = dialog.querySelector('.ds-command__input');
|
|
75
|
+
const list = dialog.querySelector('.ds-command__list');
|
|
76
|
+
|
|
77
|
+
// textos no idioma atual, refeitos quando o idioma muda; label e placeholder aceitam função para acompanhar também
|
|
78
|
+
const text = (value, key) => (typeof value === 'function' ? value() : value ?? msg(key));
|
|
79
|
+
function labels() {
|
|
80
|
+
const name = text(label, 'palette.label');
|
|
81
|
+
dialog.setAttribute('aria-label', name);
|
|
82
|
+
input.setAttribute('aria-label', name);
|
|
83
|
+
input.placeholder = text(placeholder, 'palette.placeholder');
|
|
84
|
+
list.setAttribute('aria-label', msg('palette.results'));
|
|
85
|
+
dialog.querySelectorAll('[data-label]').forEach((el) => (el.textContent = msg(`palette.${el.dataset.label}`)));
|
|
86
|
+
if (dialog.open) render();
|
|
87
|
+
}
|
|
88
|
+
labels();
|
|
89
|
+
document.documentElement.addEventListener('ds:localechange', labels);
|
|
90
|
+
let results = [];
|
|
91
|
+
let active = 0;
|
|
92
|
+
let returnFocus = null;
|
|
93
|
+
|
|
94
|
+
function render() {
|
|
95
|
+
const found = filterCommands(typeof items === 'function' ? items() : items, input.value);
|
|
96
|
+
|
|
97
|
+
// agrupa mantendo a ordem de aparição; "results" segue a ordem visual
|
|
98
|
+
const groups = new Map();
|
|
99
|
+
for (const item of found) {
|
|
100
|
+
if (!groups.has(item.group)) groups.set(item.group, []);
|
|
101
|
+
groups.get(item.group).push(item);
|
|
102
|
+
}
|
|
103
|
+
results = [...groups.values()].flat();
|
|
104
|
+
active = Math.min(active, Math.max(results.length - 1, 0));
|
|
105
|
+
|
|
106
|
+
if (!results.length) {
|
|
107
|
+
list.innerHTML = `<p class="ds-command__empty">${escape(msg('palette.empty', input.value))}</p>`;
|
|
108
|
+
input.removeAttribute('aria-activedescendant');
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
let index = 0;
|
|
113
|
+
list.innerHTML = [...groups]
|
|
114
|
+
.map(([group, entries], g) => {
|
|
115
|
+
const options = entries
|
|
116
|
+
.map((item) => {
|
|
117
|
+
const i = index++;
|
|
118
|
+
return `<div class="ds-command__item" role="option" id="${pre}-option-${i}" data-index="${i}" aria-selected="false">
|
|
119
|
+
${icon(item.icon ?? 'arrow-right', { size: 18 })}
|
|
120
|
+
<span class="ds-command__label">${escape(item.label)}</span>
|
|
121
|
+
${item.hint ? `<span class="ds-command__hint">${escape(item.hint)}</span>` : ''}
|
|
122
|
+
${icon('corner-down-left', { size: 16, className: 'ds-command__enter' })}
|
|
123
|
+
</div>`;
|
|
124
|
+
})
|
|
125
|
+
.join('');
|
|
126
|
+
return `<div class="ds-command__group" role="group" aria-labelledby="${pre}-group-${g}">
|
|
127
|
+
<div class="ds-command__group-label" id="${pre}-group-${g}">${escape(group)}</div>${options}</div>`;
|
|
128
|
+
})
|
|
129
|
+
.join('');
|
|
130
|
+
highlight(true);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function highlight(scroll) {
|
|
134
|
+
list.querySelectorAll('[role="option"]').forEach((el) => {
|
|
135
|
+
el.setAttribute('aria-selected', String(Number(el.dataset.index) === active));
|
|
136
|
+
});
|
|
137
|
+
const el = list.querySelector(`[data-index="${active}"]`);
|
|
138
|
+
if (!el) return;
|
|
139
|
+
input.setAttribute('aria-activedescendant', el.id);
|
|
140
|
+
if (scroll) el.scrollIntoView({ block: 'nearest' });
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function open() {
|
|
144
|
+
if (dialog.open) return;
|
|
145
|
+
returnFocus = document.activeElement;
|
|
146
|
+
input.value = '';
|
|
147
|
+
active = 0;
|
|
148
|
+
render();
|
|
149
|
+
dialog.showModal();
|
|
150
|
+
input.focus();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function close() {
|
|
154
|
+
if (dialog.open) dialog.close();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function run(item) {
|
|
158
|
+
if (!item) return;
|
|
159
|
+
returnFocus = null;
|
|
160
|
+
close();
|
|
161
|
+
item.perform();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
input.addEventListener('input', () => {
|
|
165
|
+
active = 0;
|
|
166
|
+
render();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
input.addEventListener('keydown', (event) => {
|
|
170
|
+
const n = results.length;
|
|
171
|
+
if (!n) return;
|
|
172
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
active = (active + (event.key === 'ArrowDown' ? 1 : -1) + n) % n;
|
|
175
|
+
highlight(true);
|
|
176
|
+
} else if (event.key === 'Enter') {
|
|
177
|
+
event.preventDefault();
|
|
178
|
+
run(results[active]);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
list.addEventListener('click', (event) => {
|
|
183
|
+
const option = event.target.closest('[role="option"]');
|
|
184
|
+
if (option) run(results[Number(option.dataset.index)]);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
list.addEventListener('pointermove', (event) => {
|
|
188
|
+
const option = event.target.closest('[role="option"]');
|
|
189
|
+
if (option && Number(option.dataset.index) !== active) {
|
|
190
|
+
active = Number(option.dataset.index);
|
|
191
|
+
highlight(false);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// clique fora do painel (no backdrop)
|
|
196
|
+
dialog.addEventListener('click', (event) => {
|
|
197
|
+
if (event.target === dialog) close();
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
dialog.addEventListener('close', () => {
|
|
201
|
+
returnFocus?.focus?.({ preventScroll: true });
|
|
202
|
+
returnFocus = null;
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
const onKey = (event) => {
|
|
206
|
+
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 'k' && !event.defaultPrevented) {
|
|
207
|
+
event.preventDefault();
|
|
208
|
+
dialog.open ? close() : open();
|
|
209
|
+
} else if (event.key === '/' && !dialog.open && !isTyping(event.target)) {
|
|
210
|
+
event.preventDefault();
|
|
211
|
+
open();
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
if (hotkeys) document.addEventListener('keydown', onKey);
|
|
215
|
+
|
|
216
|
+
function destroy() {
|
|
217
|
+
document.removeEventListener('keydown', onKey);
|
|
218
|
+
document.documentElement.removeEventListener('ds:localechange', labels);
|
|
219
|
+
close();
|
|
220
|
+
dialog.remove();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return {
|
|
224
|
+
open,
|
|
225
|
+
close,
|
|
226
|
+
destroy,
|
|
227
|
+
/** A paleta está aberta. */
|
|
228
|
+
get isOpen() {
|
|
229
|
+
return dialog.open;
|
|
230
|
+
},
|
|
231
|
+
modifierLabel: isMac ? '⌘' : 'Ctrl',
|
|
232
|
+
};
|
|
233
|
+
}
|