@golemui/gui-shared 0.0.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ ## 0.19.0 (2026-03-02)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - ammend imports ([1ba7690a](https://github.com/golemui/formforge/commit/1ba7690a))
6
+ - ammend imports ([fc285e13](https://github.com/golemui/formforge/commit/fc285e13))
7
+ - gui-shared library ([e70470d9](https://github.com/golemui/formforge/commit/e70470d9))
8
+
9
+ ### ❤️ Thank You
10
+
11
+ - joanllenas
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # gui-shared
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build gui-shared` to build the library.
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test gui-shared` to execute the unit tests via [Vitest](https://vitest.dev/).
package/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from './lib/golem-form';
2
+ export * from './lib/widget.props';
3
+ export * from './lib/widgets';
4
+ export * from './lib/widget.factory';
5
+ export * from './lib/middleware/json-schema-vanilla';
6
+ export * from './lib/utils';
package/index.js ADDED
@@ -0,0 +1,179 @@
1
+ class a {
2
+ create(e) {
3
+ return {
4
+ states: e.states,
5
+ form: {
6
+ uid: "gui-root-uid",
7
+ type: "flex",
8
+ kind: "layout",
9
+ children: e.form
10
+ }
11
+ };
12
+ }
13
+ }
14
+ function s() {
15
+ return new a();
16
+ }
17
+ const r = [
18
+ "calendar",
19
+ "checkbox",
20
+ "currency",
21
+ "dateInput",
22
+ "datePicker",
23
+ "dropdown",
24
+ "list",
25
+ "number",
26
+ "password",
27
+ "radiogroup",
28
+ "rangeCalendar",
29
+ "repeater",
30
+ "select",
31
+ "textarea",
32
+ "textinput",
33
+ "toggle"
34
+ ], l = ["accordion", "flex", "tabs"], u = ["alert", "renderer"], o = ["button"], p = [
35
+ ...r,
36
+ ...l,
37
+ ...u,
38
+ ...o
39
+ ], i = {
40
+ //
41
+ // Input widgets
42
+ //
43
+ textinput: ({
44
+ config: t,
45
+ props: e,
46
+ validator: n
47
+ }) => ({
48
+ uid: "",
49
+ kind: "input",
50
+ type: "textinput",
51
+ // The `props` key only exists in the returned object when `props` is actually provided
52
+ ...e && { props: e },
53
+ ...n && { validator: n },
54
+ ...t
55
+ }),
56
+ password: ({
57
+ config: t,
58
+ props: e,
59
+ validator: n
60
+ }) => ({
61
+ uid: "",
62
+ kind: "input",
63
+ type: "password",
64
+ // The `props` key only exists in the returned object when `props` is actually provided
65
+ ...e && { props: e },
66
+ ...n && { validator: n },
67
+ ...t
68
+ }),
69
+ numberinput: ({
70
+ config: t,
71
+ props: e,
72
+ validator: n
73
+ }) => ({
74
+ uid: "",
75
+ kind: "input",
76
+ type: "numberinput",
77
+ ...e && { props: e },
78
+ ...n && { validator: n },
79
+ ...t
80
+ }),
81
+ checkbox: ({
82
+ config: t,
83
+ props: e,
84
+ validator: n
85
+ }) => ({
86
+ uid: "",
87
+ kind: "input",
88
+ type: "checkbox",
89
+ ...e && { props: e },
90
+ ...n && { validator: n },
91
+ ...t
92
+ }),
93
+ select: ({
94
+ config: t,
95
+ props: e,
96
+ validator: n
97
+ }) => ({
98
+ uid: "",
99
+ kind: "input",
100
+ type: "select",
101
+ ...e && { props: e },
102
+ ...n && { validator: n },
103
+ ...t
104
+ }),
105
+ //
106
+ // Layout widgets
107
+ //
108
+ flex: (t, e) => ({
109
+ uid: "",
110
+ kind: "layout",
111
+ type: "flex",
112
+ ...e && { props: e },
113
+ ...t
114
+ }),
115
+ tabs: (t, e) => ({
116
+ uid: "",
117
+ kind: "layout",
118
+ type: "tabs",
119
+ ...e && { props: e },
120
+ ...t
121
+ }),
122
+ //
123
+ // Display widgets
124
+ //
125
+ alert: (t, e) => ({
126
+ uid: "",
127
+ kind: "display",
128
+ type: "alert",
129
+ ...e && { props: e },
130
+ ...t
131
+ })
132
+ }, c = (t) => t !== null && typeof t == "object" && Object.prototype.hasOwnProperty.call(t, "label") && Object.prototype.hasOwnProperty.call(t, "value");
133
+ function d(t) {
134
+ return c(t) ? t : { label: t, value: t };
135
+ }
136
+ const b = (t) => ({
137
+ string: (e, n) => i.textinput({ config: { path: n } }),
138
+ enum: (e, n) => i.select({
139
+ config: { path: n },
140
+ props: { options: e.enum?.map(d) ?? [] },
141
+ validator: t.stringValidator()
142
+ }),
143
+ boolean: (e, n) => i.checkbox({ config: { path: n }, validator: t.booleanValidator() }),
144
+ number: (e, n) => i.numberinput({ config: { path: n }, validator: t.numberValidator() }),
145
+ integer: (e, n) => i.numberinput({ config: { path: n }, validator: t.integerValidator() }),
146
+ object: (e, n) => i.flex({ children: n }),
147
+ // one or the other must be valid .
148
+ // - remove data when tabs change.
149
+ // - don't generate all tabs initially.
150
+ oneOf: (e, n) => i.tabs(
151
+ { children: n }
152
+ /* TODO: , props: {logic: 'XOR'} as TabsProps*/
153
+ ),
154
+ // one or more must be valid.
155
+ // - don't remove data when tabs change.
156
+ // - generate all tabs initially, there might be a defaultValue to populate initial values.
157
+ anyOf: (e, n) => i.tabs(
158
+ { children: n }
159
+ /* TODO: , props: {logic: 'OR'} as TabsProps*/
160
+ ),
161
+ fallback: (e) => i.alert(
162
+ {},
163
+ {
164
+ text: `❌ Unsupported Json Schema field ${JSON.stringify(e)}`,
165
+ level: "error"
166
+ }
167
+ )
168
+ });
169
+ export {
170
+ i as Vanilla,
171
+ o as actionWidgets,
172
+ u as displayWidgets,
173
+ s as golemForm,
174
+ r as inputWidgets,
175
+ c as isOption,
176
+ l as layoutWidgets,
177
+ b as vanillaSchemaToFieldMap,
178
+ p as vanillaWidgets
179
+ };
package/index.umd.cjs ADDED
@@ -0,0 +1 @@
1
+ (function(i,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(i=typeof globalThis<"u"?globalThis:i||self,l(i["gui-shared"]={}))})(this,(function(i){"use strict";class l{create(e){return{states:e.states,form:{uid:"gui-root-uid",type:"flex",kind:"layout",children:e.form}}}}function s(){return new l}const u=["calendar","checkbox","currency","dateInput","datePicker","dropdown","list","number","password","radiogroup","rangeCalendar","repeater","select","textarea","textinput","toggle"],o=["accordion","flex","tabs"],d=["alert","renderer"],c=["button"],f=[...u,...o,...d,...c],a={textinput:({config:t,props:e,validator:n})=>({uid:"",kind:"input",type:"textinput",...e&&{props:e},...n&&{validator:n},...t}),password:({config:t,props:e,validator:n})=>({uid:"",kind:"input",type:"password",...e&&{props:e},...n&&{validator:n},...t}),numberinput:({config:t,props:e,validator:n})=>({uid:"",kind:"input",type:"numberinput",...e&&{props:e},...n&&{validator:n},...t}),checkbox:({config:t,props:e,validator:n})=>({uid:"",kind:"input",type:"checkbox",...e&&{props:e},...n&&{validator:n},...t}),select:({config:t,props:e,validator:n})=>({uid:"",kind:"input",type:"select",...e&&{props:e},...n&&{validator:n},...t}),flex:(t,e)=>({uid:"",kind:"layout",type:"flex",...e&&{props:e},...t}),tabs:(t,e)=>({uid:"",kind:"layout",type:"tabs",...e&&{props:e},...t}),alert:(t,e)=>({uid:"",kind:"display",type:"alert",...e&&{props:e},...t})},r=t=>t!==null&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"label")&&Object.prototype.hasOwnProperty.call(t,"value");function m(t){return r(t)?t:{label:t,value:t}}const b=t=>({string:(e,n)=>a.textinput({config:{path:n}}),enum:(e,n)=>a.select({config:{path:n},props:{options:e.enum?.map(m)??[]},validator:t.stringValidator()}),boolean:(e,n)=>a.checkbox({config:{path:n},validator:t.booleanValidator()}),number:(e,n)=>a.numberinput({config:{path:n},validator:t.numberValidator()}),integer:(e,n)=>a.numberinput({config:{path:n},validator:t.integerValidator()}),object:(e,n)=>a.flex({children:n}),oneOf:(e,n)=>a.tabs({children:n}),anyOf:(e,n)=>a.tabs({children:n}),fallback:e=>a.alert({},{text:`❌ Unsupported Json Schema field ${JSON.stringify(e)}`,level:"error"})});i.Vanilla=a,i.actionWidgets=c,i.displayWidgets=d,i.golemForm=s,i.inputWidgets=u,i.isOption=r,i.layoutWidgets=o,i.vanillaSchemaToFieldMap=b,i.vanillaWidgets=f,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,160 @@
1
+ import { Validator } from '@golemui/gui-validators';
2
+ import * as Core from '@golemui/core';
3
+ import * as Props from './widget.props';
4
+ type ExtractStates<S> = S extends Record<string, Core.ReactiveExpression> ? keyof S : never;
5
+ /**
6
+ * Make the uid propery optional on all widgets
7
+ */
8
+ type DeepPartialUid<T> = T extends (...args: infer A) => infer R ? (...args: A) => DeepPartialUid<R> : T extends any[] ? DeepPartialUidArray<T> : T extends object ? {
9
+ [K in keyof T as K extends 'uid' ? never : K]: DeepPartialUid<T[K]>;
10
+ } & {
11
+ uid?: string;
12
+ } : T;
13
+ type DeepPartialUidArray<T extends any[]> = {
14
+ [P in keyof T]: DeepPartialUid<T[P]>;
15
+ };
16
+ declare class GolemFormBuilder<FormType extends Record<string, any>, CustomWidget extends Core.FormWidget<any, FormType> = never> {
17
+ create<States extends Record<string, Core.ReactiveExpression>>(config: {
18
+ states?: States;
19
+ form: DeepPartialUid<GolemWidget<FormType, ExtractStates<States>, Validator, CustomWidget>>[];
20
+ }): Core.Form<ExtractStates<States>, FormType>;
21
+ }
22
+ /**
23
+ * Creates a new GolemFormBuilder instance for building type-safe forms.
24
+ *
25
+ * @template FormType - The shape of the form data object
26
+ * @template CustomWidget - Custom form widget type that extends Core.FormWidget, defaults to never
27
+ *
28
+ * @returns {GolemFormBuilder<FormType, CustomWidget>} A new GolemFormBuilder instance configured for the specified form type and custom widgets
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * type CustomHeadingWidget = {
33
+ * uid: string;
34
+ * kind: 'display';
35
+ * type: 'heading';
36
+ * props: {
37
+ * text: string;
38
+ * level?: number;
39
+ * };
40
+ * };
41
+ *
42
+ * type FormType = { name: string; registerMode: boolean };
43
+ *
44
+ * // 1. Pass CustomHeadingWidget here.
45
+ * // 2. Do NOT pass anything for States (it will be inferred in .create)
46
+ * export const myDemoForm = golemForm<FormType, CustomHeadingWidget>().create({
47
+ * states: {
48
+ * registering: '$form.register === true',
49
+ * },
50
+ * form: [
51
+ * {
52
+ * kind: 'input',
53
+ * type: 'textinput',
54
+ * path: 'name',
55
+ * label: 'Label',
56
+ * 'label.registering': '',
57
+ * props: { placeholder: (api) => api.$form.name, 'placeholder.registering': 'asas' },
58
+ * },
59
+ * // Custom widget usage
60
+ * {
61
+ * kind: 'display',
62
+ * type: 'heading',
63
+ * props: { text: 'User Details', level: 1 },
64
+ * },
65
+ * (api) => ({
66
+ * kind: 'input',
67
+ * type: 'textinput',
68
+ * path: 'something',
69
+ * label: api?.$form.name ? api?.$form.name : 'No name yet',
70
+ * }),
71
+ * {
72
+ * kind: 'layout',
73
+ * type: 'flex',
74
+ * props: { direction: 'horizontal' },
75
+ * children: [
76
+ * {
77
+ * kind: 'input',
78
+ * type: 'textinput',
79
+ * path: 'surname',
80
+ * props: { hint: 'not type safe' },
81
+ * },
82
+ * // Nested custom widget
83
+ * {
84
+ * kind: 'display',
85
+ * type: 'heading',
86
+ * props: { text: 'Nested Heading', level: 2 },
87
+ * },
88
+ * ],
89
+ * },
90
+ * ],
91
+ * });
92
+ * ```
93
+ */
94
+ export declare function golemForm<FormType extends Record<string, any>, CustomWidget extends Core.FormWidget<any, FormType> = never>(): GolemFormBuilder<FormType, CustomWidget>;
95
+ type GolemWidget<FormType extends Record<string, any>, States extends string, V, CustomWidget extends Core.FormWidget<any, FormType> = never> = GuiAccordion<FormType, States, V, CustomWidget> | GuiAlert<FormType, States> | GuiButton<FormType, States> | GuiCalendar<FormType, States, V> | GuiCheckbox<FormType, States, V> | GuiCurrency<FormType, States, V> | GuiDateinput<FormType, States, V> | GuiDatePicker<FormType, States, V> | GuiDropdown<FormType, States, V> | GuiFunctionWidget<FormType, States, V, CustomWidget> | GuiList<FormType, States, V> | GuiNumberinput<FormType, States, V> | GuiPassword<FormType, States, V> | GuiRadiogroup<FormType, States, V> | GuiRangeCalendar<FormType, States, V> | GuiRepeater<FormType, States, V, CustomWidget> | GuiSelect<FormType, States, V> | GuiFlex<FormType, States, V, CustomWidget> | GuiTabs<FormType, States, V, CustomWidget> | GuiTextarea<FormType, States, V> | GuiTextInput<FormType, States, V> | GuiToggle<FormType, States, V> | CustomWidget;
96
+ type GuiAccordion<FormType extends Record<string, any>, States extends string, V, CustomWidget extends Core.FormWidget<any, FormType>> = Core.LayoutWidget<States, FormType, Props.AccordionProps, GolemWidget<FormType, States, V, CustomWidget>[]> & {
97
+ type: 'accordion';
98
+ };
99
+ type GuiAlert<FormType extends Record<string, any>, States extends string> = Core.DisplayWidget<States, FormType, Props.AlertProps> & {
100
+ type: 'alert';
101
+ };
102
+ type GuiButton<FormType extends Record<string, any>, States extends string> = Core.ActionWidget<States, FormType, never> & {
103
+ type: 'button';
104
+ };
105
+ type GuiCalendar<FormType extends Record<string, any>, States extends string, V> = Core.InputWidget<string, States, FormType, Props.CalendarProps, V> & {
106
+ type: 'calendar';
107
+ };
108
+ type GuiCheckbox<FormType extends Record<string, any>, States extends string, V> = Core.InputWidget<boolean, States, FormType, Props.CheckboxProps, V> & {
109
+ type: 'checkbox';
110
+ };
111
+ type GuiCurrency<FormType extends Record<string, any>, States extends string, V> = Core.InputWidget<number, States, FormType, Props.CurrencyProps, V> & {
112
+ type: 'currency';
113
+ };
114
+ type GuiDateinput<FormType extends Record<string, any>, States extends string, V> = Core.InputWidget<string, States, FormType, Props.DateinputProps, V> & {
115
+ type: 'dateInput';
116
+ };
117
+ type GuiDatePicker<FormType extends Record<string, any>, States extends string, V> = Core.InputWidget<string, States, FormType, Props.DatePickerProps, V> & {
118
+ type: 'datePicker';
119
+ };
120
+ type GuiDropdown<FormType extends Record<string, any>, States extends string, V> = Core.InputWidget<Props.OptionValue, States, FormType, Props.DropdownProps<unknown>, V> & {
121
+ type: 'dropdown';
122
+ };
123
+ type GuiFunctionWidget<FormType extends Record<string, any>, States extends string, V, CustomWidget extends Core.FormWidget<any, FormType>> = (api?: Core.FunctionWidgetParams<FormType>) => Exclude<GolemWidget<FormType, States, V, CustomWidget>, () => any>;
124
+ type GuiList<FormType extends Record<string, any>, States extends string, V> = Core.InputWidget<Props.OptionValue, States, FormType, Props.ListProps<unknown>, V> & {
125
+ type: 'list';
126
+ };
127
+ type GuiNumberinput<FormType extends Record<string, any>, States extends string, V> = Core.InputWidget<number, States, FormType, Props.NumberinputProps, V> & {
128
+ type: 'number';
129
+ };
130
+ type GuiRadiogroup<FormType extends Record<string, any>, States extends string, V> = Core.InputWidget<Props.OptionValue, States, FormType, Props.RadiogroupProps, V> & {
131
+ type: 'radiogroup';
132
+ };
133
+ type GuiRangeCalendar<FormType extends Record<string, any>, States extends string, V> = Core.InputWidget<string, States, FormType, Props.RangeCalendarProps, V> & {
134
+ type: 'rangeCalendar';
135
+ };
136
+ type GuiRepeater<FormType extends Record<string, any>, States extends string, V, CustomWidget extends Core.FormWidget<any, FormType>> = Core.InputWidget<Record<string, unknown>[], States, FormType, Props.RepeaterProps<Core.LayoutWidget<States, FormType, Props.AccordionProps, GolemWidget<FormType, States, V, CustomWidget>[]>>, V> & {
137
+ type: 'repeater';
138
+ };
139
+ type GuiSelect<FormType extends Record<string, any>, States extends string, V> = Core.InputWidget<Props.OptionValue, States, FormType, Props.SelectProps, V> & {
140
+ type: 'select';
141
+ };
142
+ type GuiFlex<FormType extends Record<string, any>, States extends string, V, CustomWidget extends Core.FormWidget<any, FormType>> = Core.LayoutWidget<States, FormType, Props.FlexProps, GolemWidget<FormType, States, V, CustomWidget>[]> & {
143
+ type: 'flex';
144
+ };
145
+ type GuiTabs<FormType extends Record<string, any>, States extends string, V, CustomWidget extends Core.FormWidget<any, FormType>> = Core.LayoutWidget<States, FormType, Props.TabsProps, GolemWidget<FormType, States, V, CustomWidget>[]> & {
146
+ type: 'tabs';
147
+ };
148
+ type GuiTextarea<FormType extends Record<string, any>, States extends string, V> = Core.InputWidget<string, States, FormType, Props.TextareaProps, V> & {
149
+ type: 'textarea';
150
+ };
151
+ type GuiTextInput<FormType extends Record<string, any>, States extends string, V> = Core.InputWidget<string, States, FormType, Props.TextinputProps, V> & {
152
+ type: 'textinput';
153
+ };
154
+ type GuiPassword<FormType extends Record<string, any>, States extends string, V> = Core.InputWidget<string, States, FormType, Props.PasswordProps, V> & {
155
+ type: 'password';
156
+ };
157
+ type GuiToggle<FormType extends Record<string, any>, States extends string, V> = Core.InputWidget<boolean, States, FormType, Props.ToggleProps, V> & {
158
+ type: 'toggle';
159
+ };
160
+ export {};
@@ -0,0 +1,2 @@
1
+ import * as Core from '@golemui/core';
2
+ export declare const vanillaSchemaToFieldMap: <V>(validators: Core.JsonSchemaValidators<V>) => Core.SchemaToWidgetMap;
@@ -0,0 +1 @@
1
+ export * from './one-of';
@@ -0,0 +1,5 @@
1
+ import { Option } from '../widget.props';
2
+ /**
3
+ * Checks whether a value is a fully compliant Option (with label and value fields)
4
+ */
5
+ export declare const isOption: (opt: unknown) => opt is Option;
@@ -0,0 +1,39 @@
1
+ import * as Core from '@golemui/core';
2
+ import * as Props from './widget.props';
3
+ type InputWidgetConfig<T> = Omit<Core.InputWidget<T>, 'kind' | 'type' | 'uid' | 'props' | 'validator'>;
4
+ type LayoutWidgetConfig = Omit<Core.LayoutWidget, 'kind' | 'type' | 'uid' | 'props'>;
5
+ type DisplayWidgetConfig = Omit<Core.BaseWidget, 'kind' | 'type' | 'uid' | 'props'>;
6
+ /**
7
+ * Vanilla widget factory
8
+ */
9
+ export declare const Vanilla: {
10
+ textinput: <StateKeys extends Core.UiState = string, V = any>({ config, props, validator, }: {
11
+ config: InputWidgetConfig<string>;
12
+ props?: Props.TextinputProps;
13
+ validator?: V;
14
+ }) => Core.InputWidget<string, StateKeys>;
15
+ password: <StateKeys extends Core.UiState = string, V = any>({ config, props, validator, }: {
16
+ config: InputWidgetConfig<string>;
17
+ props?: Props.PasswordProps;
18
+ validator?: V;
19
+ }) => Core.InputWidget<string, StateKeys>;
20
+ numberinput: <StateKeys extends Core.UiState = string, V = any>({ config, props, validator, }: {
21
+ config: InputWidgetConfig<number>;
22
+ props?: Props.NumberinputProps;
23
+ validator?: V;
24
+ }) => Core.InputWidget<number, StateKeys>;
25
+ checkbox: <StateKeys extends Core.UiState = string, V = any>({ config, props, validator, }: {
26
+ config: InputWidgetConfig<boolean>;
27
+ props?: Props.CheckboxProps;
28
+ validator?: V;
29
+ }) => Core.InputWidget<boolean, StateKeys>;
30
+ select: <StateKeys extends Core.UiState = string, V = any>({ config, props, validator, }: {
31
+ config: InputWidgetConfig<string>;
32
+ props?: Props.SelectProps;
33
+ validator?: V;
34
+ }) => Core.InputWidget<string, StateKeys>;
35
+ flex: <StateKeys extends Core.UiState = string>(config: LayoutWidgetConfig, props?: Props.FlexProps) => Core.LayoutWidget<StateKeys>;
36
+ tabs: <StateKeys extends Core.UiState = string>(config: LayoutWidgetConfig, props?: Props.TabsProps) => Core.LayoutWidget<StateKeys>;
37
+ alert: <StateKeys extends Core.UiState = string>(config: DisplayWidgetConfig, props?: Props.AlertProps) => Core.DisplayWidget<StateKeys>;
38
+ };
39
+ export {};
@@ -0,0 +1,348 @@
1
+ import { Localizable, WidgetPropertyFunctionParams } from '@golemui/core';
2
+ export interface DateRange {
3
+ start: string;
4
+ end?: string;
5
+ }
6
+ export type AccordionProps = {
7
+ singleOpen?: boolean;
8
+ defaultOpen?: {
9
+ [key: string]: boolean;
10
+ };
11
+ renderMode?: 'all' | 'activeOnly';
12
+ sections: {
13
+ label: Localizable;
14
+ uid: string;
15
+ }[];
16
+ };
17
+ export type ButtonProps = {
18
+ variant?: 'filled' | 'outlined';
19
+ };
20
+ export type TextinputProps = {
21
+ hint?: string;
22
+ placeholder?: string;
23
+ icon?: string;
24
+ };
25
+ export type PasswordProps = {
26
+ hint?: string;
27
+ placeholder?: string;
28
+ icon?: string;
29
+ showPasswordIcon?: string;
30
+ hidePasswordIcon?: string;
31
+ showPasswordLabel?: string;
32
+ hidePasswordLabel?: string;
33
+ };
34
+ export type CurrencyProps = {
35
+ currency?: string;
36
+ step?: number;
37
+ maximumFractionDigits?: number;
38
+ minimumFractionDigits?: number;
39
+ hint?: string;
40
+ placeholder?: string;
41
+ icon?: string;
42
+ };
43
+ export type TextareaProps = {
44
+ hint?: string;
45
+ placeholder?: string;
46
+ icon?: string;
47
+ counterMode?: 'remaining' | 'current';
48
+ minimumHeight?: number;
49
+ autoGrow?: boolean;
50
+ maxLength?: number;
51
+ };
52
+ export type CalendarProps = {
53
+ /**
54
+ * An optional descriptive text providing guidance or information about the associated field or functionality.
55
+ */
56
+ hint?: string;
57
+ /**
58
+ * A string representing the icon for navigating to the previous month.
59
+ * This variable is optional and may define a custom icon as a CSS class
60
+ * that will be used to visually represent the "previous month" navigation button.
61
+ */
62
+ prevMonthIcon?: string;
63
+ /**
64
+ * A string representing the icon for navigating to the previous month.
65
+ * This variable is optional and may define a custom icon as a CSS class
66
+ * that will be used to visually represent the "next month" navigation button.
67
+ */
68
+ nextMonthIcon?: string;
69
+ /**
70
+ * An optional string that represents the ARIA label for the previous month's navigation button.
71
+ * This label is used to improve accessibility by providing screen readers with descriptive text.
72
+ */
73
+ prevMonthAriaLabel?: string;
74
+ /**
75
+ * An optional string that represents the ARIA label for the next month's navigation button.
76
+ * This label is used to improve accessibility by providing screen readers with descriptive text.
77
+ */
78
+ nextMonthAriaLabel?: string;
79
+ /**
80
+ * Specifies the formatting style for displaying the day portion of a date.
81
+ *
82
+ * The variable `dayFormat` can accept one of the following values:
83
+ * - 'numeric': Displays the day as a numeric value without leading zeros (e.g., 1, 15, 31).
84
+ * - '2-digit': Displays the day as a two-digit value with leading zeros if necessary (e.g., 01, 15, 31).
85
+ *
86
+ * This is typically used to configure date formatting options for internationalization purposes.
87
+ */
88
+ dayFormat?: 'numeric' | '2-digit';
89
+ /**
90
+ * Specifies the format of the weekday to be used.
91
+ * Acceptable values are:
92
+ * - 'short': Abbreviated format of the weekday (e.g., Mon, Tue).
93
+ * - 'long': Full name of the weekday (e.g., Monday, Tuesday).
94
+ * - 'narrow': Minimal format of the weekday, typically a single letter (e.g., M, T).
95
+ * This property is typically used to customize the presentation of weekday names.
96
+ */
97
+ weekdayFormat?: 'short' | 'long' | 'narrow';
98
+ /**
99
+ * Specifies the format style to use when displaying month values.
100
+ *
101
+ * The accepted formats are:
102
+ * - 'numeric': Displays the month as a number without leading zeros (e.g., "1" for January).
103
+ * - '2-digit': Displays the month as a two-digit number with leading zeros as necessary (e.g., "01" for January).
104
+ * - 'long': Displays the month as a full name (e.g., "January").
105
+ * - 'short': Displays the month as an abbreviated name (e.g., "Jan").
106
+ * - 'narrow': Displays a single letter representation of the month (e.g., "J" for January).
107
+ *
108
+ * This property is optional. When not specified, the default formatting behavior may depend on the context or implementation.
109
+ */
110
+ monthFormat?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow';
111
+ /**
112
+ * Represents the earliest allowable date in the calendar.
113
+ * The value is optional and can be assigned as a string in an ISO date format.
114
+ */
115
+ minDate?: string;
116
+ /**
117
+ * Represents the latest allowable date in the calendar.
118
+ * The value is optional and can be assigned as a string in an ISO date format.
119
+ */
120
+ maxDate?: string;
121
+ /**
122
+ * Represents an optional property that defines a set of date ranges
123
+ * which are disabled or unavailable for selection.
124
+ *
125
+ * @type {DateRange[] | undefined}
126
+ */
127
+ disabledRanges?: DateRange[];
128
+ /**
129
+ * Specifies the number of months to be displayed in the calendar.
130
+ * Default is 1.
131
+ */
132
+ numberOfMonths?: number;
133
+ };
134
+ export type RangeCalendarProps = {
135
+ /**
136
+ * An optional descriptive text providing guidance or information about the associated widget or functionality.
137
+ */
138
+ hint?: string;
139
+ /**
140
+ * A string representing the icon for navigating to the previous month.
141
+ * This variable is optional and may define a custom icon as a CSS class
142
+ * that will be used to visually represent the "previous month" navigation button.
143
+ */
144
+ prevMonthIcon?: string;
145
+ /**
146
+ * A string representing the icon for navigating to the previous month.
147
+ * This variable is optional and may define a custom icon as a CSS class
148
+ * that will be used to visually represent the "next month" navigation button.
149
+ */
150
+ nextMonthIcon?: string;
151
+ /**
152
+ * An optional string that represents the ARIA label for the previous month's navigation button.
153
+ * This label is used to improve accessibility by providing screen readers with descriptive text.
154
+ */
155
+ prevMonthAriaLabel?: string;
156
+ /**
157
+ * An optional string that represents the ARIA label for the next month's navigation button.
158
+ * This label is used to improve accessibility by providing screen readers with descriptive text.
159
+ */
160
+ nextMonthAriaLabel?: string;
161
+ /**
162
+ * Specifies the formatting style for displaying the day portion of a date.
163
+ *
164
+ * The variable `dayFormat` can accept one of the following values:
165
+ * - 'numeric': Displays the day as a numeric value without leading zeros (e.g., 1, 15, 31).
166
+ * - '2-digit': Displays the day as a two-digit value with leading zeros if necessary (e.g., 01, 15, 31).
167
+ *
168
+ * This is typically used to configure date formatting options for internationalization purposes.
169
+ */
170
+ dayFormat?: 'numeric' | '2-digit';
171
+ /**
172
+ * Specifies the format of the weekday to be used.
173
+ * Acceptable values are:
174
+ * - 'short': Abbreviated format of the weekday (e.g., Mon, Tue).
175
+ * - 'long': Full name of the weekday (e.g., Monday, Tuesday).
176
+ * - 'narrow': Minimal format of the weekday, typically a single letter (e.g., M, T).
177
+ * This property is typically used to customize the presentation of weekday names.
178
+ */
179
+ weekdayFormat?: 'short' | 'long' | 'narrow';
180
+ /**
181
+ * Specifies the format style to use when displaying month values.
182
+ *
183
+ * The accepted formats are:
184
+ * - 'numeric': Displays the month as a number without leading zeros (e.g., "1" for January).
185
+ * - '2-digit': Displays the month as a two-digit number with leading zeros as necessary (e.g., "01" for January).
186
+ * - 'long': Displays the month as a full name (e.g., "January").
187
+ * - 'short': Displays the month as an abbreviated name (e.g., "Jan").
188
+ * - 'narrow': Displays a single letter representation of the month (e.g., "J" for January).
189
+ *
190
+ * This property is optional. When not specified, the default formatting behavior may depend on the context or implementation.
191
+ */
192
+ monthFormat?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow';
193
+ /**
194
+ * Represents the earliest allowable date in the calendar.
195
+ * The value is optional and can be assigned as a string in an ISO date format.
196
+ */
197
+ minDate?: string;
198
+ /**
199
+ * Represents the latest allowable date in the calendar.
200
+ * The value is optional and can be assigned as a string in an ISO date format.
201
+ */
202
+ maxDate?: string;
203
+ /**
204
+ * Represents an optional property that defines a set of date ranges
205
+ * which are disabled or unavailable for selection.
206
+ *
207
+ * @type {DateRange[] | undefined}
208
+ */
209
+ disabledRanges?: DateRange[];
210
+ /**
211
+ * Specifies the number of months to be displayed in the calendar.
212
+ * Default is 1.
213
+ */
214
+ numberOfMonths?: number;
215
+ };
216
+ export type DateinputProps = {
217
+ hint?: string;
218
+ icon?: string;
219
+ };
220
+ export type DatePickerProps = {
221
+ hint?: string;
222
+ placeholder?: string;
223
+ icon?: string;
224
+ prevMonthIcon?: string;
225
+ nextMonthIcon?: string;
226
+ prevMonthAriaLabel?: string;
227
+ nextMonthAriaLabel?: string;
228
+ dayFormat?: 'numeric' | '2-digit';
229
+ weekdayFormat?: 'short' | 'long' | 'narrow';
230
+ monthFormat?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow';
231
+ };
232
+ export type NumberinputProps = {
233
+ placeholder?: string;
234
+ hint?: string;
235
+ step?: number;
236
+ minimum?: number;
237
+ maximum?: number;
238
+ autoGrow?: true;
239
+ };
240
+ export type CheckboxProps = {
241
+ checkboxPosition?: 'left' | 'right';
242
+ hint?: string;
243
+ };
244
+ export type ToggleProps = {
245
+ togglePosition?: 'left' | 'right';
246
+ hint?: string;
247
+ };
248
+ export type AlertProps = {
249
+ text: string;
250
+ level?: 'default' | 'info' | 'success' | 'warning' | 'error';
251
+ };
252
+ /**
253
+ * Non-serializable component props. Used to render the provided component.
254
+ * @template ComponentType Framework-dependent type for the component. e.g. ReactNode, Type<any>
255
+ */
256
+ export type RendererProps<ComponentType = unknown> = {
257
+ render: ComponentType;
258
+ };
259
+ /**
260
+ * Non-serializable component props for Angular. Used to render the provided component.
261
+ * @template ComponentType Framework-dependent type for the component. e.g. ReactNode, Type<any>
262
+ */
263
+ export type ComponentRendererProps<ComponentType = unknown> = {
264
+ render: {
265
+ component: ComponentType;
266
+ api: WidgetPropertyFunctionParams<any>;
267
+ };
268
+ };
269
+ export type RepeaterProps<Template> = {
270
+ addLabel?: string;
271
+ removeLabel?: string;
272
+ limit?: number;
273
+ template: Template;
274
+ };
275
+ export type OptionValue = string | number;
276
+ export type Option = {
277
+ label: string;
278
+ value: OptionValue;
279
+ };
280
+ export type SelectProps = {
281
+ hint?: string;
282
+ icon?: string;
283
+ options: Option[];
284
+ placeholder?: string;
285
+ labelField?: string;
286
+ valueField?: string;
287
+ };
288
+ export type ListItem<T> = {
289
+ template: T;
290
+ value: OptionValue;
291
+ };
292
+ type ItemKeys<T> = T extends Record<string, any> ? keyof T : string;
293
+ export type DropdownProps<T> = {
294
+ placeholder?: string;
295
+ hint?: string;
296
+ items: ListItem<T>[];
297
+ /**
298
+ * Property widget used to display in the input when an item option is selected
299
+ */
300
+ labelField?: ItemKeys<T>;
301
+ valueField?: ItemKeys<T>;
302
+ searchFields?: ItemKeys<T>[];
303
+ height?: number;
304
+ itemHeight?: number;
305
+ /**
306
+ * Should match with one of the provided itemRenderer keys
307
+ */
308
+ itemRenderer?: string;
309
+ /**
310
+ * Time in milliseconds to wait on each keystroke to trigger the input event. Default: 500
311
+ */
312
+ inputDebounce?: number;
313
+ };
314
+ export type ListProps<T> = {
315
+ hint?: string;
316
+ items: ListItem<T>[];
317
+ valueField?: string;
318
+ height?: number;
319
+ itemHeight?: number;
320
+ /**
321
+ * Should match with one of the provided itemRenderer keys
322
+ */
323
+ itemRenderer?: string;
324
+ };
325
+ export type RadiogroupProps = {
326
+ hint?: string;
327
+ options: Option[];
328
+ labelField?: string;
329
+ valueField?: string;
330
+ };
331
+ export type OneOfProps = {
332
+ labelField?: string;
333
+ valueField?: string;
334
+ };
335
+ export type FlexProps = {
336
+ direction?: 'horizontal' | 'vertical';
337
+ align?: 'center' | 'start' | 'end' | 'space-between' | 'space-around';
338
+ gap?: number;
339
+ };
340
+ export type TabsProps = {
341
+ defaultOpen?: string;
342
+ renderMode: 'all' | 'activeOnly';
343
+ tabs: {
344
+ label: string;
345
+ uid: string;
346
+ }[];
347
+ };
348
+ export {};
@@ -0,0 +1,10 @@
1
+ export declare const inputWidgets: readonly ["calendar", "checkbox", "currency", "dateInput", "datePicker", "dropdown", "list", "number", "password", "radiogroup", "rangeCalendar", "repeater", "select", "textarea", "textinput", "toggle"];
2
+ export declare const layoutWidgets: readonly ["accordion", "flex", "tabs"];
3
+ export declare const displayWidgets: readonly ["alert", "renderer"];
4
+ export declare const actionWidgets: readonly ["button"];
5
+ export declare const vanillaWidgets: ("number" | "flex" | "repeater" | "accordion" | "alert" | "button" | "calendar" | "checkbox" | "currency" | "dateInput" | "datePicker" | "dropdown" | "list" | "password" | "radiogroup" | "rangeCalendar" | "select" | "tabs" | "textarea" | "textinput" | "toggle" | "renderer")[];
6
+ export type VanillaInputWidget = (typeof inputWidgets)[number];
7
+ export type VanillaLayoutWidget = (typeof layoutWidgets)[number];
8
+ export type VanillaDisplayWidget = (typeof displayWidgets)[number];
9
+ export type VanillaActionWidget = (typeof actionWidgets)[number];
10
+ export type VanillaWidget = (typeof vanillaWidgets)[number];
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@golemui/gui-shared",
3
+ "version": "0.0.2",
4
+ "type": "module",
5
+ "main": "./index.umd.cjs",
6
+ "module": "./index.js",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./index.d.ts",
11
+ "import": "./index.js",
12
+ "require": "./index.umd.cjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "lib",
17
+ "index.d.ts",
18
+ "index.js",
19
+ "index.umd.cjs",
20
+ "*.md"
21
+ ],
22
+ "dependencies": {
23
+ "@golemui/core": "*",
24
+ "@golemui/gui-validators": "*"
25
+ }
26
+ }