@inglorious/ui 0.1.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.
Files changed (83) hide show
  1. package/LICENSE +9 -0
  2. package/package.json +142 -0
  3. package/src/controls/button/button.stories.js +139 -0
  4. package/src/controls/button/index.js +5 -0
  5. package/src/controls/button/style.css +148 -0
  6. package/src/controls/button/template.js +74 -0
  7. package/src/controls/button-group/button-group.stories.js +108 -0
  8. package/src/controls/button-group/index.js +4 -0
  9. package/src/controls/button-group/style.css +58 -0
  10. package/src/controls/button-group/template.js +117 -0
  11. package/src/controls/checkbox/checkbox.stories.js +47 -0
  12. package/src/controls/checkbox/index.js +4 -0
  13. package/src/controls/checkbox/style.css +33 -0
  14. package/src/controls/checkbox/template.js +54 -0
  15. package/src/controls/fab/fab.stories.js +52 -0
  16. package/src/controls/fab/index.js +4 -0
  17. package/src/controls/fab/style.css +76 -0
  18. package/src/controls/fab/template.js +33 -0
  19. package/src/controls/icon-button/icon-button.stories.js +70 -0
  20. package/src/controls/icon-button/index.js +4 -0
  21. package/src/controls/icon-button/style.css +14 -0
  22. package/src/controls/icon-button/template.js +47 -0
  23. package/src/controls/input/index.js +4 -0
  24. package/src/controls/input/input.stories.js +180 -0
  25. package/src/controls/input/style.css +121 -0
  26. package/src/controls/input/template.js +111 -0
  27. package/src/controls/radio-group/index.js +4 -0
  28. package/src/controls/radio-group/radio-group.stories.js +51 -0
  29. package/src/controls/radio-group/style.css +41 -0
  30. package/src/controls/radio-group/template.js +71 -0
  31. package/src/controls/rating/index.js +4 -0
  32. package/src/controls/rating/rating.stories.js +47 -0
  33. package/src/controls/rating/style.css +29 -0
  34. package/src/controls/rating/template.js +53 -0
  35. package/src/controls/select/handlers.js +133 -0
  36. package/src/controls/select/helpers.js +91 -0
  37. package/src/controls/select/index.js +15 -0
  38. package/src/controls/select/select.stories.js +90 -0
  39. package/src/controls/select/style.css +211 -0
  40. package/src/controls/select/template.js +423 -0
  41. package/src/controls/slider/index.js +4 -0
  42. package/src/controls/slider/slider.stories.js +43 -0
  43. package/src/controls/slider/style.css +28 -0
  44. package/src/controls/slider/template.js +66 -0
  45. package/src/controls/switch/index.js +4 -0
  46. package/src/controls/switch/style.css +82 -0
  47. package/src/controls/switch/switch.stories.js +45 -0
  48. package/src/controls/switch/template.js +55 -0
  49. package/src/index.js +14 -0
  50. package/src/layout/flex/flex.stories.js +103 -0
  51. package/src/layout/flex/index.js +4 -0
  52. package/src/layout/flex/style.css +103 -0
  53. package/src/layout/flex/template.js +41 -0
  54. package/src/layout/grid/grid.stories.js +82 -0
  55. package/src/layout/grid/index.js +4 -0
  56. package/src/layout/grid/style.css +51 -0
  57. package/src/layout/grid/template.js +47 -0
  58. package/src/shared/applyElementProps.js +79 -0
  59. package/src/shared/withRenderValidation.js +19 -0
  60. package/src/stories/notifyStory.js +43 -0
  61. package/src/themes/bootstrap.css +118 -0
  62. package/src/themes/inglorious.css +106 -0
  63. package/src/themes/material.css +124 -0
  64. package/src/tokens/index.css +133 -0
  65. package/src/widgets/card/card.stories.js +135 -0
  66. package/src/widgets/card/index.js +4 -0
  67. package/src/widgets/card/style.css +53 -0
  68. package/src/widgets/card/template.js +97 -0
  69. package/types/controls/button-group.d.ts +35 -0
  70. package/types/controls/button.d.ts +23 -0
  71. package/types/controls/checkbox.d.ts +18 -0
  72. package/types/controls/fab.d.ts +19 -0
  73. package/types/controls/icon-button.d.ts +23 -0
  74. package/types/controls/input.d.ts +29 -0
  75. package/types/controls/radio-group.d.ts +25 -0
  76. package/types/controls/rating.d.ts +18 -0
  77. package/types/controls/select.d.ts +56 -0
  78. package/types/controls/slider.d.ts +21 -0
  79. package/types/controls/switch.d.ts +17 -0
  80. package/types/index.d.ts +14 -0
  81. package/types/layout/flex.d.ts +20 -0
  82. package/types/layout/grid.d.ts +19 -0
  83. package/types/widgets/card.d.ts +21 -0
