@moyarich/console-addon-selection 0.1.0 → 0.2.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/README.md +7 -1
- package/dist/components/SelectedMessageIndicator/SelectedMessageIndicator.d.cts +6 -0
- package/dist/components/SelectedMessageIndicator/SelectedMessageIndicator.d.ts +5 -1
- package/dist/index.cjs +68 -10
- package/dist/index.d.cts +35 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +69 -11
- package/dist/locales/en.json +6 -0
- package/dist/locales/es.json +6 -0
- package/dist/locales/fr.json +6 -0
- package/dist/locales/pt.json +6 -0
- package/dist/localization.d.cts +4 -0
- package/dist/localization.d.ts +4 -0
- package/package.json +15 -8
package/README.md
CHANGED
|
@@ -2,12 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Select Console messages. Select message IDs individually or in visible ranges, with optional message actions and decorations.
|
|
4
4
|
|
|
5
|
+
[Documentation and live examples](https://moyarich.github.io/console/)
|
|
6
|
+
|
|
5
7
|
## Install
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
|
-
npm install @moyarich/console @moyarich/console-addon-selection
|
|
10
|
+
npm install @moyarich/console @moyarich/console-addon-selection react
|
|
9
11
|
```
|
|
10
12
|
|
|
13
|
+
Configure the `@moyarich` scope and authenticate with GitHub Packages as described in the [installation guide](../../../README.md#installation).
|
|
14
|
+
|
|
15
|
+
Required peer dependencies: `@moyarich/console-core@^0.2.0`, `react@>=18`.
|
|
16
|
+
|
|
11
17
|
## Quick start
|
|
12
18
|
|
|
13
19
|
```tsx
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type AddonTranslations } from "../../localization.cjs";
|
|
2
|
+
/** Default selection indicator. No stylesheet or addon runtime required. */
|
|
3
|
+
export declare function SelectedMessageIndicator({ locale, translations, }?: {
|
|
4
|
+
locale?: string;
|
|
5
|
+
translations?: AddonTranslations;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
import { type AddonTranslations } from "../../localization.js";
|
|
1
2
|
/** Default selection indicator. No stylesheet or addon runtime required. */
|
|
2
|
-
export declare function SelectedMessageIndicator(
|
|
3
|
+
export declare function SelectedMessageIndicator({ locale, translations, }?: {
|
|
4
|
+
locale?: string;
|
|
5
|
+
translations?: AddonTranslations;
|
|
6
|
+
}): import("react").JSX.Element;
|
package/dist/index.cjs
CHANGED
|
@@ -2,12 +2,65 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const consoleCore = require("@moyarich/console-core");
|
|
5
|
-
|
|
5
|
+
const selectedMessage$3 = "Selected message";
|
|
6
|
+
const selected$3 = "Selected";
|
|
7
|
+
const toggleSelection$3 = "Toggle selection";
|
|
8
|
+
const toggleMessageSelection$3 = "Toggle message selection";
|
|
9
|
+
const en = {
|
|
10
|
+
selectedMessage: selectedMessage$3,
|
|
11
|
+
selected: selected$3,
|
|
12
|
+
toggleSelection: toggleSelection$3,
|
|
13
|
+
toggleMessageSelection: toggleMessageSelection$3
|
|
14
|
+
};
|
|
15
|
+
const selectedMessage$2 = "Mensaje seleccionado";
|
|
16
|
+
const selected$2 = "Seleccionado";
|
|
17
|
+
const toggleSelection$2 = "Alternar selección";
|
|
18
|
+
const toggleMessageSelection$2 = "Alternar selección del mensaje";
|
|
19
|
+
const es = {
|
|
20
|
+
selectedMessage: selectedMessage$2,
|
|
21
|
+
selected: selected$2,
|
|
22
|
+
toggleSelection: toggleSelection$2,
|
|
23
|
+
toggleMessageSelection: toggleMessageSelection$2
|
|
24
|
+
};
|
|
25
|
+
const selectedMessage$1 = "Message sélectionné";
|
|
26
|
+
const selected$1 = "Sélectionné";
|
|
27
|
+
const toggleSelection$1 = "Activer/désactiver la sélection";
|
|
28
|
+
const toggleMessageSelection$1 = "Activer/désactiver la sélection du message";
|
|
29
|
+
const fr = {
|
|
30
|
+
selectedMessage: selectedMessage$1,
|
|
31
|
+
selected: selected$1,
|
|
32
|
+
toggleSelection: toggleSelection$1,
|
|
33
|
+
toggleMessageSelection: toggleMessageSelection$1
|
|
34
|
+
};
|
|
35
|
+
const selectedMessage = "Mensagem selecionada";
|
|
36
|
+
const selected = "Selecionado";
|
|
37
|
+
const toggleSelection = "Alternar seleção";
|
|
38
|
+
const toggleMessageSelection = "Alternar seleção da mensagem";
|
|
39
|
+
const pt = {
|
|
40
|
+
selectedMessage,
|
|
41
|
+
selected,
|
|
42
|
+
toggleSelection,
|
|
43
|
+
toggleMessageSelection
|
|
44
|
+
};
|
|
45
|
+
const dictionaries = { en, es, fr, pt };
|
|
46
|
+
function resolveAddonMessages(locale = "en", overrides) {
|
|
47
|
+
const tag = locale.replace(/_/g, "-").toLowerCase();
|
|
48
|
+
return {
|
|
49
|
+
...en,
|
|
50
|
+
...dictionaries[tag] ?? dictionaries[tag.split("-")[0]] ?? {},
|
|
51
|
+
...overrides
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function SelectedMessageIndicator({
|
|
55
|
+
locale = "en",
|
|
56
|
+
translations
|
|
57
|
+
} = {}) {
|
|
58
|
+
const t = resolveAddonMessages(locale, translations);
|
|
6
59
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7
60
|
"span",
|
|
8
61
|
{
|
|
9
|
-
"aria-label":
|
|
10
|
-
title:
|
|
62
|
+
"aria-label": t.selectedMessage,
|
|
63
|
+
title: t.selected,
|
|
11
64
|
style: { fontSize: 12, lineHeight: 1 },
|
|
12
65
|
children: "●"
|
|
13
66
|
}
|
|
@@ -112,7 +165,7 @@ function createConsoleSelectionController(getData = () => void 0) {
|
|
|
112
165
|
};
|
|
113
166
|
return controller;
|
|
114
167
|
}
|
|
115
|
-
function createDecoration(controller) {
|
|
168
|
+
function createDecoration(controller, locale, translations) {
|
|
116
169
|
return {
|
|
117
170
|
id: `${CONSOLE_SELECTION_ADDON_ID}:selected`,
|
|
118
171
|
placement: "gutter",
|
|
@@ -121,15 +174,15 @@ function createDecoration(controller) {
|
|
|
121
174
|
},
|
|
122
175
|
render({ message }) {
|
|
123
176
|
if (!message.id || !controller.isSelected(message.id)) return void 0;
|
|
124
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SelectedMessageIndicator, {});
|
|
177
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectedMessageIndicator, { locale, translations });
|
|
125
178
|
}
|
|
126
179
|
};
|
|
127
180
|
}
|
|
128
|
-
function createMessageAction(controller) {
|
|
181
|
+
function createMessageAction(controller, locale, translations) {
|
|
129
182
|
return {
|
|
130
183
|
id: `${CONSOLE_SELECTION_ADDON_ID}:toggle`,
|
|
131
|
-
label:
|
|
132
|
-
ariaLabel:
|
|
184
|
+
label: resolveAddonMessages(locale, translations).toggleSelection,
|
|
185
|
+
ariaLabel: resolveAddonMessages(locale, translations).toggleMessageSelection,
|
|
133
186
|
visible({ message }) {
|
|
134
187
|
return Boolean(message.id);
|
|
135
188
|
},
|
|
@@ -157,14 +210,18 @@ function createConsoleSelectionAddon(options = {}) {
|
|
|
157
210
|
if (withDecoration) {
|
|
158
211
|
decorationRegistration = host.extensions.register(
|
|
159
212
|
consoleCore.consoleExtensionPoints.messageDecoration,
|
|
160
|
-
createDecoration(controller),
|
|
213
|
+
createDecoration(controller, options.locale, options.translations),
|
|
161
214
|
{ id: `${CONSOLE_SELECTION_ADDON_ID}:selected` }
|
|
162
215
|
);
|
|
163
216
|
}
|
|
164
217
|
if (withMessageAction) {
|
|
165
218
|
actionRegistration = host.extensions.register(
|
|
166
219
|
consoleCore.consoleExtensionPoints.messageAction,
|
|
167
|
-
createMessageAction(
|
|
220
|
+
createMessageAction(
|
|
221
|
+
controller,
|
|
222
|
+
options.locale,
|
|
223
|
+
options.translations
|
|
224
|
+
),
|
|
168
225
|
{ id: `${CONSOLE_SELECTION_ADDON_ID}:toggle` }
|
|
169
226
|
);
|
|
170
227
|
}
|
|
@@ -184,3 +241,4 @@ exports.SelectedMessageIndicator = SelectedMessageIndicator;
|
|
|
184
241
|
exports.consoleSelectionService = consoleSelectionService;
|
|
185
242
|
exports.createConsoleSelectionAddon = createConsoleSelectionAddon;
|
|
186
243
|
exports.createConsoleSelectionController = createConsoleSelectionController;
|
|
244
|
+
exports.resolveConsoleSelectionMessages = resolveAddonMessages;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type AddonTranslations } from "./localization.cjs";
|
|
2
|
+
export { resolveAddonMessages as resolveConsoleSelectionMessages } from "./localization.cjs";
|
|
3
|
+
export type { AddonTranslations as ConsoleSelectionTranslations } from "./localization.cjs";
|
|
4
|
+
export { SelectedMessageIndicator } from "./components/SelectedMessageIndicator/SelectedMessageIndicator.cjs";
|
|
5
|
+
import { type ConsoleAddon, type ConsoleDataService } from "@moyarich/console-core";
|
|
6
|
+
export declare const CONSOLE_SELECTION_ADDON_ID = "@moyarich/console-addon-selection";
|
|
7
|
+
export interface ConsoleSelectionState {
|
|
8
|
+
readonly selectedIds: readonly string[];
|
|
9
|
+
readonly anchorId?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ConsoleSelectionController {
|
|
12
|
+
getState(): ConsoleSelectionState;
|
|
13
|
+
subscribe(listener: () => void): () => void;
|
|
14
|
+
isSelected(id: string): boolean;
|
|
15
|
+
select(id: string, additive?: boolean): boolean;
|
|
16
|
+
deselect(id: string): boolean;
|
|
17
|
+
toggle(id: string): boolean;
|
|
18
|
+
clear(): void;
|
|
19
|
+
setSelectedIds(ids: readonly string[]): void;
|
|
20
|
+
selectRange(fromId: string, toId: string): readonly string[];
|
|
21
|
+
getVisibleSelectedIds(): readonly string[];
|
|
22
|
+
}
|
|
23
|
+
export interface ConsoleSelectionAddonOptions {
|
|
24
|
+
locale?: string;
|
|
25
|
+
translations?: AddonTranslations;
|
|
26
|
+
controller?: ConsoleSelectionController;
|
|
27
|
+
decoration?: boolean;
|
|
28
|
+
messageAction?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface ConsoleSelectionAddon extends ConsoleAddon {
|
|
31
|
+
readonly controller: ConsoleSelectionController;
|
|
32
|
+
}
|
|
33
|
+
export declare const consoleSelectionService: import("@moyarich/console-core").ConsoleServiceToken<ConsoleSelectionController>;
|
|
34
|
+
export declare function createConsoleSelectionController(getData?: () => ConsoleDataService | undefined): ConsoleSelectionController;
|
|
35
|
+
export declare function createConsoleSelectionAddon(options?: ConsoleSelectionAddonOptions): ConsoleSelectionAddon;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { type AddonTranslations } from "./localization.js";
|
|
2
|
+
export { resolveAddonMessages as resolveConsoleSelectionMessages } from "./localization.js";
|
|
3
|
+
export type { AddonTranslations as ConsoleSelectionTranslations } from "./localization.js";
|
|
4
|
+
export { SelectedMessageIndicator } from "./components/SelectedMessageIndicator/SelectedMessageIndicator.js";
|
|
2
5
|
import { type ConsoleAddon, type ConsoleDataService } from "@moyarich/console-core";
|
|
3
6
|
export declare const CONSOLE_SELECTION_ADDON_ID = "@moyarich/console-addon-selection";
|
|
4
7
|
export interface ConsoleSelectionState {
|
|
@@ -18,6 +21,8 @@ export interface ConsoleSelectionController {
|
|
|
18
21
|
getVisibleSelectedIds(): readonly string[];
|
|
19
22
|
}
|
|
20
23
|
export interface ConsoleSelectionAddonOptions {
|
|
24
|
+
locale?: string;
|
|
25
|
+
translations?: AddonTranslations;
|
|
21
26
|
controller?: ConsoleSelectionController;
|
|
22
27
|
decoration?: boolean;
|
|
23
28
|
messageAction?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,64 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createConsoleServiceToken, consoleServices, consoleExtensionPoints } from "@moyarich/console-core";
|
|
3
|
-
|
|
3
|
+
const selectedMessage$3 = "Selected message";
|
|
4
|
+
const selected$3 = "Selected";
|
|
5
|
+
const toggleSelection$3 = "Toggle selection";
|
|
6
|
+
const toggleMessageSelection$3 = "Toggle message selection";
|
|
7
|
+
const en = {
|
|
8
|
+
selectedMessage: selectedMessage$3,
|
|
9
|
+
selected: selected$3,
|
|
10
|
+
toggleSelection: toggleSelection$3,
|
|
11
|
+
toggleMessageSelection: toggleMessageSelection$3
|
|
12
|
+
};
|
|
13
|
+
const selectedMessage$2 = "Mensaje seleccionado";
|
|
14
|
+
const selected$2 = "Seleccionado";
|
|
15
|
+
const toggleSelection$2 = "Alternar selección";
|
|
16
|
+
const toggleMessageSelection$2 = "Alternar selección del mensaje";
|
|
17
|
+
const es = {
|
|
18
|
+
selectedMessage: selectedMessage$2,
|
|
19
|
+
selected: selected$2,
|
|
20
|
+
toggleSelection: toggleSelection$2,
|
|
21
|
+
toggleMessageSelection: toggleMessageSelection$2
|
|
22
|
+
};
|
|
23
|
+
const selectedMessage$1 = "Message sélectionné";
|
|
24
|
+
const selected$1 = "Sélectionné";
|
|
25
|
+
const toggleSelection$1 = "Activer/désactiver la sélection";
|
|
26
|
+
const toggleMessageSelection$1 = "Activer/désactiver la sélection du message";
|
|
27
|
+
const fr = {
|
|
28
|
+
selectedMessage: selectedMessage$1,
|
|
29
|
+
selected: selected$1,
|
|
30
|
+
toggleSelection: toggleSelection$1,
|
|
31
|
+
toggleMessageSelection: toggleMessageSelection$1
|
|
32
|
+
};
|
|
33
|
+
const selectedMessage = "Mensagem selecionada";
|
|
34
|
+
const selected = "Selecionado";
|
|
35
|
+
const toggleSelection = "Alternar seleção";
|
|
36
|
+
const toggleMessageSelection = "Alternar seleção da mensagem";
|
|
37
|
+
const pt = {
|
|
38
|
+
selectedMessage,
|
|
39
|
+
selected,
|
|
40
|
+
toggleSelection,
|
|
41
|
+
toggleMessageSelection
|
|
42
|
+
};
|
|
43
|
+
const dictionaries = { en, es, fr, pt };
|
|
44
|
+
function resolveAddonMessages(locale = "en", overrides) {
|
|
45
|
+
const tag = locale.replace(/_/g, "-").toLowerCase();
|
|
46
|
+
return {
|
|
47
|
+
...en,
|
|
48
|
+
...dictionaries[tag] ?? dictionaries[tag.split("-")[0]] ?? {},
|
|
49
|
+
...overrides
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function SelectedMessageIndicator({
|
|
53
|
+
locale = "en",
|
|
54
|
+
translations
|
|
55
|
+
} = {}) {
|
|
56
|
+
const t = resolveAddonMessages(locale, translations);
|
|
4
57
|
return /* @__PURE__ */ jsx(
|
|
5
58
|
"span",
|
|
6
59
|
{
|
|
7
|
-
"aria-label":
|
|
8
|
-
title:
|
|
60
|
+
"aria-label": t.selectedMessage,
|
|
61
|
+
title: t.selected,
|
|
9
62
|
style: { fontSize: 12, lineHeight: 1 },
|
|
10
63
|
children: "●"
|
|
11
64
|
}
|
|
@@ -110,7 +163,7 @@ function createConsoleSelectionController(getData = () => void 0) {
|
|
|
110
163
|
};
|
|
111
164
|
return controller;
|
|
112
165
|
}
|
|
113
|
-
function createDecoration(controller) {
|
|
166
|
+
function createDecoration(controller, locale, translations) {
|
|
114
167
|
return {
|
|
115
168
|
id: `${CONSOLE_SELECTION_ADDON_ID}:selected`,
|
|
116
169
|
placement: "gutter",
|
|
@@ -119,15 +172,15 @@ function createDecoration(controller) {
|
|
|
119
172
|
},
|
|
120
173
|
render({ message }) {
|
|
121
174
|
if (!message.id || !controller.isSelected(message.id)) return void 0;
|
|
122
|
-
return /* @__PURE__ */ jsx(SelectedMessageIndicator, {});
|
|
175
|
+
return /* @__PURE__ */ jsx(SelectedMessageIndicator, { locale, translations });
|
|
123
176
|
}
|
|
124
177
|
};
|
|
125
178
|
}
|
|
126
|
-
function createMessageAction(controller) {
|
|
179
|
+
function createMessageAction(controller, locale, translations) {
|
|
127
180
|
return {
|
|
128
181
|
id: `${CONSOLE_SELECTION_ADDON_ID}:toggle`,
|
|
129
|
-
label:
|
|
130
|
-
ariaLabel:
|
|
182
|
+
label: resolveAddonMessages(locale, translations).toggleSelection,
|
|
183
|
+
ariaLabel: resolveAddonMessages(locale, translations).toggleMessageSelection,
|
|
131
184
|
visible({ message }) {
|
|
132
185
|
return Boolean(message.id);
|
|
133
186
|
},
|
|
@@ -155,14 +208,18 @@ function createConsoleSelectionAddon(options = {}) {
|
|
|
155
208
|
if (withDecoration) {
|
|
156
209
|
decorationRegistration = host.extensions.register(
|
|
157
210
|
consoleExtensionPoints.messageDecoration,
|
|
158
|
-
createDecoration(controller),
|
|
211
|
+
createDecoration(controller, options.locale, options.translations),
|
|
159
212
|
{ id: `${CONSOLE_SELECTION_ADDON_ID}:selected` }
|
|
160
213
|
);
|
|
161
214
|
}
|
|
162
215
|
if (withMessageAction) {
|
|
163
216
|
actionRegistration = host.extensions.register(
|
|
164
217
|
consoleExtensionPoints.messageAction,
|
|
165
|
-
createMessageAction(
|
|
218
|
+
createMessageAction(
|
|
219
|
+
controller,
|
|
220
|
+
options.locale,
|
|
221
|
+
options.translations
|
|
222
|
+
),
|
|
166
223
|
{ id: `${CONSOLE_SELECTION_ADDON_ID}:toggle` }
|
|
167
224
|
);
|
|
168
225
|
}
|
|
@@ -182,5 +239,6 @@ export {
|
|
|
182
239
|
SelectedMessageIndicator,
|
|
183
240
|
consoleSelectionService,
|
|
184
241
|
createConsoleSelectionAddon,
|
|
185
|
-
createConsoleSelectionController
|
|
242
|
+
createConsoleSelectionController,
|
|
243
|
+
resolveAddonMessages as resolveConsoleSelectionMessages
|
|
186
244
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moyarich/console-addon-selection",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "First-party semantic output selection for @moyarich/console hosts.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -9,10 +9,14 @@
|
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./dist/index.d.cts",
|
|
18
|
+
"default": "./dist/index.cjs"
|
|
19
|
+
}
|
|
16
20
|
}
|
|
17
21
|
},
|
|
18
22
|
"files": [
|
|
@@ -22,15 +26,15 @@
|
|
|
22
26
|
"registry": "https://npm.pkg.github.com"
|
|
23
27
|
},
|
|
24
28
|
"scripts": {
|
|
25
|
-
"build": "vite build && tsc -p tsconfig.build.json",
|
|
29
|
+
"build": "vite build && tsc -p tsconfig.build.json && node ../../../scripts/prepare-cjs-types.mjs",
|
|
26
30
|
"typecheck": "tsc --noEmit"
|
|
27
31
|
},
|
|
28
32
|
"peerDependencies": {
|
|
29
|
-
"@moyarich/console-core": "^0.
|
|
33
|
+
"@moyarich/console-core": "^0.2.0",
|
|
30
34
|
"react": ">=18"
|
|
31
35
|
},
|
|
32
36
|
"devDependencies": {
|
|
33
|
-
"@moyarich/console-core": "0.
|
|
37
|
+
"@moyarich/console-core": "0.2.0",
|
|
34
38
|
"@types/react": "^19.1.12",
|
|
35
39
|
"react": "^19.2.7",
|
|
36
40
|
"typescript": "^5.9.2",
|
|
@@ -53,5 +57,8 @@
|
|
|
53
57
|
],
|
|
54
58
|
"publisher": "moyarich",
|
|
55
59
|
"author": "Moya Richards",
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=24"
|
|
62
|
+
},
|
|
56
63
|
"private": false
|
|
57
64
|
}
|