@krumio/trailhand-ui 1.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/README.md ADDED
@@ -0,0 +1,104 @@
1
+ # Trailhand UI
2
+
3
+ A component library built with Lit Element web components and Storybook.
4
+
5
+ ## Recommended IDE Setup
6
+
7
+ VSCode with ES6 and Lit plugin support.
8
+
9
+ ## Project Setup
10
+
11
+ ```bash
12
+ npm install
13
+ ```
14
+
15
+ ### Compile and Hot-Reload for Development
16
+
17
+ ```bash
18
+ npm start
19
+ ```
20
+
21
+ ### Storybook Development
22
+
23
+ ```bash
24
+ npm run storybook
25
+ ```
26
+
27
+ ### Build for Production
28
+
29
+ ```bash
30
+ npm run build
31
+ ```
32
+
33
+ ### Build Storybook Static Site
34
+
35
+ ```bash
36
+ npm run build-storybook
37
+ ```
38
+
39
+ ## File Structure
40
+
41
+ ```
42
+ trailhand-ui/
43
+ ├── Components/ # Web components
44
+ ├── stories/ # Storybook stories
45
+ ├── .storybook/ # Storybook configuration
46
+ │ ├── main.js
47
+ │ └── preview.js
48
+ ├── index.html # Demo page
49
+ └── package.json
50
+ ```
51
+
52
+ ## Web Components
53
+
54
+ This library uses **Lit Element** for building fast, lightweight web components. Web components are framework-agnostic and work with any JavaScript framework or vanilla JS.
55
+
56
+ ### Benefits
57
+ - Framework agnostic
58
+ - Encapsulated styles and functionality
59
+ - Reusable across projects
60
+ - Based on web standards
61
+
62
+ Learn more at [lit.dev](https://lit.dev)
63
+
64
+ ## Storybook
65
+
66
+ Storybook provides an isolated environment for component development and documentation.
67
+
68
+ ### Setup
69
+
70
+ Storybook was initialized using:
71
+
72
+ ```bash
73
+ npm create storybook@latest
74
+ ```
75
+
76
+ **Configuration:**
77
+ - Framework: `@storybook/web-components-vite`
78
+ - Addons: `addon-essentials`, `addon-a11y`
79
+ - ES Modules: `"type": "module"` in package.json
80
+ - Version: 8.6.14 (for Node.js v20.18.0 compatibility)
81
+
82
+ ### Writing Stories
83
+
84
+ Every component should have stories that demonstrate its various states and configurations.
85
+
86
+ ```javascript
87
+ export default {
88
+ title: 'Components/ComponentName',
89
+ tags: ['autodocs'],
90
+ };
91
+
92
+ export const Default = {
93
+ args: {
94
+ // component props
95
+ },
96
+ };
97
+ ```
98
+
99
+ ## Tech Stack
100
+
101
+ - **Lit Element** 3.3.1 - Web component library
102
+ - **Vite** 6.4.1 - Build tool
103
+ - **Storybook** 8.6.14 - Component documentation
104
+ - **Node.js** v20.18.0+
@@ -0,0 +1,15 @@
1
+ import { TemplateResult } from 'lit';
2
+ import './button.css';
3
+ /**
4
+ * Props for the Button component
5
+ */
6
+ export interface ButtonProps {
7
+ primary?: boolean;
8
+ backgroundColor?: string | null;
9
+ size?: 'small' | 'medium' | 'large';
10
+ label: string;
11
+ onClick?: (e: Event) => void;
12
+ }
13
+ /** Primary UI component for user interaction */
14
+ export declare const Button: ({ primary, backgroundColor, size, label, onClick }: ButtonProps) => TemplateResult;
15
+ //# sourceMappingURL=Button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../Components/Button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,cAAc,EAAE,MAAM,KAAK,CAAC;AAG3C,OAAO,cAAc,CAAC;AAEtB;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;CAC9B;AAED,gDAAgD;AAChD,eAAO,MAAM,MAAM,GAAI,oDAMpB,WAAW,KAAG,cAahB,CAAC"}
package/dist/Button.js ADDED
@@ -0,0 +1,18 @@
1
+ import { html } from 'lit';
2
+ import { styleMap } from 'lit/directives/style-map.js';
3
+ import './button.css';
4
+ /** Primary UI component for user interaction */
5
+ export const Button = ({ primary, backgroundColor = null, size, label, onClick }) => {
6
+ const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
7
+ return html `
8
+ <button
9
+ type="button"
10
+ class=${['storybook-button', `storybook-button--${size || 'medium'}`, mode].join(' ')}
11
+ style=${styleMap({ backgroundColor })}
12
+ @click=${onClick}
13
+ >
14
+ ${label}
15
+ </button>
16
+ `;
17
+ };
18
+ //# sourceMappingURL=Button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../Components/Button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,cAAc,CAAC;AAatB,gDAAgD;AAChD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EACrB,OAAO,EACP,eAAe,GAAG,IAAI,EACtB,IAAI,EACJ,KAAK,EACL,OAAO,EACK,EAAkB,EAAE;IAChC,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,6BAA6B,CAAC;IAEnF,OAAO,IAAI,CAAA;;;cAGC,CAAC,kBAAkB,EAAE,qBAAqB,IAAI,IAAI,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;cAC7E,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;eAC5B,OAAO;;QAEd,KAAK;;GAEV,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { TemplateResult } from 'lit';
2
+ import './header.css';
3
+ /**
4
+ * Props for the Header component
5
+ */
6
+ export interface HeaderProps {
7
+ user?: {
8
+ name?: string;
9
+ } | null;
10
+ onLogin?: (e: Event) => void;
11
+ onLogout?: (e: Event) => void;
12
+ onCreateAccount?: (e: Event) => void;
13
+ }
14
+ export declare const Header: ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => TemplateResult;
15
+ //# sourceMappingURL=Header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../Components/Header.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,cAAc,EAAE,MAAM,KAAK,CAAC;AAG3C,OAAO,cAAc,CAAC;AAEtB;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IAC7B,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IAC9B,eAAe,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,MAAM,GAAI,8CAKpB,WAAW,KAAG,cAuChB,CAAC"}
package/dist/Header.js ADDED
@@ -0,0 +1,44 @@
1
+ import { html } from 'lit';
2
+ import { Button } from './Button';
3
+ import './header.css';
4
+ export const Header = ({ user, onLogin, onLogout, onCreateAccount }) => html `
5
+ <header>
6
+ <div class="storybook-header">
7
+ <div>
8
+ <svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
9
+ <g fill="none" fillRule="evenodd">
10
+ <path
11
+ d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
12
+ fill="#FFF"
13
+ />
14
+ <path
15
+ d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
16
+ fill="#555AB9"
17
+ />
18
+ <path
19
+ d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z"
20
+ fill="#91BAF8"
21
+ />
22
+ </g>
23
+ </svg>
24
+ <h1>Acme</h1>
25
+ </div>
26
+ <div>
27
+ ${user
28
+ ? Button({ size: 'small', onClick: onLogout, label: 'Log out' })
29
+ : html `${Button({
30
+ size: 'small',
31
+ onClick: onLogin,
32
+ label: 'Log in',
33
+ })}
34
+ ${Button({
35
+ primary: true,
36
+ size: 'small',
37
+ onClick: onCreateAccount,
38
+ label: 'Sign up',
39
+ })}`}
40
+ </div>
41
+ </div>
42
+ </header>
43
+ `;
44
+ //# sourceMappingURL=Header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Header.js","sourceRoot":"","sources":["../Components/Header.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,cAAc,CAAC;AAYtB,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EACrB,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,eAAe,EACH,EAAkB,EAAE,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;UAuB7B,IAAI;IACJ,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAChE,CAAC,CAAC,IAAI,CAAA,GAAG,MAAM,CAAC;QACZ,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,QAAQ;KAChB,CAAC;cACA,MAAM,CAAC;QACP,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,eAAe;QACxB,KAAK,EAAE,SAAS;KACjB,CAAC,EAAE;;;;CAIf,CAAC"}
package/dist/Page.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { HeaderProps } from './Header';
3
+ import './page.css';
4
+ /**
5
+ * Props for the Page component (extends HeaderProps)
6
+ */
7
+ export type PageProps = HeaderProps;
8
+ export declare const Page: ({ user, onLogin, onLogout, onCreateAccount }: PageProps) => TemplateResult;
9
+ //# sourceMappingURL=Page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../Components/Page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,cAAc,EAAE,MAAM,KAAK,CAAC;AAE3C,OAAO,EAAU,WAAW,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,WAAW,CAAC;AAEpC,eAAO,MAAM,IAAI,GAAI,8CAKlB,SAAS,KAAG,cAwDd,CAAC"}
package/dist/Page.js ADDED
@@ -0,0 +1,61 @@
1
+ import { html } from 'lit';
2
+ import { Header } from './Header';
3
+ import './page.css';
4
+ export const Page = ({ user, onLogin, onLogout, onCreateAccount }) => html `
5
+ <article>
6
+ ${Header({
7
+ user,
8
+ onLogin,
9
+ onLogout,
10
+ onCreateAccount,
11
+ })}
12
+
13
+ <section class="storybook-page">
14
+ <h2>Pages in Storybook</h2>
15
+ <p>
16
+ We recommend building UIs with a
17
+ <a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
18
+ <strong>component-driven</strong> </a
19
+ >process starting with atomic components and ending with pages.
20
+ </p>
21
+ <p>
22
+ Render pages with mock data. This makes it easy to build and review page states without
23
+ needing to navigate to them in your app. Here are some handy patterns for managing page data
24
+ in Storybook:
25
+ </p>
26
+ <ul>
27
+ <li>
28
+ Use a higher-level connected component. Storybook helps you compose such data from the
29
+ "args" of child component stories
30
+ </li>
31
+ <li>
32
+ Assemble data in the page component from your services. You can mock these services out
33
+ using Storybook.
34
+ </li>
35
+ </ul>
36
+ <p>
37
+ Get a guided tutorial on component-driven development at
38
+ <a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer">
39
+ Storybook tutorials
40
+ </a>
41
+ . Read more in the
42
+ <a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer"> docs </a>
43
+ .
44
+ </p>
45
+ <div class="tip-wrapper">
46
+ <span class="tip">Tip</span> Adjust the width of the canvas with the
47
+ <svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
48
+ <g fill="none" fillRule="evenodd">
49
+ <path
50
+ d="M1.5 5.2h4.8c.3 0 .5.2.5.4v5.1c-.1.2-.3.3-.4.3H1.4a.5.5 0 01-.5-.4V5.7c0-.3.2-.5.5-.5zm0-2.1h6.9c.3 0 .5.2.5.4v7a.5.5 0 01-1 0V4H1.5a.5.5 0 010-1zm0-2.1h9c.3 0 .5.2.5.4v9.1a.5.5 0 01-1 0V2H1.5a.5.5 0 010-1zm4.3 5.2H2V10h3.8V6.2z"
51
+ id="a"
52
+ fill="#999"
53
+ />
54
+ </g>
55
+ </svg>
56
+ Viewports addon in the toolbar
57
+ </div>
58
+ </section>
59
+ </article>
60
+ `;
61
+ //# sourceMappingURL=Page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Page.js","sourceRoot":"","sources":["../Components/Page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAe,MAAM,UAAU,CAAC;AAC/C,OAAO,YAAY,CAAC;AAOpB,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,EACnB,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,eAAe,EACL,EAAkB,EAAE,CAAC,IAAI,CAAA;;MAE/B,MAAM,CAAC;IACP,IAAI;IACJ,OAAO;IACP,QAAQ;IACR,eAAe;CAChB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDL,CAAC"}
@@ -0,0 +1,79 @@
1
+ import { LitElement, TemplateResult } from 'lit';
2
+ /**
3
+ * Type definition for resource data
4
+ */
5
+ interface ResourceData {
6
+ [key: string]: any;
7
+ availableActions?: ActionMenuItem[];
8
+ }
9
+ /**
10
+ * Type definition for action menu items
11
+ */
12
+ export interface ActionMenuItem {
13
+ label?: string;
14
+ action?: (resource: ResourceData) => void;
15
+ enabled?: boolean | ((resource: ResourceData) => boolean);
16
+ visible?: boolean | ((resource: ResourceData) => boolean);
17
+ danger?: boolean;
18
+ divider?: boolean;
19
+ }
20
+ /**
21
+ * A dropdown action menu component for displaying contextual actions.
22
+ * Typically used in table rows or cards to provide action options.
23
+ */
24
+ export declare class ActionMenu extends LitElement {
25
+ actions: ActionMenuItem[];
26
+ resource: ResourceData;
27
+ disabled: boolean;
28
+ private _isOpen;
29
+ private _boundHandleClickOutside;
30
+ static styles: import("lit").CSSResult;
31
+ constructor();
32
+ connectedCallback(): void;
33
+ disconnectedCallback(): void;
34
+ /**
35
+ * Handle clicks outside the menu to close it
36
+ * @param e - The click event
37
+ * @private
38
+ */
39
+ private _handleClickOutside;
40
+ /**
41
+ * Toggle the dropdown menu open/closed
42
+ * @param e - The click event
43
+ * @private
44
+ */
45
+ private _toggleMenu;
46
+ /**
47
+ * Handle action click
48
+ * @param e - The click event
49
+ * @param action - The action object
50
+ * @private
51
+ */
52
+ private _handleActionClick;
53
+ /**
54
+ * Check if an action is enabled
55
+ * @param action - The action object
56
+ * @returns boolean
57
+ * @private
58
+ */
59
+ private _isActionEnabled;
60
+ /**
61
+ * Render the three-dots icon
62
+ * @returns TemplateResult
63
+ * @private
64
+ */
65
+ private _renderIcon;
66
+ /**
67
+ * Get actions to display
68
+ * @returns Array of actions
69
+ * @private
70
+ */
71
+ private _getActions;
72
+ /**
73
+ * Render the component
74
+ * @returns TemplateResult
75
+ */
76
+ render(): TemplateResult;
77
+ }
78
+ export {};
79
+ //# sourceMappingURL=action-menu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-menu.d.ts","sourceRoot":"","sources":["../Components/action-menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,cAAc,EAAE,MAAM,KAAK,CA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