@@ -0,0 +1,97 @@
1
+ /**
2
+ * @typedef {import('../../../types/widgets/card').CardEntity} CardEntity
3
+ * @typedef {import('@inglorious/web').Api} Api
4
+ * @typedef {import('@inglorious/web').TemplateResult} TemplateResult
5
+ */
6
+
7
+ import { classMap, html } from "@inglorious/web"
8
+
9
+ /**
10
+ * Card component for Inglorious Web.
11
+ *
12
+ * @example
13
+ * // Stateless usage
14
+ * card.render({ title: 'Card Title', subtitle: 'Description' }, api)
15
+ *
16
+ * @example
17
+ * // Stateful usage with event handling
18
+ * // Entity: { type: 'card', id: 'myCard', title: 'Click me' }
19
+ * // In store: api.render('myCard')
20
+ *
21
+ * @param {CardEntity} entity
22
+ * @param {Api} api
23
+ * @returns {TemplateResult}
24
+ */
25
+ export function render(entity, api) {
26
+ const { hoverable = false, clickable = false, fullWidth = false } = entity
27
+ const type = getCardType(entity, api)
28
+
29
+ const classes = {
30
+ "iw-card": true,
31
+ "iw-card-hoverable": hoverable || clickable,
32
+ "iw-card-clickable": clickable,
33
+ "iw-card-full-width": fullWidth,
34
+ }
35
+
36
+ return html`
37
+ <div
38
+ class=${classMap(classes)}
39
+ @click=${() => api.notify(`#${entity.id}:click`)}
40
+ >
41
+ ${type.renderHeader(entity, api)} ${type.renderBody(entity, api)}
42
+ ${type.renderFooter(entity, api)}
43
+ </div>
44
+ `
45
+ }
46
+
47
+ /**
48
+ * Default header renderer.
49
+ * Override in composed types for custom header rendering.
50
+ * @param {CardEntity} entity
51
+ * @returns {TemplateResult | null}
52
+ */
53
+ export function renderHeader(entity) {
54
+ const { title, subtitle } = entity
55
+ const hasHeader = title || subtitle
56
+ if (!hasHeader) return null
57
+
58
+ return html`<div class="iw-card-header">
59
+ ${title ? html`<h3 class="iw-card-title">${title}</h3>` : null}
60
+ ${subtitle ? html`<p class="iw-card-subtitle">${subtitle}</p>` : null}
61
+ </div>`
62
+ }
63
+
64
+ /**
65
+ * Default body renderer.
66
+ * Override in composed types for custom body rendering.
67
+ * @returns {TemplateResult}
68
+ */
69
+ export function renderBody() {
70
+ return html`<div class="iw-card-body">
71
+ <slot></slot>
72
+ </div>`
73
+ }
74
+
75
+ /**
76
+ * Default footer renderer.
77
+ * Override in composed types for custom footer rendering.
78
+ * @returns {TemplateResult | null}
79
+ */
80
+ export function renderFooter() {
81
+ return null
82
+ }
83
+
84
+ function getCardType(entity, api) {
85
+ const resolved = api?.getType?.(entity?.type)
86
+ return hasCardRenderers(resolved)
87
+ ? resolved
88
+ : { renderHeader, renderBody, renderFooter }
89
+ }
90
+
91
+ function hasCardRenderers(type) {
92
+ return (
93
+ typeof type?.renderHeader === "function" &&
94
+ typeof type?.renderBody === "function" &&
95
+ typeof type?.renderFooter === "function"
96
+ )
97
+ }
@@ -0,0 +1,35 @@
1
+ import type { TemplateResult, Api } from "@inglorious/web"
2
+
3
+ export interface ButtonGroupItem {
4
+ id?: string
5
+ value?: string
6
+ label: string
7
+ children?: TemplateResult | string | number
8
+ disabled?: boolean
9
+ variant?: "default" | "outline" | "ghost"
10
+ color?: "primary" | "secondary" | "success" | "warning" | "error" | "info"
11
+ size?: "sm" | "md" | "lg"
12
+ icon?: string
13
+ iconAfter?: string
14
+ [key: string]: unknown
15
+ }
16
+
17
+ export interface ButtonGroupEntity {
18
+ id?: string
19
+ buttons?: ButtonGroupItem[]
20
+ value?: string | string[]
21
+ multiple?: boolean
22
+ direction?: "row" | "column"
23
+ attached?: boolean
24
+ size?: "sm" | "md" | "lg"
25
+ variant?: "default" | "outline" | "ghost"
26
+ color?: "primary" | "secondary" | "success" | "warning" | "error" | "info"
27
+ disabled?: boolean
28
+ [key: string]: unknown
29
+ }
30
+
31
+ export interface ButtonGroupType {
32
+ render(entity: ButtonGroupEntity, api: Api): TemplateResult
33
+ }
34
+
35
+ export declare const buttonGroup: ButtonGroupType
@@ -0,0 +1,23 @@
1
+ import type { TemplateResult, Api } from "@inglorious/web"
2
+
3
+ export interface ButtonEntity {
4
+ id?: string
5
+ children?: TemplateResult | string | number
6
+ variant?: "default" | "outline" | "ghost"
7
+ color?: "primary" | "secondary" | "success" | "warning" | "error" | "info"
8
+ size?: "sm" | "md" | "lg"
9
+ shape?: "rectangle" | "pill" | "round" | "square"
10
+ disabled?: boolean
11
+ fullWidth?: boolean
12
+ type?: "button" | "submit" | "reset" | "menu"
13
+ ariaLabel?: string
14
+ ariaPressed?: boolean
15
+ className?: string
16
+ [key: string]: unknown
17
+ }
18
+
19
+ export interface ButtonType {
20
+ render(entity: ButtonEntity, api: Api): TemplateResult
21
+ }
22
+
23
+ export declare const button: ButtonType
@@ -0,0 +1,18 @@
1
+ import type { TemplateResult, Api } from "@inglorious/web"
2
+
3
+ export interface CheckboxEntity {
4
+ id?: string
5
+ name?: string
6
+ label?: string
7
+ checked?: boolean
8
+ disabled?: boolean
9
+ required?: boolean
10
+ size?: "sm" | "md" | "lg"
11
+ [key: string]: unknown
12
+ }
13
+
14
+ export interface CheckboxType {
15
+ render(entity: CheckboxEntity, api: Api): TemplateResult
16
+ }
17
+
18
+ export declare const checkbox: CheckboxType
@@ -0,0 +1,19 @@
1
+ import type { TemplateResult, Api } from "@inglorious/web"
2
+
3
+ export interface FabEntity {
4
+ id?: string
5
+ children?: TemplateResult | string | number
6
+ color?: "primary" | "secondary" | "success" | "warning" | "error" | "info"
7
+ size?: "sm" | "md" | "lg"
8
+ disabled?: boolean
9
+ type?: "button" | "submit" | "reset" | "menu"
10
+ extended?: boolean
11
+ ariaLabel?: string
12
+ [key: string]: unknown
13
+ }
14
+
15
+ export interface FabType {
16
+ render(entity: FabEntity, api: Api): TemplateResult
17
+ }
18
+
19
+ export declare const fab: FabType
@@ -0,0 +1,23 @@
1
+ import type { TemplateResult, Api } from "@inglorious/web"
2
+
3
+ export interface IconButtonEntity {
4
+ id?: string
5
+ icon?: string
6
+ label?: string
7
+ iconAfter?: string
8
+ direction?: "row" | "column"
9
+ iconOnly?: boolean
10
+ ariaLabel?: string
11
+ variant?: "default" | "outline" | "ghost"
12
+ color?: "primary" | "secondary" | "success" | "warning" | "error" | "info"
13
+ size?: "sm" | "md" | "lg"
14
+ disabled?: boolean
15
+ fullWidth?: boolean
16
+ type?: "button" | "submit" | "reset" | "menu"
17
+ }
18
+
19
+ export interface IconButtonType {
20
+ render(entity: IconButtonEntity, api: Api): TemplateResult
21
+ }
22
+
23
+ export declare const iconButton: IconButtonType
@@ -0,0 +1,29 @@
1
+ import type { TemplateResult, Api } from "@inglorious/web"
2
+
3
+ export interface InputEntity {
4
+ id?: string
5
+ name?: string
6
+ type?: "text" | "password" | "email" | "number" | "tel" | "url" | "search"
7
+ value?: string
8
+ placeholder?: string
9
+ label?: string
10
+ hint?: string
11
+ error?: string
12
+ size?: "sm" | "md" | "lg"
13
+ disabled?: boolean
14
+ readonly?: boolean
15
+ required?: boolean
16
+ fullWidth?: boolean
17
+ icon?: string
18
+ iconAfter?: string
19
+ [key: string]: unknown
20
+ }
21
+
22
+ export interface InputType {
23
+ render(entity: InputEntity, api: Api): TemplateResult
24
+ change(entity: InputEntity, payload: string, api: Api): void
25
+ blur(entity: InputEntity, payload: unknown, api: Api): void
26
+ focus(entity: InputEntity, payload: unknown, api: Api): void
27
+ }
28
+
29
+ export declare const input: InputType
@@ -0,0 +1,25 @@
1
+ import type { TemplateResult, Api } from "@inglorious/web"
2
+
3
+ export interface RadioOption {
4
+ label: string
5
+ value: string
6
+ disabled?: boolean
7
+ [key: string]: unknown
8
+ }
9
+
10
+ export interface RadioGroupEntity {
11
+ id?: string
12
+ name?: string
13
+ label?: string
14
+ value?: string
15
+ options?: RadioOption[]
16
+ direction?: "column" | "row"
17
+ disabled?: boolean
18
+ [key: string]: unknown
19
+ }
20
+
21
+ export interface RadioGroupType {
22
+ render(entity: RadioGroupEntity, api: Api): TemplateResult
23
+ }
24
+
25
+ export declare const radioGroup: RadioGroupType
@@ -0,0 +1,18 @@
1
+ import type { TemplateResult, Api } from "@inglorious/web"
2
+
3
+ export interface RatingEntity {
4
+ id?: string
5
+ value?: number
6
+ max?: number
7
+ disabled?: boolean
8
+ readonly?: boolean
9
+ symbol?: string
10
+ emptySymbol?: string
11
+ size?: "sm" | "md" | "lg"
12
+ }
13
+
14
+ export interface RatingType {
15
+ render(entity: RatingEntity, api: Api): TemplateResult
16
+ }
17
+
18
+ export declare const rating: RatingType
@@ -0,0 +1,56 @@
1
+ import type { TemplateResult, Api } from "@inglorious/web"
2
+
3
+ export type SelectOption =
4
+ | string
5
+ | number
6
+ | {
7
+ value: string | number
8
+ label?: string
9
+ disabled?: boolean
10
+ isDisabled?: boolean
11
+ [key: string]: unknown
12
+ }
13
+
14
+ export interface SelectEntity {
15
+ id?: string
16
+ type?: string
17
+ label?: string
18
+ options?: SelectOption[]
19
+
20
+ isOpen?: boolean
21
+ searchTerm?: string
22
+ focusedIndex?: number
23
+
24
+ isMulti?: boolean
25
+ selectedValue?: string | number | (string | number)[] | null
26
+
27
+ isLoading?: boolean
28
+ isDisabled?: boolean
29
+ isSearchable?: boolean
30
+ isClearable?: boolean
31
+
32
+ placeholder?: string
33
+ noOptionsMessage?: string
34
+ loadingMessage?: string
35
+
36
+ fullWidth?: boolean
37
+ size?: "sm" | "md" | "lg"
38
+ [key: string]: unknown
39
+ }
40
+
41
+ export interface SelectType {
42
+ create(entity: SelectEntity): void
43
+ render(entity: SelectEntity, api: Api): TemplateResult
44
+ open(entity: SelectEntity): void
45
+ close(entity: SelectEntity): void
46
+ toggle(entity: SelectEntity): void
47
+ optionSelect(entity: SelectEntity, option: SelectOption): void
48
+ clear(entity: SelectEntity): void
49
+ searchChange(entity: SelectEntity, searchTerm: string): void
50
+ focusNext(entity: SelectEntity): void
51
+ focusPrev(entity: SelectEntity): void
52
+ focusFirst(entity: SelectEntity): void
53
+ focusLast(entity: SelectEntity): void
54
+ }
55
+
56
+ export declare const select: SelectType
@@ -0,0 +1,21 @@
1
+ import type { TemplateResult, Api } from "@inglorious/web"
2
+
3
+ export interface SliderEntity {
4
+ id?: string
5
+ name?: string
6
+ label?: string
7
+ value?: number
8
+ min?: number
9
+ max?: number
10
+ step?: number
11
+ disabled?: boolean
12
+ showValue?: boolean
13
+ fullWidth?: boolean
14
+ [key: string]: unknown
15
+ }
16
+
17
+ export interface SliderType {
18
+ render(entity: SliderEntity, api: Api): TemplateResult
19
+ }
20
+
21
+ export declare const slider: SliderType
@@ -0,0 +1,17 @@
1
+ import type { TemplateResult, Api } from "@inglorious/web"
2
+
3
+ export interface SwitchEntity {
4
+ id?: string
5
+ name?: string
6
+ label?: string
7
+ checked?: boolean
8
+ disabled?: boolean
9
+ size?: "sm" | "md" | "lg"
10
+ [key: string]: unknown
11
+ }
12
+
13
+ export interface SwitchType {
14
+ render(entity: SwitchEntity, api: Api): TemplateResult
15
+ }
16
+
17
+ export declare const switchControl: SwitchType
@@ -0,0 +1,14 @@
1
+ export type { ButtonEntity } from "./controls/button"
2
+ export type { ButtonGroupEntity } from "./controls/button-group"
3
+ export type { CheckboxEntity } from "./controls/checkbox"
4
+ export type { FabEntity } from "./controls/fab"
5
+ export type { IconButtonEntity } from "./controls/icon-button"
6
+ export type { InputEntity } from "./controls/input"
7
+ export type { RadioGroupEntity } from "./controls/radio-group"
8
+ export type { RatingEntity } from "./controls/rating"
9
+ export type { SelectEntity } from "./controls/select"
10
+ export type { SliderEntity } from "./controls/slider"
11
+ export type { SwitchEntity } from "./controls/switch"
12
+ export type { CardEntity } from "./widgets/card"
13
+ export type { FlexEntity } from "./layout/flex"
14
+ export type { GridEntity } from "./layout/grid"
@@ -0,0 +1,20 @@
1
+ import type { TemplateResult, Api } from "@inglorious/web"
2
+
3
+ export interface FlexEntity {
4
+ id?: string
5
+ type?: string
6
+ direction?: "row" | "column" | "row-reverse" | "column-reverse"
7
+ wrap?: "nowrap" | "wrap" | "wrap-reverse"
8
+ justify?: "start" | "center" | "end" | "between" | "around" | "evenly"
9
+ align?: "stretch" | "start" | "center" | "end" | "baseline"
10
+ gap?: "none" | "sm" | "md" | "lg" | "xl"
11
+ inline?: boolean
12
+ fullWidth?: boolean
13
+ children?: Array<TemplateResult | string | number>
14
+ }
15
+
16
+ export interface FlexType {
17
+ render(entity: FlexEntity, api: Api): TemplateResult
18
+ }
19
+
20
+ export declare const flex: FlexType
@@ -0,0 +1,19 @@
1
+ import type { TemplateResult, Api } from "@inglorious/web"
2
+
3
+ export interface GridEntity {
4
+ id?: string
5
+ type?: string
6
+ columns?: number
7
+ minColumnWidth?: string
8
+ gap?: "none" | "sm" | "md" | "lg" | "xl"
9
+ align?: "stretch" | "start" | "center" | "end"
10
+ justify?: "stretch" | "start" | "center" | "end"
11
+ fullWidth?: boolean
12
+ children?: Array<TemplateResult | string | number>
13
+ }
14
+
15
+ export interface GridType {
16
+ render(entity: GridEntity, api: Api): TemplateResult
17
+ }
18
+
19
+ export declare const grid: GridType
@@ -0,0 +1,21 @@
1
+ import type { TemplateResult, Api } from "@inglorious/web"
2
+
3
+ export interface CardEntity {
4
+ id?: string
5
+ type?: string
6
+ title?: string
7
+ subtitle?: string
8
+ hoverable?: boolean
9
+ clickable?: boolean
10
+ fullWidth?: boolean
11
+ }
12
+
13
+ export interface CardType {
14
+ render(entity: CardEntity, api: Api): TemplateResult
15
+ renderHeader(entity: CardEntity, api: Api): TemplateResult | null
16
+ renderBody(entity: CardEntity, api: Api): TemplateResult
17
+ renderFooter(entity: CardEntity, api: Api): TemplateResult | null
18
+ click(entity: CardEntity, payload: unknown, api: Api): void
19
+ }
20
+
21
+ export declare const card: CardType