@api-client/ui 0.5.5 → 0.5.7

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 (114) hide show
  1. package/.cursor/rules/html-and-css-best-practices.mdc +63 -0
  2. package/.cursor/rules/lit-best-practices.mdc +78 -0
  3. package/.github/instructions/html-and-css-best-practices.instructions.md +70 -0
  4. package/.github/instructions/lit-best-practices.instructions.md +86 -0
  5. package/build/src/elements/currency/currency-picker.d.ts +10 -0
  6. package/build/src/elements/currency/currency-picker.d.ts.map +1 -0
  7. package/build/src/elements/currency/currency-picker.js +27 -0
  8. package/build/src/elements/currency/currency-picker.js.map +1 -0
  9. package/build/src/elements/currency/internals/Picker.d.ts +311 -0
  10. package/build/src/elements/currency/internals/Picker.d.ts.map +1 -0
  11. package/build/src/elements/currency/internals/Picker.js +857 -0
  12. package/build/src/elements/currency/internals/Picker.js.map +1 -0
  13. package/build/src/elements/currency/internals/Picker.styles.d.ts +3 -0
  14. package/build/src/elements/currency/internals/Picker.styles.d.ts.map +1 -0
  15. package/build/src/elements/currency/internals/Picker.styles.js +58 -0
  16. package/build/src/elements/currency/internals/Picker.styles.js.map +1 -0
  17. package/build/src/elements/highlight/MarkdownStyles.d.ts.map +1 -1
  18. package/build/src/elements/highlight/MarkdownStyles.js +0 -13
  19. package/build/src/elements/highlight/MarkdownStyles.js.map +1 -1
  20. package/build/src/elements/http/BodyEditor.d.ts +0 -13
  21. package/build/src/elements/http/BodyEditor.d.ts.map +1 -1
  22. package/build/src/elements/http/BodyEditor.js +0 -13
  23. package/build/src/elements/http/BodyEditor.js.map +1 -1
  24. package/build/src/elements/http/BodyTextEditor.d.ts +0 -13
  25. package/build/src/elements/http/BodyTextEditor.d.ts.map +1 -1
  26. package/build/src/elements/http/BodyTextEditor.js +0 -13
  27. package/build/src/elements/http/BodyTextEditor.js.map +1 -1
  28. package/build/src/elements/http/BodyUrlEncodedEditor.d.ts +0 -13
  29. package/build/src/elements/http/BodyUrlEncodedEditor.d.ts.map +1 -1
  30. package/build/src/elements/http/BodyUrlEncodedEditor.js +0 -13
  31. package/build/src/elements/http/BodyUrlEncodedEditor.js.map +1 -1
  32. package/build/src/elements/http/UrlInput.d.ts +0 -13
  33. package/build/src/elements/http/UrlInput.d.ts.map +1 -1
  34. package/build/src/elements/http/UrlInput.js +0 -13
  35. package/build/src/elements/http/UrlInput.js.map +1 -1
  36. package/build/src/index.d.ts +2 -0
  37. package/build/src/index.d.ts.map +1 -1
  38. package/build/src/index.js +2 -0
  39. package/build/src/index.js.map +1 -1
  40. package/build/src/md/button/internals/base.d.ts +1 -0
  41. package/build/src/md/button/internals/base.d.ts.map +1 -1
  42. package/build/src/md/button/internals/base.js +7 -0
  43. package/build/src/md/button/internals/base.js.map +1 -1
  44. package/build/src/md/button/internals/button.styles.js +1 -1
  45. package/build/src/md/button/internals/button.styles.js.map +1 -1
  46. package/build/src/md/date/internals/DateTime.d.ts +0 -13
  47. package/build/src/md/date/internals/DateTime.d.ts.map +1 -1
  48. package/build/src/md/date/internals/DateTime.js +0 -13
  49. package/build/src/md/date/internals/DateTime.js.map +1 -1
  50. package/build/src/md/date-picker/index.d.ts +13 -0
  51. package/build/src/md/date-picker/index.d.ts.map +1 -0
  52. package/build/src/md/date-picker/index.js +13 -0
  53. package/build/src/md/date-picker/index.js.map +1 -0
  54. package/build/src/md/date-picker/internals/DatePicker.styles.d.ts +4 -0
  55. package/build/src/md/date-picker/internals/DatePicker.styles.d.ts.map +1 -0
  56. package/build/src/md/date-picker/internals/DatePicker.styles.js +409 -0
  57. package/build/src/md/date-picker/internals/DatePicker.styles.js.map +1 -0
  58. package/build/src/md/date-picker/internals/DatePickerCalendar.d.ts +272 -0
  59. package/build/src/md/date-picker/internals/DatePickerCalendar.d.ts.map +1 -0
  60. package/build/src/md/date-picker/internals/DatePickerCalendar.js +1062 -0
  61. package/build/src/md/date-picker/internals/DatePickerCalendar.js.map +1 -0
  62. package/build/src/md/date-picker/internals/DatePickerUtils.d.ts +93 -0
  63. package/build/src/md/date-picker/internals/DatePickerUtils.d.ts.map +1 -0
  64. package/build/src/md/date-picker/internals/DatePickerUtils.js +221 -0
  65. package/build/src/md/date-picker/internals/DatePickerUtils.js.map +1 -0
  66. package/build/src/md/date-picker/ui-date-picker-input.d.ts +160 -0
  67. package/build/src/md/date-picker/ui-date-picker-input.d.ts.map +1 -0
  68. package/build/src/md/date-picker/ui-date-picker-input.js +464 -0
  69. package/build/src/md/date-picker/ui-date-picker-input.js.map +1 -0
  70. package/build/src/md/date-picker/ui-date-picker-modal-input.d.ts +178 -0
  71. package/build/src/md/date-picker/ui-date-picker-modal-input.d.ts.map +1 -0
  72. package/build/src/md/date-picker/ui-date-picker-modal-input.js +538 -0
  73. package/build/src/md/date-picker/ui-date-picker-modal-input.js.map +1 -0
  74. package/build/src/md/date-picker/ui-date-picker-modal.d.ts +156 -0
  75. package/build/src/md/date-picker/ui-date-picker-modal.d.ts.map +1 -0
  76. package/build/src/md/date-picker/ui-date-picker-modal.js +423 -0
  77. package/build/src/md/date-picker/ui-date-picker-modal.js.map +1 -0
  78. package/build/src/md/dialog/internals/Dialog.styles.d.ts.map +1 -1
  79. package/build/src/md/dialog/internals/Dialog.styles.js +1 -0
  80. package/build/src/md/dialog/internals/Dialog.styles.js.map +1 -1
  81. package/demo/elements/currency/index.html +91 -0
  82. package/demo/elements/currency/index.ts +272 -0
  83. package/demo/elements/har/har2.json +1 -1
  84. package/demo/elements/index.html +3 -0
  85. package/demo/md/date-picker/date-picker.ts +336 -0
  86. package/demo/md/date-picker/index.html +171 -0
  87. package/demo/md/index.html +2 -0
  88. package/package.json +1 -1
  89. package/src/elements/currency/currency-picker.ts +14 -0
  90. package/src/elements/currency/internals/Picker.styles.ts +58 -0
  91. package/src/elements/currency/internals/Picker.ts +846 -0
  92. package/src/elements/highlight/MarkdownStyles.ts +0 -13
  93. package/src/elements/http/BodyEditor.ts +0 -13
  94. package/src/elements/http/BodyTextEditor.ts +0 -13
  95. package/src/elements/http/BodyUrlEncodedEditor.ts +0 -13
  96. package/src/elements/http/UrlInput.ts +0 -13
  97. package/src/index.ts +17 -0
  98. package/src/md/button/internals/base.ts +7 -0
  99. package/src/md/button/internals/button.styles.ts +1 -1
  100. package/src/md/date/internals/DateTime.ts +0 -14
  101. package/src/md/date-picker/README.md +184 -0
  102. package/src/md/date-picker/index.ts +17 -0
  103. package/src/md/date-picker/internals/DatePicker.styles.ts +411 -0
  104. package/src/md/date-picker/internals/DatePickerCalendar.ts +1031 -0
  105. package/src/md/date-picker/internals/DatePickerUtils.ts +288 -0
  106. package/src/md/date-picker/ui-date-picker-input.ts +333 -0
  107. package/src/md/date-picker/ui-date-picker-modal-input.ts +440 -0
  108. package/src/md/date-picker/ui-date-picker-modal.ts +346 -0
  109. package/src/md/dialog/internals/Dialog.styles.ts +1 -0
  110. package/test/README.md +3 -2
  111. package/test/elements/currency/CurrencyPicker.accessibility.test.ts +328 -0
  112. package/test/elements/currency/CurrencyPicker.core.test.ts +318 -0
  113. package/test/elements/currency/CurrencyPicker.integration.test.ts +482 -0
  114. package/test/elements/currency/CurrencyPicker.test.ts +486 -0
