@univerjs/ui 1.0.3 → 1.0.4
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/lib/cjs/facade.js +4 -1
- package/lib/cjs/index.js +27 -17
- package/lib/es/facade.js +4 -1
- package/lib/es/index.js +27 -17
- package/lib/facade.js +4 -1
- package/lib/index.css +5 -0
- package/lib/index.js +27 -17
- package/lib/types/common/component-manager.d.ts +17 -1
- package/lib/types/facade/f-univer.d.ts +5 -3
- package/lib/types/views/components/ribbon/ToolbarButton.d.ts +1 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +4 -4
- package/package.json +7 -7
package/lib/cjs/facade.js
CHANGED
|
@@ -434,7 +434,10 @@ var FUniverUIMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
434
434
|
}
|
|
435
435
|
registerComponent(name, component, options) {
|
|
436
436
|
const componentManager = this._injector.get(_univerjs_ui.ComponentManager);
|
|
437
|
-
return this.disposeWithMe(componentManager.register(name, component,
|
|
437
|
+
return this.disposeWithMe(componentManager.register(name, component, {
|
|
438
|
+
...options,
|
|
439
|
+
override: (options === null || options === void 0 ? void 0 : options.override) ?? true
|
|
440
|
+
}));
|
|
438
441
|
}
|
|
439
442
|
setCurrent(unitId) {
|
|
440
443
|
if (!this._injector.get(_univerjs_engine_render.IRenderManagerService).getRenderUnitById(unitId)) throw new Error("Unit not found");
|
package/lib/cjs/index.js
CHANGED
|
@@ -322,6 +322,7 @@ let ComponentManager = class ComponentManager extends _univerjs_core.Disposable
|
|
|
322
322
|
super();
|
|
323
323
|
this._logService = _logService;
|
|
324
324
|
_defineProperty(this, "_components", /* @__PURE__ */ new Map());
|
|
325
|
+
_defineProperty(this, "_overrides", /* @__PURE__ */ new Map());
|
|
325
326
|
_defineProperty(this, "reactUtils", {
|
|
326
327
|
createElement: react.createElement,
|
|
327
328
|
useEffect: react.useEffect,
|
|
@@ -331,19 +332,27 @@ let ComponentManager = class ComponentManager extends _univerjs_core.Disposable
|
|
|
331
332
|
return component;
|
|
332
333
|
} });
|
|
333
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* Register before the component is first rendered; mounted views do not subscribe to registry changes.
|
|
337
|
+
* Disposing an override reveals the current default, if it is still registered.
|
|
338
|
+
* @throws When another override is already registered for this name.
|
|
339
|
+
*/
|
|
334
340
|
register(name, component, options) {
|
|
335
|
-
const { framework = "react" } = options
|
|
341
|
+
const { framework = "react", override = false } = options ?? {};
|
|
342
|
+
const components = override ? this._overrides : this._components;
|
|
336
343
|
if (framework === "vue3" && !this._handler.vue3) throw new Error("[ComponentManager] Vue3 support is no longer built-in since v0.9.0, please install @univerjs/ui-adapter-vue3 plugin.");
|
|
337
|
-
if (
|
|
344
|
+
if (components.has(name)) {
|
|
338
345
|
var _this$_logService;
|
|
346
|
+
if (override) throw new Error(`[ComponentManager] Component ${name} already has an override.`);
|
|
339
347
|
(_this$_logService = this._logService) === null || _this$_logService === void 0 || _this$_logService.warn("[ComponentManager]", `Component ${name} already exists.`);
|
|
340
348
|
}
|
|
341
|
-
|
|
349
|
+
const registration = {
|
|
342
350
|
framework,
|
|
343
351
|
component
|
|
344
|
-
}
|
|
352
|
+
};
|
|
353
|
+
components.set(name, registration);
|
|
345
354
|
return (0, _univerjs_core.toDisposable)(() => {
|
|
346
|
-
|
|
355
|
+
if (components.get(name) === registration) components.delete(name);
|
|
347
356
|
});
|
|
348
357
|
}
|
|
349
358
|
setHandler(framework, handler) {
|
|
@@ -351,15 +360,25 @@ let ComponentManager = class ComponentManager extends _univerjs_core.Disposable
|
|
|
351
360
|
}
|
|
352
361
|
get(name) {
|
|
353
362
|
if (!name) return;
|
|
354
|
-
const value = this._components.get(name);
|
|
363
|
+
const value = this._overrides.get(name) ?? this._components.get(name);
|
|
355
364
|
if (!value) return;
|
|
356
365
|
const frameworkHandler = this._handler[value.framework];
|
|
357
366
|
if (!frameworkHandler) throw new Error(`[ComponentManager] No handler found for framework: ${value.framework}`);
|
|
358
367
|
return frameworkHandler(value.component, name);
|
|
359
368
|
}
|
|
369
|
+
/** Check for a built-in default independently of any active host override. */
|
|
370
|
+
hasDefault(name) {
|
|
371
|
+
return this._components.has(name);
|
|
372
|
+
}
|
|
373
|
+
/** Remove the default registration. Overrides can only be removed through their registration disposable. */
|
|
360
374
|
delete(name) {
|
|
361
375
|
this._components.delete(name);
|
|
362
376
|
}
|
|
377
|
+
dispose() {
|
|
378
|
+
super.dispose();
|
|
379
|
+
this._components.clear();
|
|
380
|
+
this._overrides.clear();
|
|
381
|
+
}
|
|
363
382
|
};
|
|
364
383
|
ComponentManager = __decorate([__decorateParam(0, (0, _univerjs_core.Optional)(_univerjs_core.ILogService))], ComponentManager);
|
|
365
384
|
|
|
@@ -3501,7 +3520,7 @@ function useToolbarShortcutDisplay({ id, commandId, shortcut }) {
|
|
|
3501
3520
|
*/
|
|
3502
3521
|
const toolbarButtonClassName = `
|
|
3503
3522
|
univer-box-border univer-flex univer-h-6 univer-min-w-6 univer-cursor-pointer univer-items-center
|
|
3504
|
-
univer-justify-center univer-rounded univer-border-none univer-bg-transparent univer-
|
|
3523
|
+
univer-justify-center univer-rounded univer-border-none univer-bg-transparent univer-px-0 univer-py-0
|
|
3505
3524
|
univer-text-gray-900 univer-outline-none univer-transition-colors univer-animate-in univer-fade-in
|
|
3506
3525
|
dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-700 dark:disabled:!univer-text-gray-600
|
|
3507
3526
|
disabled:univer-cursor-not-allowed disabled:univer-text-gray-300 disabled:hover:univer-bg-transparent
|
|
@@ -7006,7 +7025,7 @@ const IUIController = (0, _univerjs_core.createIdentifier)("univer.ui.ui-control
|
|
|
7006
7025
|
//#endregion
|
|
7007
7026
|
//#region package.json
|
|
7008
7027
|
var name = "@univerjs/ui";
|
|
7009
|
-
var version = "1.0.
|
|
7028
|
+
var version = "1.0.4";
|
|
7010
7029
|
|
|
7011
7030
|
//#endregion
|
|
7012
7031
|
//#region src/views/color-picker/interface.ts
|
|
@@ -26533,18 +26552,9 @@ function DialogItem(props) {
|
|
|
26533
26552
|
const ownerDocument = document;
|
|
26534
26553
|
const opener = ownerDocument.activeElement;
|
|
26535
26554
|
const owner = getEmbedBoundaryOwner(opener);
|
|
26536
|
-
const ownerWindow = ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.defaultView;
|
|
26537
|
-
const handleCompositionEscape = (event) => {
|
|
26538
|
-
if (event.key === "Escape" && event.isComposing && event.target instanceof Element && event.target.closest("[role=\"dialog\"]") === dialogRef.current) {
|
|
26539
|
-
event.preventDefault();
|
|
26540
|
-
event.stopPropagation();
|
|
26541
|
-
}
|
|
26542
|
-
};
|
|
26543
|
-
ownerWindow === null || ownerWindow === void 0 || ownerWindow.addEventListener("keydown", handleCompositionEscape, true);
|
|
26544
26555
|
return () => {
|
|
26545
26556
|
openRef.current = false;
|
|
26546
26557
|
const content = dialogRef.current;
|
|
26547
|
-
ownerWindow === null || ownerWindow === void 0 || ownerWindow.removeEventListener("keydown", handleCompositionEscape, true);
|
|
26548
26558
|
if (props.mask === false) return;
|
|
26549
26559
|
queueMicrotask(() => {
|
|
26550
26560
|
if (openRef.current) return;
|
package/lib/es/facade.js
CHANGED
|
@@ -434,7 +434,10 @@ var FUniverUIMixin = class extends FUniver {
|
|
|
434
434
|
}
|
|
435
435
|
registerComponent(name, component, options) {
|
|
436
436
|
const componentManager = this._injector.get(ComponentManager);
|
|
437
|
-
return this.disposeWithMe(componentManager.register(name, component,
|
|
437
|
+
return this.disposeWithMe(componentManager.register(name, component, {
|
|
438
|
+
...options,
|
|
439
|
+
override: (options === null || options === void 0 ? void 0 : options.override) ?? true
|
|
440
|
+
}));
|
|
438
441
|
}
|
|
439
442
|
setCurrent(unitId) {
|
|
440
443
|
if (!this._injector.get(IRenderManagerService).getRenderUnitById(unitId)) throw new Error("Unit not found");
|
package/lib/es/index.js
CHANGED
|
@@ -321,6 +321,7 @@ let ComponentManager = class ComponentManager extends Disposable {
|
|
|
321
321
|
super();
|
|
322
322
|
this._logService = _logService;
|
|
323
323
|
_defineProperty(this, "_components", /* @__PURE__ */ new Map());
|
|
324
|
+
_defineProperty(this, "_overrides", /* @__PURE__ */ new Map());
|
|
324
325
|
_defineProperty(this, "reactUtils", {
|
|
325
326
|
createElement,
|
|
326
327
|
useEffect,
|
|
@@ -330,19 +331,27 @@ let ComponentManager = class ComponentManager extends Disposable {
|
|
|
330
331
|
return component;
|
|
331
332
|
} });
|
|
332
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Register before the component is first rendered; mounted views do not subscribe to registry changes.
|
|
336
|
+
* Disposing an override reveals the current default, if it is still registered.
|
|
337
|
+
* @throws When another override is already registered for this name.
|
|
338
|
+
*/
|
|
333
339
|
register(name, component, options) {
|
|
334
|
-
const { framework = "react" } = options
|
|
340
|
+
const { framework = "react", override = false } = options ?? {};
|
|
341
|
+
const components = override ? this._overrides : this._components;
|
|
335
342
|
if (framework === "vue3" && !this._handler.vue3) throw new Error("[ComponentManager] Vue3 support is no longer built-in since v0.9.0, please install @univerjs/ui-adapter-vue3 plugin.");
|
|
336
|
-
if (
|
|
343
|
+
if (components.has(name)) {
|
|
337
344
|
var _this$_logService;
|
|
345
|
+
if (override) throw new Error(`[ComponentManager] Component ${name} already has an override.`);
|
|
338
346
|
(_this$_logService = this._logService) === null || _this$_logService === void 0 || _this$_logService.warn("[ComponentManager]", `Component ${name} already exists.`);
|
|
339
347
|
}
|
|
340
|
-
|
|
348
|
+
const registration = {
|
|
341
349
|
framework,
|
|
342
350
|
component
|
|
343
|
-
}
|
|
351
|
+
};
|
|
352
|
+
components.set(name, registration);
|
|
344
353
|
return toDisposable(() => {
|
|
345
|
-
|
|
354
|
+
if (components.get(name) === registration) components.delete(name);
|
|
346
355
|
});
|
|
347
356
|
}
|
|
348
357
|
setHandler(framework, handler) {
|
|
@@ -350,15 +359,25 @@ let ComponentManager = class ComponentManager extends Disposable {
|
|
|
350
359
|
}
|
|
351
360
|
get(name) {
|
|
352
361
|
if (!name) return;
|
|
353
|
-
const value = this._components.get(name);
|
|
362
|
+
const value = this._overrides.get(name) ?? this._components.get(name);
|
|
354
363
|
if (!value) return;
|
|
355
364
|
const frameworkHandler = this._handler[value.framework];
|
|
356
365
|
if (!frameworkHandler) throw new Error(`[ComponentManager] No handler found for framework: ${value.framework}`);
|
|
357
366
|
return frameworkHandler(value.component, name);
|
|
358
367
|
}
|
|
368
|
+
/** Check for a built-in default independently of any active host override. */
|
|
369
|
+
hasDefault(name) {
|
|
370
|
+
return this._components.has(name);
|
|
371
|
+
}
|
|
372
|
+
/** Remove the default registration. Overrides can only be removed through their registration disposable. */
|
|
359
373
|
delete(name) {
|
|
360
374
|
this._components.delete(name);
|
|
361
375
|
}
|
|
376
|
+
dispose() {
|
|
377
|
+
super.dispose();
|
|
378
|
+
this._components.clear();
|
|
379
|
+
this._overrides.clear();
|
|
380
|
+
}
|
|
362
381
|
};
|
|
363
382
|
ComponentManager = __decorate([__decorateParam(0, Optional(ILogService))], ComponentManager);
|
|
364
383
|
|
|
@@ -3500,7 +3519,7 @@ function useToolbarShortcutDisplay({ id, commandId, shortcut }) {
|
|
|
3500
3519
|
*/
|
|
3501
3520
|
const toolbarButtonClassName = `
|
|
3502
3521
|
univer-box-border univer-flex univer-h-6 univer-min-w-6 univer-cursor-pointer univer-items-center
|
|
3503
|
-
univer-justify-center univer-rounded univer-border-none univer-bg-transparent univer-
|
|
3522
|
+
univer-justify-center univer-rounded univer-border-none univer-bg-transparent univer-px-0 univer-py-0
|
|
3504
3523
|
univer-text-gray-900 univer-outline-none univer-transition-colors univer-animate-in univer-fade-in
|
|
3505
3524
|
dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-700 dark:disabled:!univer-text-gray-600
|
|
3506
3525
|
disabled:univer-cursor-not-allowed disabled:univer-text-gray-300 disabled:hover:univer-bg-transparent
|
|
@@ -7005,7 +7024,7 @@ const IUIController = createIdentifier("univer.ui.ui-controller");
|
|
|
7005
7024
|
//#endregion
|
|
7006
7025
|
//#region package.json
|
|
7007
7026
|
var name = "@univerjs/ui";
|
|
7008
|
-
var version = "1.0.
|
|
7027
|
+
var version = "1.0.4";
|
|
7009
7028
|
|
|
7010
7029
|
//#endregion
|
|
7011
7030
|
//#region src/views/color-picker/interface.ts
|
|
@@ -26532,18 +26551,9 @@ function DialogItem(props) {
|
|
|
26532
26551
|
const ownerDocument = document;
|
|
26533
26552
|
const opener = ownerDocument.activeElement;
|
|
26534
26553
|
const owner = getEmbedBoundaryOwner(opener);
|
|
26535
|
-
const ownerWindow = ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.defaultView;
|
|
26536
|
-
const handleCompositionEscape = (event) => {
|
|
26537
|
-
if (event.key === "Escape" && event.isComposing && event.target instanceof Element && event.target.closest("[role=\"dialog\"]") === dialogRef.current) {
|
|
26538
|
-
event.preventDefault();
|
|
26539
|
-
event.stopPropagation();
|
|
26540
|
-
}
|
|
26541
|
-
};
|
|
26542
|
-
ownerWindow === null || ownerWindow === void 0 || ownerWindow.addEventListener("keydown", handleCompositionEscape, true);
|
|
26543
26554
|
return () => {
|
|
26544
26555
|
openRef.current = false;
|
|
26545
26556
|
const content = dialogRef.current;
|
|
26546
|
-
ownerWindow === null || ownerWindow === void 0 || ownerWindow.removeEventListener("keydown", handleCompositionEscape, true);
|
|
26547
26557
|
if (props.mask === false) return;
|
|
26548
26558
|
queueMicrotask(() => {
|
|
26549
26559
|
if (openRef.current) return;
|
package/lib/facade.js
CHANGED
|
@@ -434,7 +434,10 @@ var FUniverUIMixin = class extends FUniver {
|
|
|
434
434
|
}
|
|
435
435
|
registerComponent(name, component, options) {
|
|
436
436
|
const componentManager = this._injector.get(ComponentManager);
|
|
437
|
-
return this.disposeWithMe(componentManager.register(name, component,
|
|
437
|
+
return this.disposeWithMe(componentManager.register(name, component, {
|
|
438
|
+
...options,
|
|
439
|
+
override: (options === null || options === void 0 ? void 0 : options.override) ?? true
|
|
440
|
+
}));
|
|
438
441
|
}
|
|
439
442
|
setCurrent(unitId) {
|
|
440
443
|
if (!this._injector.get(IRenderManagerService).getRenderUnitById(unitId)) throw new Error("Unit not found");
|
package/lib/index.css
CHANGED
package/lib/index.js
CHANGED
|
@@ -321,6 +321,7 @@ let ComponentManager = class ComponentManager extends Disposable {
|
|
|
321
321
|
super();
|
|
322
322
|
this._logService = _logService;
|
|
323
323
|
_defineProperty(this, "_components", /* @__PURE__ */ new Map());
|
|
324
|
+
_defineProperty(this, "_overrides", /* @__PURE__ */ new Map());
|
|
324
325
|
_defineProperty(this, "reactUtils", {
|
|
325
326
|
createElement,
|
|
326
327
|
useEffect,
|
|
@@ -330,19 +331,27 @@ let ComponentManager = class ComponentManager extends Disposable {
|
|
|
330
331
|
return component;
|
|
331
332
|
} });
|
|
332
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Register before the component is first rendered; mounted views do not subscribe to registry changes.
|
|
336
|
+
* Disposing an override reveals the current default, if it is still registered.
|
|
337
|
+
* @throws When another override is already registered for this name.
|
|
338
|
+
*/
|
|
333
339
|
register(name, component, options) {
|
|
334
|
-
const { framework = "react" } = options
|
|
340
|
+
const { framework = "react", override = false } = options ?? {};
|
|
341
|
+
const components = override ? this._overrides : this._components;
|
|
335
342
|
if (framework === "vue3" && !this._handler.vue3) throw new Error("[ComponentManager] Vue3 support is no longer built-in since v0.9.0, please install @univerjs/ui-adapter-vue3 plugin.");
|
|
336
|
-
if (
|
|
343
|
+
if (components.has(name)) {
|
|
337
344
|
var _this$_logService;
|
|
345
|
+
if (override) throw new Error(`[ComponentManager] Component ${name} already has an override.`);
|
|
338
346
|
(_this$_logService = this._logService) === null || _this$_logService === void 0 || _this$_logService.warn("[ComponentManager]", `Component ${name} already exists.`);
|
|
339
347
|
}
|
|
340
|
-
|
|
348
|
+
const registration = {
|
|
341
349
|
framework,
|
|
342
350
|
component
|
|
343
|
-
}
|
|
351
|
+
};
|
|
352
|
+
components.set(name, registration);
|
|
344
353
|
return toDisposable(() => {
|
|
345
|
-
|
|
354
|
+
if (components.get(name) === registration) components.delete(name);
|
|
346
355
|
});
|
|
347
356
|
}
|
|
348
357
|
setHandler(framework, handler) {
|
|
@@ -350,15 +359,25 @@ let ComponentManager = class ComponentManager extends Disposable {
|
|
|
350
359
|
}
|
|
351
360
|
get(name) {
|
|
352
361
|
if (!name) return;
|
|
353
|
-
const value = this._components.get(name);
|
|
362
|
+
const value = this._overrides.get(name) ?? this._components.get(name);
|
|
354
363
|
if (!value) return;
|
|
355
364
|
const frameworkHandler = this._handler[value.framework];
|
|
356
365
|
if (!frameworkHandler) throw new Error(`[ComponentManager] No handler found for framework: ${value.framework}`);
|
|
357
366
|
return frameworkHandler(value.component, name);
|
|
358
367
|
}
|
|
368
|
+
/** Check for a built-in default independently of any active host override. */
|
|
369
|
+
hasDefault(name) {
|
|
370
|
+
return this._components.has(name);
|
|
371
|
+
}
|
|
372
|
+
/** Remove the default registration. Overrides can only be removed through their registration disposable. */
|
|
359
373
|
delete(name) {
|
|
360
374
|
this._components.delete(name);
|
|
361
375
|
}
|
|
376
|
+
dispose() {
|
|
377
|
+
super.dispose();
|
|
378
|
+
this._components.clear();
|
|
379
|
+
this._overrides.clear();
|
|
380
|
+
}
|
|
362
381
|
};
|
|
363
382
|
ComponentManager = __decorate([__decorateParam(0, Optional(ILogService))], ComponentManager);
|
|
364
383
|
|
|
@@ -3500,7 +3519,7 @@ function useToolbarShortcutDisplay({ id, commandId, shortcut }) {
|
|
|
3500
3519
|
*/
|
|
3501
3520
|
const toolbarButtonClassName = `
|
|
3502
3521
|
univer-box-border univer-flex univer-h-6 univer-min-w-6 univer-cursor-pointer univer-items-center
|
|
3503
|
-
univer-justify-center univer-rounded univer-border-none univer-bg-transparent univer-
|
|
3522
|
+
univer-justify-center univer-rounded univer-border-none univer-bg-transparent univer-px-0 univer-py-0
|
|
3504
3523
|
univer-text-gray-900 univer-outline-none univer-transition-colors univer-animate-in univer-fade-in
|
|
3505
3524
|
dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-700 dark:disabled:!univer-text-gray-600
|
|
3506
3525
|
disabled:univer-cursor-not-allowed disabled:univer-text-gray-300 disabled:hover:univer-bg-transparent
|
|
@@ -7005,7 +7024,7 @@ const IUIController = createIdentifier("univer.ui.ui-controller");
|
|
|
7005
7024
|
//#endregion
|
|
7006
7025
|
//#region package.json
|
|
7007
7026
|
var name = "@univerjs/ui";
|
|
7008
|
-
var version = "1.0.
|
|
7027
|
+
var version = "1.0.4";
|
|
7009
7028
|
|
|
7010
7029
|
//#endregion
|
|
7011
7030
|
//#region src/views/color-picker/interface.ts
|
|
@@ -26532,18 +26551,9 @@ function DialogItem(props) {
|
|
|
26532
26551
|
const ownerDocument = document;
|
|
26533
26552
|
const opener = ownerDocument.activeElement;
|
|
26534
26553
|
const owner = getEmbedBoundaryOwner(opener);
|
|
26535
|
-
const ownerWindow = ownerDocument === null || ownerDocument === void 0 ? void 0 : ownerDocument.defaultView;
|
|
26536
|
-
const handleCompositionEscape = (event) => {
|
|
26537
|
-
if (event.key === "Escape" && event.isComposing && event.target instanceof Element && event.target.closest("[role=\"dialog\"]") === dialogRef.current) {
|
|
26538
|
-
event.preventDefault();
|
|
26539
|
-
event.stopPropagation();
|
|
26540
|
-
}
|
|
26541
|
-
};
|
|
26542
|
-
ownerWindow === null || ownerWindow === void 0 || ownerWindow.addEventListener("keydown", handleCompositionEscape, true);
|
|
26543
26554
|
return () => {
|
|
26544
26555
|
openRef.current = false;
|
|
26545
26556
|
const content = dialogRef.current;
|
|
26546
|
-
ownerWindow === null || ownerWindow === void 0 || ownerWindow.removeEventListener("keydown", handleCompositionEscape, true);
|
|
26547
26557
|
if (props.mask === false) return;
|
|
26548
26558
|
queueMicrotask(() => {
|
|
26549
26559
|
if (openRef.current) return;
|
|
@@ -19,6 +19,12 @@ import { createElement, useEffect, useRef } from 'react';
|
|
|
19
19
|
type ComponentFramework = string;
|
|
20
20
|
export interface IComponentOptions {
|
|
21
21
|
framework?: ComponentFramework;
|
|
22
|
+
/**
|
|
23
|
+
* Whether this registration takes precedence over the built-in default, regardless of registration order.
|
|
24
|
+
* Defaults to false in ComponentManager and true in FUniver.registerComponent.
|
|
25
|
+
* Only one override may be active for each name.
|
|
26
|
+
*/
|
|
27
|
+
override?: boolean;
|
|
22
28
|
}
|
|
23
29
|
export interface IComponent<T = any> {
|
|
24
30
|
framework: string;
|
|
@@ -28,8 +34,14 @@ export type ComponentType<T = any> = any;
|
|
|
28
34
|
export type ComponentList = Map<string, IComponent>;
|
|
29
35
|
export declare class ComponentManager extends Disposable {
|
|
30
36
|
private readonly _logService?;
|
|
31
|
-
private _components;
|
|
37
|
+
private readonly _components;
|
|
38
|
+
private readonly _overrides;
|
|
32
39
|
constructor(_logService?: ILogService | undefined);
|
|
40
|
+
/**
|
|
41
|
+
* Register before the component is first rendered; mounted views do not subscribe to registry changes.
|
|
42
|
+
* Disposing an override reveals the current default, if it is still registered.
|
|
43
|
+
* @throws When another override is already registered for this name.
|
|
44
|
+
*/
|
|
33
45
|
register(name: string, component: ComponentType, options?: IComponentOptions): IDisposable;
|
|
34
46
|
reactUtils: {
|
|
35
47
|
createElement: typeof createElement;
|
|
@@ -39,6 +51,10 @@ export declare class ComponentManager extends Disposable {
|
|
|
39
51
|
private _handler;
|
|
40
52
|
setHandler(framework: string, handler: (component: IComponent['component'], name?: string) => any): void;
|
|
41
53
|
get(name: string): any;
|
|
54
|
+
/** Check for a built-in default independently of any active host override. */
|
|
55
|
+
hasDefault(name: string): boolean;
|
|
56
|
+
/** Remove the default registration. Overrides can only be removed through their registration disposable. */
|
|
42
57
|
delete(name: string): void;
|
|
58
|
+
dispose(): void;
|
|
43
59
|
}
|
|
44
60
|
export {};
|
|
@@ -372,11 +372,13 @@ export interface IFUniverUIMixin {
|
|
|
372
372
|
*/
|
|
373
373
|
registerUIPart(key: BuiltInUIPart, component: ComponentType): IDisposable;
|
|
374
374
|
/**
|
|
375
|
-
* Register
|
|
375
|
+
* Register a component, overriding its built-in default regardless of registration order.
|
|
376
|
+
* Register before opening the corresponding view; mounted views do not update automatically.
|
|
376
377
|
* @param {string} name - The name of the component.
|
|
377
378
|
* @param {ComponentType} component - The component.
|
|
378
|
-
* @param {IComponentOptions} [options] -
|
|
379
|
-
* @returns {IDisposable}
|
|
379
|
+
* @param {IComponentOptions} [options] - Component options. `override` defaults to true; pass false to register a default.
|
|
380
|
+
* @returns {IDisposable} Disposes this registration, restoring the current built-in default when available.
|
|
381
|
+
* @throws When another override is already registered for this name. Dispose it before registering a replacement.
|
|
380
382
|
* @example
|
|
381
383
|
* ```tsx
|
|
382
384
|
* const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
|
|
@@ -39,7 +39,7 @@ export interface IBaseToolbarButtonProps {
|
|
|
39
39
|
onMouseEnter?: React.MouseEventHandler;
|
|
40
40
|
onMouseLeave?: React.MouseEventHandler;
|
|
41
41
|
}
|
|
42
|
-
export declare const toolbarButtonClassName = "\nuniver-box-border univer-flex univer-h-6 univer-min-w-6 univer-cursor-pointer univer-items-center\nuniver-justify-center univer-rounded univer-border-none univer-bg-transparent univer-
|
|
42
|
+
export declare const toolbarButtonClassName = "\nuniver-box-border univer-flex univer-h-6 univer-min-w-6 univer-cursor-pointer univer-items-center\nuniver-justify-center univer-rounded univer-border-none univer-bg-transparent univer-px-0 univer-py-0\nuniver-text-gray-900 univer-outline-none univer-transition-colors univer-animate-in univer-fade-in\ndark:!univer-text-gray-0 dark:hover:!univer-bg-gray-700 dark:disabled:!univer-text-gray-600\ndisabled:univer-cursor-not-allowed disabled:univer-text-gray-300 disabled:hover:univer-bg-transparent\nhover:univer-bg-gray-100 whitespace-nowrap univer-w-max\n[&_svg]:univer-shrink-0\n";
|
|
43
43
|
export declare const toolbarButtonVariants: (props?: ({
|
|
44
44
|
noIcon?: boolean | null | undefined;
|
|
45
45
|
active?: boolean | null | undefined;
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(require("@univerjs/core"),require("@univerjs/core/facade"),require("@univerjs/engine-render"),require("@univerjs/ui")):typeof define==`function`&&define.amd?define([`@univerjs/core`,`@univerjs/core/facade`,`@univerjs/engine-render`,`@univerjs/ui`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCore,e.UniverCoreFacade,e.UniverEngineRender,e.UniverUi))})(this,function(e,t,n,r){function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){return function(n,r){t(n,r,e)}}function l(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var u=class extends t.FBase{appendTo(e){let t=typeof e==`string`?e.split(`|`):e,n=t.length,r={},i=r,a=this.__getSchema();t.forEach((e,t)=>{t===n-1?i[e]=a:i[e]={},i=i[e]}),this._menuManagerService.mergeMenu(r)}};let d=class extends u{constructor(t,n,i,a){super(),this._item=t,this._injector=n,this._commandService=i,this._menuManagerService=a,s(this,`_commandToRegister`,new Map),s(this,`_buildingSchema`,void 0);let o=typeof t.action==`string`?t.action:(0,e.generateRandomId)(12);o!==t.action&&this._commandToRegister.set(o,t.action),this._buildingSchema={menuItemFactory:()=>({id:t.id,type:r.MenuItemType.BUTTON,icon:t.icon,title:t.title,tooltip:t.tooltip,commandId:o})},t.order!==void 0&&(this._buildingSchema.order=t.order),t.gridLayout&&(this._buildingSchema.gridLayout=t.gridLayout)}__getSchema(){return this._commandToRegister.forEach((t,n)=>{this._commandService.hasCommand(n)||this._commandService.registerCommand({id:n,type:e.CommandType.COMMAND,handler:t})}),{[this._item.id]:this._buildingSchema}}};s(d,`RibbonStartGroup`,r.RibbonStartGroup),s(d,`RibbonPosition`,r.RibbonPosition),s(d,`MenuManagerPosition`,r.MenuManagerPosition),d=l([c(1,(0,e.Inject)(e.Injector)),c(2,e.ICommandService),c(3,r.IMenuManagerService)],d);let f=class extends u{constructor(e,t,n){super(),this._item=e,this._injector=t,this._menuManagerService=n,s(this,`_menuByGroups`,[]),s(this,`_submenus`,[]),s(this,`_buildingSchema`,void 0),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:r.MenuItemType.SUBITEMS,icon:e.icon,title:e.title,tooltip:e.tooltip})},e.order!==void 0&&(this._buildingSchema.order=e.order),e.gridLayout&&(this._buildingSchema.gridLayout=e.gridLayout)}addSubmenu(e){return this._submenus.push(e),this}addSeparator(){return this._menuByGroups.push(this._submenus),this._submenus=[],this}__getSchema(){let e={};return this.addSeparator(),this._menuByGroups.forEach((t,n)=>{let r={};t.forEach(e=>{Object.assign(r,e.__getSchema())}),e[`${this._item.id}-group-${n}`]=r}),{[this._item.id]:Object.assign(this._buildingSchema,e)}}};f=l([c(1,(0,e.Inject)(e.Injector)),c(2,r.IMenuManagerService)],f);let p=class extends t.FBase{constructor(e,t,n,r){super(),this._injector=e,this._renderManagerService=t,this._univerInstanceService=n,this._shortcutService=r,s(this,`_forceDisableDisposable`,null)}enableShortcut(){var e;return(e=this._forceDisableDisposable)==null||e.dispose(),this._forceDisableDisposable=null,this}disableShortcut(){return this._forceDisableDisposable||=this._shortcutService.forceDisable(),this}triggerShortcut(t){let n=this._univerInstanceService.getCurrentUnitOfType(e.UniverInstanceType.UNIVER_SHEET);if(!n)return;let r=this._renderManagerService.getRenderUnitById(n.getUnitId());if(r)return r.engine.getCanvasElement().dispatchEvent(t),this._shortcutService.dispatch(t)}dispatchShortcutEvent(e){return this._shortcutService.dispatch(e)}};p=l([c(0,(0,e.Inject)(e.Injector)),c(1,(0,e.Inject)(n.IRenderManagerService)),c(2,e.IUniverInstanceService),c(3,r.IShortcutService)],p);var m=class extends t.FUniver{getURL(){return new URL(window.location.href)}getShortcut(){return this._injector.createInstance(p)}copy(){return this._commandService.executeCommand(r.CopyCommand.id)}paste(){return this._commandService.executeCommand(r.PasteCommand.id)}createMenu(e){return this._injector.createInstance(d,e)}createSubmenu(e){return this._injector.createInstance(f,e)}updateMenuConfig(e){return this._injector.get(r.IMenuManagerService).updateMenuConfig(e),this}openSidebar(e){return this._injector.get(r.ISidebarService).open(e)}openDialog(e){let t=this._injector.get(r.IDialogService).open({...e,onClose:()=>{t.dispose()}});return t}getComponentManager(){return this._injector.get(r.ComponentManager)}showMessage(e){return this._injector.get(r.IMessageService).show(e),this}setRibbonType(t){return this._injector.get(e.IConfigService).setConfig(r.UI_PLUGIN_CONFIG_KEY,{ribbonType:t},{merge:!0}),this}setUIVisible(e,t){return this._injector.get(r.IUIPartsService).setUIVisible(e,t),this}isUIVisible(e){return this._injector.get(r.IUIPartsService).isUIVisible(e)}registerUIPart(e,t){return this._injector.get(r.IUIPartsService).registerComponent(e,()=>(0,r.connectInjector)(t,this._injector))}registerComponent(e,t,n){let i=this._injector.get(r.ComponentManager);return this.disposeWithMe(i.register(e,t,n))}setCurrent(e){if(!this._injector.get(n.IRenderManagerService).getRenderUnitById(e))throw Error(`Unit not found`);this._univerInstanceService.setCurrentUnitForType(e)}addFonts(e){let t=this._injector.get(r.IFontService);e.forEach(e=>{t.addFont(e)})}};t.FUniver.extend(m);var h=class extends t.FEnum{get BuiltInUIPart(){return r.BuiltInUIPart}get KeyCode(){return r.KeyCode}};t.FEnum.extend(h)});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(require("@univerjs/core"),require("@univerjs/core/facade"),require("@univerjs/engine-render"),require("@univerjs/ui")):typeof define==`function`&&define.amd?define([`@univerjs/core`,`@univerjs/core/facade`,`@univerjs/engine-render`,`@univerjs/ui`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCore,e.UniverCoreFacade,e.UniverEngineRender,e.UniverUi))})(this,function(e,t,n,r){function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){return function(n,r){t(n,r,e)}}function l(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var u=class extends t.FBase{appendTo(e){let t=typeof e==`string`?e.split(`|`):e,n=t.length,r={},i=r,a=this.__getSchema();t.forEach((e,t)=>{t===n-1?i[e]=a:i[e]={},i=i[e]}),this._menuManagerService.mergeMenu(r)}};let d=class extends u{constructor(t,n,i,a){super(),this._item=t,this._injector=n,this._commandService=i,this._menuManagerService=a,s(this,`_commandToRegister`,new Map),s(this,`_buildingSchema`,void 0);let o=typeof t.action==`string`?t.action:(0,e.generateRandomId)(12);o!==t.action&&this._commandToRegister.set(o,t.action),this._buildingSchema={menuItemFactory:()=>({id:t.id,type:r.MenuItemType.BUTTON,icon:t.icon,title:t.title,tooltip:t.tooltip,commandId:o})},t.order!==void 0&&(this._buildingSchema.order=t.order),t.gridLayout&&(this._buildingSchema.gridLayout=t.gridLayout)}__getSchema(){return this._commandToRegister.forEach((t,n)=>{this._commandService.hasCommand(n)||this._commandService.registerCommand({id:n,type:e.CommandType.COMMAND,handler:t})}),{[this._item.id]:this._buildingSchema}}};s(d,`RibbonStartGroup`,r.RibbonStartGroup),s(d,`RibbonPosition`,r.RibbonPosition),s(d,`MenuManagerPosition`,r.MenuManagerPosition),d=l([c(1,(0,e.Inject)(e.Injector)),c(2,e.ICommandService),c(3,r.IMenuManagerService)],d);let f=class extends u{constructor(e,t,n){super(),this._item=e,this._injector=t,this._menuManagerService=n,s(this,`_menuByGroups`,[]),s(this,`_submenus`,[]),s(this,`_buildingSchema`,void 0),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:r.MenuItemType.SUBITEMS,icon:e.icon,title:e.title,tooltip:e.tooltip})},e.order!==void 0&&(this._buildingSchema.order=e.order),e.gridLayout&&(this._buildingSchema.gridLayout=e.gridLayout)}addSubmenu(e){return this._submenus.push(e),this}addSeparator(){return this._menuByGroups.push(this._submenus),this._submenus=[],this}__getSchema(){let e={};return this.addSeparator(),this._menuByGroups.forEach((t,n)=>{let r={};t.forEach(e=>{Object.assign(r,e.__getSchema())}),e[`${this._item.id}-group-${n}`]=r}),{[this._item.id]:Object.assign(this._buildingSchema,e)}}};f=l([c(1,(0,e.Inject)(e.Injector)),c(2,r.IMenuManagerService)],f);let p=class extends t.FBase{constructor(e,t,n,r){super(),this._injector=e,this._renderManagerService=t,this._univerInstanceService=n,this._shortcutService=r,s(this,`_forceDisableDisposable`,null)}enableShortcut(){var e;return(e=this._forceDisableDisposable)==null||e.dispose(),this._forceDisableDisposable=null,this}disableShortcut(){return this._forceDisableDisposable||=this._shortcutService.forceDisable(),this}triggerShortcut(t){let n=this._univerInstanceService.getCurrentUnitOfType(e.UniverInstanceType.UNIVER_SHEET);if(!n)return;let r=this._renderManagerService.getRenderUnitById(n.getUnitId());if(r)return r.engine.getCanvasElement().dispatchEvent(t),this._shortcutService.dispatch(t)}dispatchShortcutEvent(e){return this._shortcutService.dispatch(e)}};p=l([c(0,(0,e.Inject)(e.Injector)),c(1,(0,e.Inject)(n.IRenderManagerService)),c(2,e.IUniverInstanceService),c(3,r.IShortcutService)],p);var m=class extends t.FUniver{getURL(){return new URL(window.location.href)}getShortcut(){return this._injector.createInstance(p)}copy(){return this._commandService.executeCommand(r.CopyCommand.id)}paste(){return this._commandService.executeCommand(r.PasteCommand.id)}createMenu(e){return this._injector.createInstance(d,e)}createSubmenu(e){return this._injector.createInstance(f,e)}updateMenuConfig(e){return this._injector.get(r.IMenuManagerService).updateMenuConfig(e),this}openSidebar(e){return this._injector.get(r.ISidebarService).open(e)}openDialog(e){let t=this._injector.get(r.IDialogService).open({...e,onClose:()=>{t.dispose()}});return t}getComponentManager(){return this._injector.get(r.ComponentManager)}showMessage(e){return this._injector.get(r.IMessageService).show(e),this}setRibbonType(t){return this._injector.get(e.IConfigService).setConfig(r.UI_PLUGIN_CONFIG_KEY,{ribbonType:t},{merge:!0}),this}setUIVisible(e,t){return this._injector.get(r.IUIPartsService).setUIVisible(e,t),this}isUIVisible(e){return this._injector.get(r.IUIPartsService).isUIVisible(e)}registerUIPart(e,t){return this._injector.get(r.IUIPartsService).registerComponent(e,()=>(0,r.connectInjector)(t,this._injector))}registerComponent(e,t,n){let i=this._injector.get(r.ComponentManager);return this.disposeWithMe(i.register(e,t,{...n,override:(n==null?void 0:n.override)??!0}))}setCurrent(e){if(!this._injector.get(n.IRenderManagerService).getRenderUnitById(e))throw Error(`Unit not found`);this._univerInstanceService.setCurrentUnitForType(e)}addFonts(e){let t=this._injector.get(r.IFontService);e.forEach(e=>{t.addFont(e)})}};t.FUniver.extend(m);var h=class extends t.FEnum{get BuiltInUIPart(){return r.BuiltInUIPart}get KeyCode(){return r.KeyCode}};t.FEnum.extend(h)});
|