uhuu-components 0.4.0 → 0.4.1
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/index.d.ts +50 -22
- package/package.json +1 -1
- package/uhuu-components.es.js +4583 -4322
- package/uhuu-components.es.js.map +1 -1
- package/uhuu-components.umd.cjs +11 -11
- package/uhuu-components.umd.cjs.map +1 -1
package/index.d.ts
CHANGED
|
@@ -852,7 +852,8 @@ export interface PageEditorTemplateConfig {
|
|
|
852
852
|
|
|
853
853
|
export interface PageOptionSelectValue {
|
|
854
854
|
label: LocalizedText;
|
|
855
|
-
value
|
|
855
|
+
/** Matched to the stored value as a string (`2` is `"2"`); a payload option writes it typed by `valueType`. */
|
|
856
|
+
value: string | number | boolean;
|
|
856
857
|
hex?: string;
|
|
857
858
|
}
|
|
858
859
|
|
|
@@ -883,12 +884,27 @@ export type ColorSeriesPageOption = BasePageOption & {
|
|
|
883
884
|
};
|
|
884
885
|
export type PageOption = SelectPageOption | TogglePageOption | SliderPageOption | CounterPageOption | ColorSeriesPageOption;
|
|
885
886
|
|
|
887
|
+
/** How a payload option writes a choice: default `boolean` for a toggle, `number` for a slider or counter, else `string`. */
|
|
888
|
+
export type OptionValueType = "string" | "number" | "boolean";
|
|
889
|
+
|
|
890
|
+
/** What a payload option (a page option without callbacks, or a document option) adds to its control. */
|
|
891
|
+
interface PayloadOptionStorage {
|
|
892
|
+
/** Shown while the payload holds no value (`stored ?? defaultValue`). */
|
|
893
|
+
defaultValue?: any;
|
|
894
|
+
/** The stored key. Default: `id`. */
|
|
895
|
+
field?: string;
|
|
896
|
+
valueType?: OptionValueType;
|
|
897
|
+
}
|
|
898
|
+
|
|
886
899
|
type PayloadOptionFor<Option> = Option extends PageOption
|
|
887
|
-
? Omit<Option, "getValue" | "onChange" | "applyPatch"> &
|
|
900
|
+
? Omit<Option, "getValue" | "onChange" | "applyPatch"> & PayloadOptionStorage
|
|
888
901
|
: never;
|
|
889
|
-
/** A page option stored automatically in `payload.pages`, without custom callbacks. */
|
|
902
|
+
/** A page option stored automatically in `payload.pages[pageId]`, without custom callbacks. */
|
|
890
903
|
export type PayloadOptionDefinition = PayloadOptionFor<PageOption>;
|
|
891
904
|
|
|
905
|
+
/** The corner of PageEditor's floating toolbar. */
|
|
906
|
+
export type ToolbarPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
907
|
+
|
|
892
908
|
export interface PageEditorProps {
|
|
893
909
|
/** Pages, groups and initial items; `pageManagement` sets the page-management controls. */
|
|
894
910
|
templateConfig: PageEditorTemplateConfig;
|
|
@@ -907,6 +923,12 @@ export interface PageEditorProps {
|
|
|
907
923
|
pageFilter?: PageFilterConfig;
|
|
908
924
|
printConfigs?: PrintConfigMap;
|
|
909
925
|
defaultZoomMode?: PageEditorDefaultZoomMode;
|
|
926
|
+
/**
|
|
927
|
+
* The corner the floating toolbar (page count, Add, Reorder, document options, zoom) starts in.
|
|
928
|
+
* Default `bottom-right`. A user moves it from the zoom menu; their corner is remembered in the
|
|
929
|
+
* browser and wins over this one.
|
|
930
|
+
*/
|
|
931
|
+
toolbarPosition?: ToolbarPosition;
|
|
910
932
|
onItemsChange?: (items: PageItem[], state: PageEditorState) => void;
|
|
911
933
|
onStateChange?: (state: PageEditorState) => void;
|
|
912
934
|
/**
|
|
@@ -963,26 +985,32 @@ export interface IntegrationAdapter {
|
|
|
963
985
|
[key: string]: unknown;
|
|
964
986
|
}
|
|
965
987
|
|
|
988
|
+
type DocumentOptionFor<Option> = Option extends PageOption
|
|
989
|
+
? Omit<Option, "getValue" | "onChange" | "applyPatch" | "appliesTo"> & PayloadOptionStorage
|
|
990
|
+
: never;
|
|
991
|
+
|
|
966
992
|
/**
|
|
967
|
-
*
|
|
968
|
-
*
|
|
969
|
-
*
|
|
993
|
+
* The 0.4 shape, as `uhuu templates theme inspect <templateId> --snippet` prints a legacy theme:
|
|
994
|
+
* `key` names the payload key, and a select may leave out `type`.
|
|
995
|
+
* @deprecated Define document options as payload page options are, with `id`.
|
|
970
996
|
*/
|
|
971
|
-
export interface
|
|
972
|
-
/** The top-level payload key, the same one the platform's theme option wrote. */
|
|
997
|
+
export interface LegacyDocumentOptionDefinition {
|
|
973
998
|
key: string;
|
|
974
|
-
/** Default `select`. */
|
|
975
999
|
type?: "select" | "toggle";
|
|
976
1000
|
label: LocalizedText;
|
|
977
1001
|
description?: LocalizedText;
|
|
978
|
-
/** A select's choices. A stored value matches a choice as a string: `2` matches `"2"`. */
|
|
979
1002
|
options?: Array<{ value: string | number | boolean; label: LocalizedText }>;
|
|
980
|
-
/** Shown while the payload has no value for the key (`payload[key] ?? defaultValue`). */
|
|
981
1003
|
defaultValue?: unknown;
|
|
982
|
-
|
|
983
|
-
valueType?: "string" | "number" | "boolean";
|
|
1004
|
+
valueType?: OptionValueType;
|
|
984
1005
|
}
|
|
985
1006
|
|
|
1007
|
+
/**
|
|
1008
|
+
* One document-level option: a top-level payload key the template reads (`payload.language`),
|
|
1009
|
+
* defined, valued and drawn as a payload page option is (`id` names the key, `field` overrides
|
|
1010
|
+
* it). See docs/document-options.md.
|
|
1011
|
+
*/
|
|
1012
|
+
export type DocumentOptionDefinition = DocumentOptionFor<PageOption> | LegacyDocumentOptionDefinition;
|
|
1013
|
+
|
|
986
1014
|
export interface DocumentOptionsProps {
|
|
987
1015
|
/**
|
|
988
1016
|
* The payload the template renders. Required outside a TemplateDataProvider; inside one, the
|
|
@@ -993,14 +1021,13 @@ export interface DocumentOptionsProps {
|
|
|
993
1021
|
/** Heading of the control. Default: "Document options" in the shell's interface language. */
|
|
994
1022
|
title?: LocalizedText;
|
|
995
1023
|
/**
|
|
996
|
-
* Called for local choices when no
|
|
997
|
-
*
|
|
1024
|
+
* Called for local choices, when there is no uhuu document editor on the page. In the editor a
|
|
1025
|
+
* choice arrives through the next payload update.
|
|
998
1026
|
*/
|
|
999
1027
|
onChange?: (key: string, value: unknown) => void;
|
|
1000
|
-
/**
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
*/
|
|
1028
|
+
/** The corner of the control's own floating bar, drawn when no PageEditor toolbar is on screen. Default `bottom-right`. */
|
|
1029
|
+
toolbarPosition?: ToolbarPosition;
|
|
1030
|
+
/** Inside PageEditor's floating toolbar: the entry's wrapper. Otherwise the control's own floating bar. */
|
|
1004
1031
|
className?: string;
|
|
1005
1032
|
style?: CSSProperties;
|
|
1006
1033
|
}
|
|
@@ -1012,9 +1039,10 @@ export const EditorShell: {
|
|
|
1012
1039
|
useInteractive: () => InteractiveModeContextValue;
|
|
1013
1040
|
useIntegrationAdapter: (config: IntegrationAdapterConfig) => IntegrationAdapter;
|
|
1014
1041
|
/**
|
|
1015
|
-
* Document-level
|
|
1016
|
-
*
|
|
1017
|
-
* Hidden outside edit mode, in the PDF renderer and
|
|
1042
|
+
* Document-level options for top-level payload keys, defined and drawn as page options are. A
|
|
1043
|
+
* choice is an edit in the uhuu document editor. Joins the nearest InteractiveModeProvider's
|
|
1044
|
+
* PageEditor toolbar, else floats in a corner. Hidden outside edit mode, in the PDF renderer and
|
|
1045
|
+
* in print. See docs/document-options.md.
|
|
1018
1046
|
*/
|
|
1019
1047
|
DocumentOptions: ComponentType<DocumentOptionsProps>;
|
|
1020
1048
|
};
|
package/package.json
CHANGED