@@ -0,0 +1,63 @@
1
+ ---
2
+ description:
3
+ globs: *.ts,*.css,*html
4
+ alwaysApply: false
5
+ ---
6
+
7
+ You are an expert developer in HTML and CSS, focusing on best practices, accessibility, and responsive design.
8
+
9
+ Key Principles
10
+ - Write semantic HTML to improve accessibility and SEO.
11
+ - Use CSS for styling, avoiding inline styles.
12
+ - Ensure responsive design using media queries and flexible layouts.
13
+ - Prioritize accessibility by using ARIA roles and attributes.
14
+
15
+ HTML
16
+ - Use semantic elements (e.g., <header>, <main>, <footer>, <article>, <section>).
17
+ - Use <button> for clickable elements, not <div> or <span>.
18
+ - Use <a> for links, ensuring href attribute is present.
19
+ - Use <img> with alt attribute for images.
20
+ - Use <form> for forms, with appropriate input types and labels.
21
+ - Avoid using deprecated elements (e.g., <font>, <center>).
22
+
23
+ CSS
24
+ - Use external stylesheets for CSS.
25
+ - Use class selectors over ID selectors for styling.
26
+ - Use Flexbox and Grid for layout.
27
+ - Use rem and em units for scalable and accessible typography.
28
+ - Use CSS variables for consistent theming.
29
+ - Use BEM (Block Element Modifier) methodology for naming classes.
30
+ - Avoid !important; use specificity to manage styles.
31
+
32
+ Responsive Design
33
+ - Use media queries to create responsive layouts.
34
+ - Use mobile-first approach for media queries.
35
+ - Ensure touch targets are large enough for touch devices.
36
+ - Use responsive images with srcset and sizes attributes.
37
+ - Use viewport meta tag for responsive scaling.
38
+
39
+ Accessibility
40
+ - Use ARIA roles and attributes to enhance accessibility.
41
+ - Ensure sufficient color contrast for text.
42
+ - Provide keyboard navigation for interactive elements.
43
+ - Use focus styles to indicate focus state.
44
+ - Use landmarks (e.g., <nav>, <main>, <aside>) for screen readers.
45
+
46
+ Performance
47
+ - Minimize CSS and HTML file sizes.
48
+ - Use CSS minification and compression.
49
+ - Avoid excessive use of animations and transitions.
50
+ - Use lazy loading for images and other media.
51
+
52
+ Testing
53
+ - Test HTML and CSS in multiple browsers and devices.
54
+ - Use tools like Lighthouse for performance and accessibility audits.
55
+ - Validate HTML and CSS using W3C validators.
56
+
57
+ Documentation
58
+ - Comment complex CSS rules and HTML structures.
59
+ - Use consistent naming conventions for classes and IDs.
60
+ - Document responsive breakpoints and design decisions.
61
+
62
+ Refer to MDN Web Docs for HTML and CSS best practices and to the W3C guidelines for accessibility standards.
63
+
@@ -0,0 +1,78 @@
1
+ You are an expert developer in web components using the Lit library and Material Design version 3, focusing on best practices, accessibility, and responsive design.
2
+
3
+ Key Principles
4
+
5
+ - Comply with web elements authoring standards when designing a web component.
6
+ - Use accessibility best practices to produce semantically relevant web components.
7
+ - Prioritize web standards over custom implementation.
8
+ - Prioritize APIs that are passing the Web Platform Baseline
9
+ - Minimize external dependencies, but also balance between custom code and widely known and trusted dependencies.
10
+ - Everything must be ES compliant. Use the appropriate standards for module imports.
11
+
12
+ Lit Web Components
13
+
14
+ - Document public properties and public function for authors to understand what these properties and functions do.
15
+ - Ensure the appropriate aria roles are applied to each element.
16
+ - Document all events and their structure (for custom events).
17
+ - Prioritize well-known events (like change, select) over custom events.
18
+ - Provide examples of usage when producing component documentation.
19
+ - Prioritize native elements over custom elements whenever possible.
20
+ - Prioritize composition over attribute passed configuration (a dropdown should have a semantic HTML structure and not auto-generated structure from a complex configuration object).
21
+ - Think of other use-cases and how the custom element can scale for future use cases.
22
+ - Reuse existing components whenever possible.
23
+ - Prefer to put lifecycle methods after the constructor and before the render and other methods.
24
+ - Put render methods at the end of the class.
25
+ - Use `@property` decorator for public properties and `@state` decorator for private properties.
26
+ - Use `@query` decorator for querying elements in the shadow DOM.
27
+ - Use `@queryAssignedElements` decorator for querying slotted elements.
28
+ - Boolean properties should be initialized to `false` in the constructor.
29
+ - Use `@eventOptions` decorator to specify event options like `capture`, `passive`, and `once`.
30
+ - Use `@queryAsync` decorator for querying elements that may not be immediately available in the DOM.
31
+ - Use `@state` decorator for properties that are internal to the component and should not be exposed to the outside world.
32
+ - Avoid passing complex objects as properties. Instead, use simple types like `string`, `number`, or `boolean` and handle complex logic internally.
33
+ - Use lifecycle methods like `connectedCallback`, `disconnectedCallback`, and `update` to manage component state and behavior.
34
+ - Use `willUpdate` method to perform actions before the component updates, such as validating properties or preparing data.
35
+ - Place the component definition under the `internals/` directory of a component folder. The components registration should be done in the component file in the main component directory.
36
+ - Place the base material components under the `src/md/` directory.
37
+ - Place composite components under the `src/elements/` directory.
38
+
39
+ CSS and Styling
40
+
41
+ - Prioritize native CSS over JavaScript implementation. Use Web Platform Baseline even if the editor says it's not supported.
42
+ - Use anchoring and popover API whenever possible and applicable over JavaScript positioning.
43
+ - Place lit component styles in a separate file with the `.styles.ts` extension.
44
+ - Add styles to the component registration class, not the base class.
45
+ - Declare the `part` attributes to expose custom styling.
46
+ - When working on base components, use CSS variables to allow customization of the component styles.
47
+ - Define component states via the `internals.states.add("--state-name")` method. These states can be used as `component-name:state(state-name) {}` in the CSS.
48
+
49
+ Error handling
50
+
51
+ - Components either communicate errors through rendering them internally or dispatch an error event with the error details to the parent component or application.
52
+ - Prefer error states defined on the element internals over custom error styling.
53
+
54
+ Naming Convention
55
+
56
+ - Follow web authoring standards as closely as possible.
57
+ - Minimize the the of "-" in attribute and event names
58
+
59
+ Testing
60
+
61
+ - Use @open-wc/testing library.
62
+ - Always add accessibility tests.
63
+ - Create fixtures for different states of a component.
64
+ - To run tests for a specific file, use the `--files` option in the test command. For example:
65
+ ```bash
66
+ npm test -- --files=".tmp/test/**/[test file name].test.js"
67
+ ```
68
+
69
+ Component Demoing
70
+
71
+ - Always produce a demo page under the demo/ directory.
72
+ - Use the `DemoPage` class to bootstrap the demo page.
73
+ - Use material styles with the demo page. Minimize custom styling.
74
+ - Try to render each state separately and minimize the use of complex configurations.
75
+ - Start with simple states and progressively enhance the demo with more complex configurations.
76
+ - If a component produces output, ensure that the demo page shows the output in a readable format. Use one output per component.
77
+ - Document the states in a way that is obvious to the user. Use headings and paragraphs to explain the states.
78
+ - Due to the nature how the demo pages are processed, ensure that typescript files that belong to the demo page are imported from the `/.tmp/demo/` directory. This is done automatically by the build process. Imports inside the typescript file should reference files from the `src/` folder directly.
@@ -0,0 +1,70 @@
1
+ ---
2
+ applyTo: "*.ts,*.css,*html"
3
+ ---
4
+
5
+ # HTML and CSS Best Practices
6
+
7
+ You are an expert developer in HTML and CSS, focusing on best practices, accessibility, and responsive design.
8
+
9
+ ## Key Principles
10
+
11
+ - Write semantic HTML to improve accessibility and SEO.
12
+ - Use CSS for styling, avoiding inline styles.
13
+ - Ensure responsive design using media queries and flexible layouts.
14
+ - Prioritize accessibility by using ARIA roles and attributes.
15
+
16
+ ## HTML
17
+
18
+ - Use semantic elements (e.g., <header>, <main>, <footer>, <article>, <section>).
19
+ - Use <button> for clickable elements, not <div> or <span>.
20
+ - Use <a> for links, ensuring href attribute is present.
21
+ - Use <img> with alt attribute for images.
22
+ - Use <form> for forms, with appropriate input types and labels.
23
+ - Avoid using deprecated elements (e.g., <font>, <center>).
24
+
25
+ ## CSS
26
+
27
+ - Use external stylesheets for CSS.
28
+ - Use class selectors over ID selectors for styling.
29
+ - Use Flexbox and Grid for layout.
30
+ - Use rem and em units for scalable and accessible typography.
31
+ - Use CSS variables for consistent theming.
32
+ - Use BEM (Block Element Modifier) methodology for naming classes.
33
+ - Avoid !important; use specificity to manage styles.
34
+
35
+ ## Responsive Design
36
+
37
+ - Use media queries to create responsive layouts.
38
+ - Use mobile-first approach for media queries.
39
+ - Ensure touch targets are large enough for touch devices.
40
+ - Use responsive images with srcset and sizes attributes.
41
+ - Use viewport meta tag for responsive scaling.
42
+
43
+ ## Accessibility
44
+
45
+ - Use ARIA roles and attributes to enhance accessibility.
46
+ - Ensure sufficient color contrast for text.
47
+ - Provide keyboard navigation for interactive elements.
48
+ - Use focus styles to indicate focus state.
49
+ - Use landmarks (e.g., <nav>, <main>, <aside>) for screen readers.
50
+
51
+ ## Performance
52
+
53
+ - Minimize CSS and HTML file sizes.
54
+ - Use CSS minification and compression.
55
+ - Avoid excessive use of animations and transitions.
56
+ - Use lazy loading for images and other media.
57
+
58
+ ## Testing
59
+
60
+ - Test HTML and CSS in multiple browsers and devices.
61
+ - Use tools like Lighthouse for performance and accessibility audits.
62
+ - Validate HTML and CSS using W3C validators.
63
+
64
+ ## Documentation
65
+
66
+ - Comment complex CSS rules and HTML structures.
67
+ - Use consistent naming conventions for classes and IDs.
68
+ - Document responsive breakpoints and design decisions.
69
+
70
+ Refer to MDN Web Docs for HTML and CSS best practices and to the W3C guidelines for accessibility standards.
@@ -0,0 +1,86 @@
1
+ ---
2
+ applyTo: "src/{elements,md,styles}/**,demo/**"
3
+ ---
4
+
5
+ # Lit Element Best Practices
6
+
7
+ You are an expert developer in web components using the Lit library and Material Design version 3, focusing on best practices, accessibility, and responsive design.
8
+
9
+ ## Key Principles
10
+
11
+ - Comply with web elements authoring standards when designing a web component.
12
+ - Use accessibility best practices to produce semantically relevant web components.
13
+ - Prioritize web standards over custom implementation.
14
+ - Prioritize APIs that are passing the Web Platform Baseline
15
+ - Minimize external dependencies, but also balance between custom code and widely known and trusted dependencies.
16
+ - Everything must be ES compliant. Use the appropriate standards for module imports.
17
+
18
+ ## Lit Web Components
19
+
20
+ - Document public properties and public function for authors to understand what these properties and functions do.
21
+ - Ensure the appropriate aria roles are applied to each element.
22
+ - Document all events and their structure (for custom events).
23
+ - Prioritize well-known events (like change, select) over custom events.
24
+ - Provide examples of usage when producing component documentation.
25
+ - Prioritize native elements over custom elements whenever possible.
26
+ - Prioritize composition over attribute passed configuration (a dropdown should have a semantic HTML structure and not auto-generated structure from a complex configuration object).
27
+ - Think of other use-cases and how the custom element can scale for future use cases.
28
+ - Reuse existing components whenever possible.
29
+ - Prefer to put lifecycle methods after the constructor and before the render and other methods.
30
+ - Put render methods at the end of the class.
31
+ - Use `@property` decorator for public properties and `@state` decorator for private properties.
32
+ - Use `@query` decorator for querying elements in the shadow DOM.
33
+ - Use `@queryAssignedElements` decorator for querying slotted elements.
34
+ - Boolean properties should be initialized to `false` in the constructor.
35
+ - Use `@eventOptions` decorator to specify event options like `capture`, `passive`, and `once`.
36
+ - Use `@queryAsync` decorator for querying elements that may not be immediately available in the DOM.
37
+ - Use `@state` decorator for properties that are internal to the component and should not be exposed to the outside world.
38
+ - Avoid passing complex objects as properties. Instead, use simple types like `string`, `number`, or `boolean` and handle complex logic internally.
39
+ - Use lifecycle methods like `connectedCallback`, `disconnectedCallback`, and `update` to manage component state and behavior.
40
+ - Use `willUpdate` method to perform actions before the component updates, such as validating properties or preparing data.
41
+ - Place the component definition under the `internals/` directory of a component folder. The components registration should be done in the component file in the main component directory.
42
+ - Place the base material components under the `src/md/` directory.
43
+ - Place composite components under the `src/elements/` directory.
44
+
45
+ ## CSS and Styling
46
+
47
+ - Prioritize native CSS over JavaScript implementation. Use Web Platform Baseline even if the editor says it's not supported.
48
+ - Use anchoring and popover API whenever possible and applicable over JavaScript positioning.
49
+ - Place lit component styles in a separate file with the `.styles.ts` extension.
50
+ - Add styles to the component registration class, not the base class.
51
+ - Declare the `part` attributes to expose custom styling.
52
+ - When working on base components, use CSS variables to allow customization of the component styles.
53
+ - Define component states via the `internals.states.add("--state-name")` method. These states can be used as `component-name:state(state-name) {}` in the CSS.
54
+
55
+ ## Error handling
56
+
57
+ - Components either communicate errors through rendering them internally or dispatch an error event with the error details to the parent component or application.
58
+ - Prefer error states defined on the element internals over custom error styling.
59
+
60
+ ## Naming Convention
61
+
62
+ - Follow web authoring standards as closely as possible.
63
+ - Minimize the the of "-" in attribute and event names
64
+ - Use camelCase for properties and methods.
65
+ - Do not prefix private or protected properties and methods with an underscore. Use the typescript `private` and `protected` keywords to indicate visibility.
66
+
67
+ ## Testing
68
+
69
+ - Use @open-wc/testing library.
70
+ - Always add accessibility tests.
71
+ - Create fixtures for different states of a component.
72
+ - To run tests for a specific file, use the `--files` option in the test command. For example:
73
+ ```bash
74
+ npm test -- --files=".tmp/test/**/[test file name].test.js"
75
+ ```
76
+
77
+ ## Component Demoing
78
+
79
+ - Always produce a demo page under the demo/ directory.
80
+ - Use the `DemoPage` class to bootstrap the demo page.
81
+ - Use material styles with the demo page. Minimize custom styling.
82
+ - Try to render each state separately and minimize the use of complex configurations.
83
+ - Start with simple states and progressively enhance the demo with more complex configurations.
84
+ - If a component produces output, ensure that the demo page shows the output in a readable format. Use one output per component.
85
+ - Document the states in a way that is obvious to the user. Use headings and paragraphs to explain the states.
86
+ - Due to the nature how the demo pages are processed, ensure that typescript files that belong to the demo page are imported from the `/.tmp/demo/` directory. This is done automatically by the build process. Imports inside the typescript file should reference files from the `src/` folder directly.
@@ -0,0 +1,10 @@
1
+ import Element from './internals/Picker.js';
2
+ export declare class CurrencyPickerElement extends Element {
3
+ static styles: import("lit").CSSResult[];
4
+ }
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ 'currency-picker': CurrencyPickerElement;
8
+ }
9
+ }
10
+ //# sourceMappingURL=currency-picker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currency-picker.d.ts","sourceRoot":"","sources":["../../../../src/elements/currency/currency-picker.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,uBAAuB,CAAA;AAG3C,qBACa,qBAAsB,SAAQ,OAAO;IAChD,OAAgB,MAAM,4BAAkB;CACzC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,qBAAqB,CAAA;KACzC;CACF"}
@@ -0,0 +1,27 @@
1
+ import { __esDecorate, __runInitializers } from "tslib";
2
+ import { customElement } from 'lit/decorators.js';
3
+ import Element from './internals/Picker.js';
4
+ import elementStyles from './internals/Picker.styles.js';
5
+ let CurrencyPickerElement = (() => {
6
+ let _classDecorators = [customElement('currency-picker')];
7
+ let _classDescriptor;
8
+ let _classExtraInitializers = [];
9
+ let _classThis;
10
+ let _classSuper = Element;
11
+ var CurrencyPickerElement = class extends _classSuper {
12
+ static { _classThis = this; }
13
+ static {
14
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
15
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
16
+ CurrencyPickerElement = _classThis = _classDescriptor.value;
17
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
18
+ }
19
+ static styles = [elementStyles];
20
+ static {
21
+ __runInitializers(_classThis, _classExtraInitializers);
22
+ }
23
+ };
24
+ return CurrencyPickerElement = _classThis;
25
+ })();
26
+ export { CurrencyPickerElement };
27
+ //# sourceMappingURL=currency-picker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currency-picker.js","sourceRoot":"","sources":["../../../../src/elements/currency/currency-picker.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,OAAO,MAAM,uBAAuB,CAAA;AAC3C,OAAO,aAAa,MAAM,8BAA8B,CAAA;IAG3C,qBAAqB;4BADjC,aAAa,CAAC,iBAAiB,CAAC;;;;sBACU,OAAO;qCAAf,SAAQ,WAAO;;;;YAAlD,6KAEC;;;;QADC,MAAM,CAAU,MAAM,GAAG,CAAC,aAAa,CAAC,CAAA;;YAD7B,uDAAqB;;;;;SAArB,qBAAqB","sourcesContent":["import { customElement } from 'lit/decorators.js'\nimport Element from './internals/Picker.js'\nimport elementStyles from './internals/Picker.styles.js'\n\n@customElement('currency-picker')\nexport class CurrencyPickerElement extends Element {\n static override styles = [elementStyles]\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'currency-picker': CurrencyPickerElement\n }\n}\n"]}
@@ -0,0 +1,311 @@
1
+ import { LitElement, type TemplateResult, type PropertyValues, nothing } from 'lit';
2
+ import '@material/web/select/outlined-select.js';
3
+ import '@material/web/select/select-option.js';
4
+ import '../../../md/chip/ui-chip-set.js';
5
+ import '../../../md/chip/ui-chip.js';
6
+ /**
7
+ * Represents a currency with all its display information.
8
+ */
9
+ export interface Currency {
10
+ /** ISO 4217 currency code (e.g., 'USD', 'EUR') */
11
+ code: string;
12
+ /** Full name of the currency (e.g., 'US Dollar', 'Euro') */
13
+ name: string;
14
+ /** Currency symbol (e.g., '$', '€') */
15
+ symbol: string;
16
+ /** Country or region name (e.g., 'United States', 'European Union') */
17
+ country: string;
18
+ /** Flag emoji representing the currency's origin */
19
+ flag: string;
20
+ }
21
+ /**
22
+ * Represents an error that can occur in the CurrencyPicker component.
23
+ */
24
+ export interface CurrencyPickerError {
25
+ /** Type of error: validation, selection constraint, or internal error */
26
+ type: 'validation' | 'selection' | 'internal';
27
+ /** Human-readable error message */
28
+ message: string;
29
+ /** Optional additional details about the error for debugging */
30
+ details?: Record<string, unknown>;
31
+ }
32
+ /**
33
+ * Event detail interface for currency picker error events.
34
+ */
35
+ export interface CurrencyPickerErrorEvent {
36
+ /** The error information */
37
+ error: CurrencyPickerError;
38
+ }
39
+ /**
40
+ * A web component for selecting currencies with chips display.
41
+ * Provides a searchable interface with country flags and currency information.
42
+ *
43
+ * This component uses ElementInternals for native form integration and
44
+ * follows web standards for error handling and validation.
45
+ *
46
+ * ## Features
47
+ * - Single or multi-select currency selection
48
+ * - Visual chips display for selected currencies
49
+ * - Native form integration with ElementInternals
50
+ * - Comprehensive validation and error handling
51
+ * - Accessibility support with ARIA attributes
52
+ * - Keyboard navigation support
53
+ * - Currency filtering based on allowed currencies
54
+ *
55
+ * ## Usage
56
+ * ```html
57
+ * <!-- Basic usage -->
58
+ * <currency-picker></currency-picker>
59
+ *
60
+ * <!-- Multi-select with allowed currencies -->
61
+ * <currency-picker multi .allowedCurrencies="${['USD', 'EUR', 'GBP']}"></currency-picker>
62
+ *
63
+ * <!-- Form integration -->
64
+ * <form>
65
+ * <currency-picker name="currencies" required></currency-picker>
66
+ * </form>
67
+ * ```
68
+ *
69
+ * @fires change - Dispatched when selected currencies change due to user interaction.
70
+ * Contains {currencies: Currency[], codes: string[]} in event.detail
71
+ * @fires error - Dispatched when validation or other errors occur.
72
+ * Contains {error: CurrencyPickerError} in event.detail
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * const picker = document.querySelector('currency-picker');
77
+ * picker.addEventListener('change', (e) => {
78
+ * console.log('Selected currencies:', e.detail.currencies);
79
+ * });
80
+ * picker.addEventListener('error', (e) => {
81
+ * console.error('Picker error:', e.detail.error.message);
82
+ * });
83
+ * ```
84
+ */
85
+ export default class CurrencyPicker extends LitElement {
86
+ /**
87
+ * Indicates that this custom element is form-associated and can participate in form submission.
88
+ * This enables the component to work with native HTML forms and use ElementInternals.
89
+ */
90
+ static formAssociated: boolean;
91
+ /**
92
+ * Private ElementInternals instance for form integration and validation.
93
+ * Provides access to form APIs like setFormValue, setValidity, etc.
94
+ */
95
+ private internals;
96
+ /**
97
+ * Shadow root configuration for the component.
98
+ * Uses 'open' mode for accessibility and delegates focus to enable proper focus management.
99
+ */
100
+ static shadowRootOptions: ShadowRootInit;
101
+ /**
102
+ * The currently selected currency codes.
103
+ * This is an array of ISO 4217 currency codes (e.g., 'USD', 'EUR').
104
+ */
105
+ accessor selected: string[];
106
+ /**
107
+ * The currencies that should be available for selection.
108
+ * If not specified, all supported currencies will be available.
109
+ * This is an array of ISO 4217 currency codes (e.g., 'USD', 'EUR').
110
+ */
111
+ accessor allowedCurrencies: string[];
112
+ /**
113
+ * The label for the currency selection dropdown.
114
+ * This is displayed as the label for the select input.
115
+ * @attribute
116
+ */
117
+ accessor label: string;
118
+ /**
119
+ * The name attribute for the currency selection dropdown.
120
+ * This is used when submitting forms that include this component.
121
+ * @attribute
122
+ */
123
+ accessor name: string | undefined;
124
+ /**
125
+ * Supporting text for the currency selection dropdown.
126
+ * This is displayed below the select input.
127
+ * @attribute
128
+ */
129
+ accessor supportingText: string | undefined;
130
+ /**
131
+ * Whether the currency selection is required.
132
+ * If true, the component will enforce at least one currency to be selected.
133
+ * @attribute
134
+ */
135
+ accessor required: boolean;
136
+ /**
137
+ * Whether the currency selection is disabled.
138
+ * If true, the component will not allow any changes to the selected currencies.
139
+ * @attribute
140
+ */
141
+ accessor disabled: boolean;
142
+ /**
143
+ * Whether multiple currencies can be selected.
144
+ * If true, the component allows selecting multiple currencies.
145
+ * If false, only one currency can be selected at a time.
146
+ * @attribute
147
+ */
148
+ accessor multi: boolean;
149
+ /**
150
+ * Whether to show errors inline within the component.
151
+ * If true, errors will be displayed below the component.
152
+ * If false, errors will only be dispatched as events.
153
+ * @attribute
154
+ */
155
+ accessor showErrors: boolean;
156
+ /**
157
+ * The currently selectable currencies (filtered based on selection and allowed currencies).
158
+ * This is automatically updated based on the selected currencies and allowedCurrencies property.
159
+ */
160
+ private accessor selectableCurrencies;
161
+ /**
162
+ * Reference to the Material Design outlined select element.
163
+ * Used to manage the select's internal state and keep it synchronized with the component's selected property.
164
+ */
165
+ private accessor selectElement;
166
+ /**
167
+ * Returns the form element that contains this component, if any.
168
+ * Part of the ElementInternals API for form-associated custom elements.
169
+ */
170
+ get form(): HTMLFormElement | null;
171
+ /**
172
+ * Returns the validity state of the component.
173
+ * Part of the ElementInternals API for form-associated custom elements.
174
+ */
175
+ get validity(): ValidityState;
176
+ /**
177
+ * Returns the validation message for the component.
178
+ * Part of the ElementInternals API for form-associated custom elements.
179
+ */
180
+ get validationMessage(): string;
181
+ /**
182
+ * Returns whether the component will be validated when the form is submitted.
183
+ * Part of the ElementInternals API for form-associated custom elements.
184
+ */
185
+ get willValidate(): boolean;
186
+ /**
187
+ * Checks the validity of the component without displaying validation UI.
188
+ * Part of the ElementInternals API for form-associated custom elements.
189
+ * @returns True if the component is valid, false otherwise
190
+ */
191
+ checkValidity(): boolean;
192
+ /**
193
+ * Checks the validity of the component and displays validation UI if invalid.
194
+ * Part of the ElementInternals API for form-associated custom elements.
195
+ * @returns True if the component is valid, false otherwise
196
+ */
197
+ reportValidity(): boolean;
198
+ /**
199
+ * Master list of supported currencies with their display information.
200
+ * This includes popular currencies with their ISO codes, names, symbols, countries, and flag emojis.
201
+ * Private and readonly to ensure data integrity.
202
+ */
203
+ private readonly currencies;
204
+ constructor();
205
+ connectedCallback(): void;
206
+ /**
207
+ * Updates the form value using ElementInternals.
208
+ */
209
+ private updateFormValue;
210
+ protected willUpdate(changed: PropertyValues<this>): void;
211
+ /**
212
+ * Called after the component has been updated and rendered.
213
+ * Ensures the select element's value stays synchronized with the component's selected state.
214
+ */
215
+ protected updated(changed: PropertyValues<this>): void;
216
+ /**
217
+ * Sets an error state using ElementInternals and optionally dispatches an error event.
218
+ * @param error The error to set
219
+ * @param dispatch Whether to dispatch an error event (default: true)
220
+ */
221
+ private setError;
222
+ /**
223
+ * Dispatches an error event.
224
+ * @param error The error to dispatch
225
+ */
226
+ private dispatchErrorEvent;
227
+ /**
228
+ * Clears the current error state using ElementInternals.
229
+ */
230
+ private clearError;
231
+ /**
232
+ * Validates currency codes against the supported currencies.
233
+ * @param codes Array of currency codes to validate
234
+ * @returns Array of invalid currency codes
235
+ */
236
+ private validateCurrencyCodes;
237
+ /**
238
+ * Safely validates and filters currency codes, setting errors for invalid codes.
239
+ * @param codes Array of currency codes to validate
240
+ * @param property Name of the property being validated
241
+ * @returns Array of valid currency codes
242
+ */
243
+ private safeCurrencyValidation;
244
+ /**
245
+ * Validates selection constraints using ElementInternals.
246
+ * @param newSelection The new selection to validate
247
+ * @returns Whether the selection is valid
248
+ */
249
+ private validateSelectionConstraints;
250
+ private updateSelectableCurrencies;
251
+ private handleCurrencySelect;
252
+ private handleRemoveCurrency;
253
+ private dispatchChangeEvent;
254
+ /**
255
+ * Get the currently selected currency codes as a copy of the array.
256
+ * This is a read-only getter that returns a shallow copy to prevent external modification.
257
+ * @returns Array of selected ISO 4217 currency codes
258
+ */
259
+ get selectedCurrencyCodes(): string[];
260
+ /**
261
+ * Get the full currency objects for currently selected currencies.
262
+ * This method looks up each selected currency code in the master currencies list
263
+ * and returns the complete currency information including name, symbol, country, and flag.
264
+ * @returns Array of complete Currency objects for selected currencies
265
+ */
266
+ getSelectedCurrencies(): Currency[];
267
+ /**
268
+ * Clear all selected currencies.
269
+ * This method removes all selections, validates constraints (such as required),
270
+ * updates the UI, and dispatches a change event. If validation fails (e.g.,
271
+ * component is required), the operation will be cancelled and an error will be set.
272
+ * @throws Will dispatch an error event if validation fails or an internal error occurs
273
+ */
274
+ clearSelection(): void;
275
+ /**
276
+ * Form state restore callback for ElementInternals.
277
+ * This method is called by the browser when form state is being restored
278
+ * (e.g., browser back/forward navigation, form autofill).
279
+ * It parses a comma-separated string of currency codes and restores the selection.
280
+ * @param state The state to restore - typically a comma-separated string of currency codes
281
+ * @param _mode The restore mode (unused in this implementation)
282
+ */
283
+ formStateRestoreCallback(state: string | FormData | null): void;
284
+ /**
285
+ * Form reset callback for ElementInternals.
286
+ * This method is called by the browser when the containing form is reset.
287
+ * It clears all selections, updates the UI, clears any errors, and updates the form value.
288
+ */
289
+ formResetCallback(): void;
290
+ /**
291
+ * Main render method for the component.
292
+ * Renders the currency selector with dropdown, selected chips (if multi-select), and error display.
293
+ * Updates ARIA attributes and error states based on current component state.
294
+ * @returns TemplateResult containing the complete component HTML
295
+ */
296
+ render(): TemplateResult;
297
+ /**
298
+ * Renders error messages when showErrors is true and the component is invalid.
299
+ * The error display uses ARIA live regions for accessibility.
300
+ * @returns TemplateResult with error display or nothing if no errors should be shown
301
+ */
302
+ protected renderError(): TemplateResult | typeof nothing;
303
+ /**
304
+ * Renders the selected currencies as removable chips in multi-select mode.
305
+ * Only renders when multi=true and there are selected currencies.
306
+ * Each chip displays the currency flag and code, and can be removed by the user.
307
+ * @returns TemplateResult with chip display or nothing if not applicable
308
+ */
309
+ protected renderSelected(): TemplateResult | typeof nothing;
310
+ }
311
+ //# sourceMappingURL=Picker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../../../src/elements/currency/internals/Picker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAIzF,OAAO,yCAAyC,CAAA;AAChD,OAAO,uCAAuC,CAAA;AAC9C,OAAO,iCAAiC,CAAA;AACxC,OAAO,6BAA6B,CAAA;AAEpC;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAA;IACZ,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAA;IACZ,uCAAuC;IACvC,MAAM,EAAE,MAAM,CAAA;IACd,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAA;IACf,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,yEAAyE;IACzE,IAAI,EAAE,YAAY,GAAG,WAAW,GAAG,UAAU,CAAA;IAC7C,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,gEAAgE;IAChE,OAAO,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