@epa-wg/custom-element-dist 0.0.33 → 0.0.35

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 (185) hide show
  1. package/.claude/settings.local.json +18 -0
  2. package/.gitattributes +4 -0
  3. package/.github/workflows/deploy.yml +59 -0
  4. package/.idea/copilot.data.migration.agent.xml +6 -0
  5. package/.idea/copilot.data.migration.ask.xml +6 -0
  6. package/.idea/copilot.data.migration.ask2agent.xml +6 -0
  7. package/.idea/copilot.data.migration.edit.xml +6 -0
  8. package/.idea/custom-element-dist.iml +2 -0
  9. package/.storybook/main.ts +20 -17
  10. package/.storybook/preview.ts +23 -23
  11. package/.yarn/install-state.gz +0 -0
  12. package/.yarnrc.yml +1 -0
  13. package/README.md +6 -4
  14. package/coverage/block-navigation.js +1 -1
  15. package/coverage/coverage-final.json +4 -3
  16. package/coverage/index.html +34 -19
  17. package/coverage/sorter.js +21 -7
  18. package/coverage/src/custom-element/coverage.svg +1 -1
  19. package/coverage/src/custom-element/custom-element.js/coverage.svg +1 -1
  20. package/coverage/src/custom-element/custom-element.js.html +448 -391
  21. package/coverage/src/custom-element/http-request.js/coverage.svg +1 -1
  22. package/coverage/src/custom-element/http-request.js.html +38 -17
  23. package/coverage/src/custom-element/index.html +26 -26
  24. package/coverage/src/custom-element/local-storage.js.html +1 -1
  25. package/coverage/src/custom-element/location-element.js.html +1 -1
  26. package/coverage/src/custom-element/module-url.js.html +1 -1
  27. package/coverage/src/index.html +1 -1
  28. package/coverage/src/material/theme/colors.js/coverage.svg +10 -0
  29. package/coverage/src/material/theme/colors.js.html +217 -0
  30. package/coverage/src/material/theme/coverage.svg +10 -0
  31. package/coverage/src/material/theme/index.html +116 -0
  32. package/coverage/src/mocks/handlers.ts.html +1 -1
  33. package/coverage/src/mocks/index.html +1 -1
  34. package/coverage/src/stories/frame.canvas.ts.html +1 -1
  35. package/coverage/src/stories/http-request.stories.ts.html +1 -1
  36. package/coverage/src/stories/index.html +1 -1
  37. package/coverage/src/stories/testStoryBook.ts.html +12 -12
  38. package/coverage/src/sum.ts.html +1 -1
  39. package/dist/custom-element-Bssk9jRy.cjs +97 -0
  40. package/dist/{custom-element-WnOqmEOe.js → custom-element-BzDjIYMe.js} +193 -183
  41. package/dist/custom-element-bundle.cjs +1 -1
  42. package/dist/custom-element-bundle.js +3 -3
  43. package/dist/demo/a.html +10 -3
  44. package/dist/demo/a.svg +26 -26
  45. package/dist/demo/html-template.html +4 -3
  46. package/dist/demo/s.xml +1 -75
  47. package/dist/demo/s.xslt +351 -72
  48. package/dist/demo/s1.xml +3706 -0
  49. package/dist/http-request-DSaowcG1.cjs +1 -0
  50. package/dist/{http-request-BOvP4KTl.js → http-request-DTCzZ1gc.js} +15 -9
  51. package/dist/mockServiceWorker.js +105 -63
  52. package/package.json +5 -4
  53. package/public/demo/a.html +10 -3
  54. package/public/demo/a.svg +26 -26
  55. package/public/demo/html-template.html +4 -3
  56. package/public/demo/s.xml +1 -75
  57. package/public/demo/s.xslt +351 -72
  58. package/public/demo/s1.xml +3706 -0
  59. package/public/mockServiceWorker.js +105 -63
  60. package/src/custom-element/custom-element.js +28 -9
  61. package/src/custom-element/demo/a.html +10 -3
  62. package/src/custom-element/demo/a.svg +26 -26
  63. package/src/custom-element/demo/html-template.html +4 -3
  64. package/src/custom-element/demo/s.xml +1 -75
  65. package/src/custom-element/demo/s.xslt +351 -72
  66. package/src/custom-element/demo/s1.xml +3706 -0
  67. package/src/custom-element/http-request.js +7 -0
  68. package/src/custom-element/ide/customData-dce.json +123 -0
  69. package/src/custom-element/ide/web-types-dce.json +128 -1
  70. package/src/custom-element/ide/web-types-xsl.json +1 -1
  71. package/src/material/angular.css +987 -987
  72. package/src/material/components/action.html +262 -0
  73. package/src/material/components/autocomplete.html +167 -239
  74. package/src/material/components/badge.html +238 -239
  75. package/src/material/components/dropdown.html +0 -1
  76. package/src/material/components/icon-link.html +160 -161
  77. package/src/material/components/icon.html +251 -252
  78. package/src/material/components/input.html +569 -570
  79. package/src/material/components/menu.html +235 -236
  80. package/src/material/components.html +157 -158
  81. package/src/material/demo.css +36 -36
  82. package/src/material/index.html +109 -110
  83. package/src/material/material.css +356 -356
  84. package/src/material/theme/Base-Principles.md +339 -0
  85. package/src/material/theme/README.md +298 -18
  86. package/src/material/theme/UI Domain Model in web applications.svg +1 -0
  87. package/src/material/theme/User Semantic Theme tokens.svg +1 -0
  88. package/src/material/theme/action-pending-poc.html +62 -0
  89. package/src/material/theme/actions-color.html +141 -0
  90. package/src/material/theme/colors-light.html +631 -0
  91. package/src/material/theme/colors-native.html +51 -0
  92. package/src/material/theme/colors-poc.html +66 -0
  93. package/src/material/theme/colors.html +297 -0
  94. package/src/material/theme/colors.js +44 -0
  95. package/src/material/theme/consumer-theme.css +745 -0
  96. package/src/material/theme/semantic.css +132 -132
  97. package/src/material/theme/style-bug.html +123 -0
  98. package/src/material/theme/theme-data.css +43 -0
  99. package/src/material/theme/theme-data.xhtml +2926 -0
  100. package/src/material/theme/todo.md +274 -0
  101. package/src/material/theme/tokens/action-colors.png +0 -0
  102. package/src/material/theme/tokens/cem-article-illustration-4x1-letterbox-2000x500.png +0 -0
  103. package/src/material/theme/tokens/cem-breakpoints.md +519 -0
  104. package/src/material/theme/tokens/cem-colors.md +715 -0
  105. package/src/material/theme/tokens/cem-consumerflow-typography-matrix.svg +198 -0
  106. package/src/material/theme/tokens/cem-coupling.md +372 -0
  107. package/src/material/theme/tokens/cem-data-vs-reading-numerals.svg +164 -0
  108. package/src/material/theme/tokens/cem-dimension.md +625 -0
  109. package/src/material/theme/tokens/cem-layering.md +562 -0
  110. package/src/material/theme/tokens/cem-m3-parity.md +343 -0
  111. package/src/material/theme/tokens/cem-responsive.md +238 -0
  112. package/src/material/theme/tokens/cem-shape.md +691 -0
  113. package/src/material/theme/tokens/cem-stroke-density-illustration-4to1-v3.svg +102 -0
  114. package/src/material/theme/tokens/cem-stroke.md +480 -0
  115. package/src/material/theme/tokens/cem-timing.md +198 -0
  116. package/src/material/theme/tokens/cem-typography-model-stack.svg +64 -0
  117. package/src/material/theme/tokens/cem-voice-fonts-typography.md +718 -0
  118. package/src/material/theme/tokens/cem-voice-ladder.svg +91 -0
  119. package/src/material/theme/tokens/chips.png +0 -0
  120. package/src/material/theme/tokens/columns-page.png +0 -0
  121. package/src/material/theme/tokens/initials.png +0 -0
  122. package/src/material/theme/tokens/nav-buttons.png +0 -0
  123. package/src/material/theme/tokens/script.png +0 -0
  124. package/src/material/theme/tokens/sufler.png +0 -0
  125. package/src/material/theme/tokens/typography-icons.png +0 -0
  126. package/src/mocks/versions.mock.ts +1 -1
  127. package/src/stories/__screenshots__/dom-merge.test.stories.ts/dom-merge-dom-merge-OrderPreservingOn2ndTransform-1.png +0 -0
  128. package/src/stories/__screenshots__/xslt-conditionals.test.stories.ts/xslt-conditionals-xslt-conditionals-MultipleIfOrderingWorkaround-1.png +0 -0
  129. package/src/stories/dom-merge.test.stories.ts +25 -1
  130. package/src/stories/xslt-conditionals.test.stories.ts +492 -0
  131. package/src/stories/xslt-for-each.test.stories.ts +336 -0
  132. package/src/stories/xslt-if.test.stories.ts +89 -0
  133. package/storybook-static/assets/{Color-F6OSRLHC-Cbp293x2.js → Color-F6OSRLHC-DeDlDLjU.js} +1 -1
  134. package/storybook-static/assets/{Configure-BrFr4SLE.js → Configure-CH_tIP5N.js} +1 -1
  135. package/storybook-static/assets/{DocsRenderer-CFRXHY34-DhHzJiIO.js → DocsRenderer-CFRXHY34-Bc9EPsUI.js} +2 -2
  136. package/storybook-static/assets/{attributes.test.stories-Gg9LQTEK.js → attributes.test.stories-BtamFQkF.js} +1 -1
  137. package/storybook-static/assets/{css.test.stories-B_3ltOrx.js → css.test.stories-BfNxLgwr.js} +1 -1
  138. package/storybook-static/assets/{custom-element-CPnvJnn8.js → custom-element-CnmjNo0g.js} +6 -6
  139. package/storybook-static/assets/{dom-merge.test.stories-nQxcgLoM.js → dom-merge.test.stories-DxnitrLK.js} +47 -6
  140. package/storybook-static/assets/entry-preview-BNCt9WBs.js +26 -0
  141. package/storybook-static/assets/{entry-preview-docs-Dwczwtsc.js → entry-preview-docs-CbF8-81D.js} +2 -2
  142. package/storybook-static/assets/{external-template.test.stories-DZ-rjnfd.js → external-template.test.stories-BTsww7B0.js} +1 -1
  143. package/storybook-static/assets/{form.test.stories-DQhPYtMj.js → form.test.stories-DNJFtPJb.js} +1 -1
  144. package/storybook-static/assets/{frame.canvas-ClTqYyMN.js → frame.canvas-E5n9h6j1.js} +1 -1
  145. package/storybook-static/assets/{handlers-CLkps6Nz.js → handlers-Dvg8CAeR.js} +1 -1
  146. package/storybook-static/assets/http-request-BWeEEBkP.js +1 -0
  147. package/storybook-static/assets/{http-request.stories-jo0f73nw.js → http-request.stories-DgrBNle8.js} +1 -1
  148. package/storybook-static/assets/{iframe-CZwRpnn9.js → iframe-DiVWehoI.js} +11 -11
  149. package/storybook-static/assets/{index-Dr4PwNfd.js → index-CGuyH0k-.js} +87 -87
  150. package/storybook-static/assets/{index-CJQtnF9V.js → index-CdEbhcV9.js} +1 -1
  151. package/storybook-static/assets/index-DO1nmyvI.js +11 -0
  152. package/storybook-static/assets/{index-B68YUdzy.js → index-w6iX3YlR.js} +3 -3
  153. package/storybook-static/assets/{local-storage.test.stories-uA5EKRPf.js → local-storage.test.stories-Hwq80yUr.js} +1 -1
  154. package/storybook-static/assets/{location-element.test.stories-Cu-6Elcg.js → location-element.test.stories-mEhZzm7x.js} +1 -1
  155. package/storybook-static/assets/{module-url.test.stories-CD_wusXQ.js → module-url.test.stories-Bj46iT0V.js} +1 -1
  156. package/storybook-static/assets/{preview-CuCH40jj.js → preview-BjbXcJci.js} +2 -2
  157. package/storybook-static/assets/{preview-BFlNN3Wj.js → preview-Bn8igYMp.js} +1 -1
  158. package/storybook-static/assets/{preview-Cm4PPhHS.js → preview-CfuT8gak.js} +1 -1
  159. package/storybook-static/assets/{set-url.test.stories-CY7B9BVZ.js → set-url.test.stories-hzxLcqmm.js} +1 -1
  160. package/storybook-static/assets/{slice-events.test.stories-BVnPXm6e.js → slice-events.test.stories-DVyXFRU1.js} +1 -1
  161. package/storybook-static/assets/{slots.test.stories-Dxsa9KdA.js → slots.test.stories-CS544nS4.js} +1 -1
  162. package/storybook-static/assets/{version-select.test.stories-Buga1PAa.js → version-select.test.stories-D36nfYBq.js} +1 -1
  163. package/storybook-static/assets/xslt-conditionals.test.stories-BS1PTIHe.js +633 -0
  164. package/storybook-static/assets/xslt-for-each.test.stories-CtPS20RK.js +329 -0
  165. package/storybook-static/assets/xslt-if.test.stories-DcHrAMSY.js +71 -0
  166. package/storybook-static/demo/a.html +10 -3
  167. package/storybook-static/demo/a.svg +26 -26
  168. package/storybook-static/demo/html-template.html +4 -3
  169. package/storybook-static/demo/s.xml +1 -75
  170. package/storybook-static/demo/s.xslt +351 -72
  171. package/storybook-static/demo/s1.xml +3706 -0
  172. package/storybook-static/iframe.html +2 -2
  173. package/storybook-static/index.json +1 -1
  174. package/storybook-static/mockServiceWorker.js +105 -63
  175. package/storybook-static/project.json +1 -1
  176. package/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js +69 -66
  177. package/storybook-static/sb-addons/essentials-docs-3/manager-bundle.js +62 -59
  178. package/dist/custom-element-6slVaFEs.cjs +0 -97
  179. package/dist/http-request-DPrY7mGh.cjs +0 -1
  180. package/storybook-static/assets/attributes.test.stories-CzWkKw0e.js +0 -1
  181. package/storybook-static/assets/entry-preview-DHVXbf3x.js +0 -26
  182. package/storybook-static/assets/external-template.test.stories-BivZqBTp.js +0 -1
  183. package/storybook-static/assets/http-request-DNq59pnj.js +0 -1
  184. package/storybook-static/assets/index-BwkS7JH_.js +0 -8
  185. package/storybook-static/assets/module-url.test.stories-CTjUAk3J.js +0 -1
@@ -1,571 +1,570 @@
1
- <!DOCTYPE html>
2
- <html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
6
- <title>Components - custom-element - Material Design</title>
7
- <link href="../../custom-element/demo/wc-square.svg" rel="icon"/>
8
- <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
9
- <link crossorigin="anonymous" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css"
10
- integrity="sha384-DyZ88mC6Up2uqS4h/KRgHuoeGwBcD4Ng9SiP4dIRy0EXTlnuz47vAwmeGwVChigm" rel="stylesheet"/>
11
-
12
- <script type="importmap">
13
- {
14
- "imports": {
15
- "@epa-wg/": "../../"
16
- }
17
- }
18
- </script>
19
- <script src="../../custom-element/module-url.js" type="module"></script>
20
- <script src="../../custom-element/custom-element.js" type="module"></script>
21
- <style>
22
- @import "../angular.css";
23
- @import "../material.css";
24
- @import "../theme/semantic.css";
25
- @import "../demo.css";
26
- main{
27
- display: flex; flex-wrap: wrap;
28
- gap: 3rem;
29
- padding: 5rem;
30
- &>p{ min-width: 90%; }
31
- html-demo-element{flex:1; width: 100%; }
32
- }
33
- html-demo-element.flat-attr{
34
- .token.attr-name:before{content:'\A '; }
35
- }
36
- </style>
37
- </head>
38
-
39
- <body>
40
- <custom-element hidden src="./icon-link.html#cem-icon-link" tag="cem-icon-link"></custom-element>
41
- <custom-element hidden src="./icon.html#cem-icon" tag="cem-icon"></custom-element>
42
-
43
-
44
- <header class="cem-theme-teal">
45
- <custom-element src="../index.html#nav-head" ></custom-element>
46
- </header>
47
- <pre>
48
- TODO
49
- * error handling & styling
50
- * link to form error handling
51
- * password show text 👁️ & clear button
52
- * slice propagation to owner DCE
53
- * tokens as in https://material-web.dev/components/text-field/#filled-text-field-tokens
54
- or by css in https://material.angular.io/components/input/overview
55
- * outlined variation
56
- * docs w/ how to use
57
- </pre>
58
- <main>
59
- <section>
60
- <p><code>cem-input</code> is text input component from &lt;custom-element&gt; Material suite based on the
61
- <a href="https://material.io/components" >Material Design specification</a>,
62
- <a href="https://m3.material.io/components/text-fields/specs" >text fields</a> in particular.
63
- </p>
64
- <p>Other implementations: <a href="https://material-web.dev/components/text-field/">Material Web</a>(Lit),
65
- <a href="https://material.angular.io/components/input/overview">Angular Material</a>
66
- </p>
67
- <h1>Attributes</h1>
68
- <div> <code>leading, label, trailing, supporting </code> attributes define the text when slot
69
- with same name is omitted.
70
- </div>
71
- <div> <code>leading</code>, <code>trailing</code> attributes defines the
72
- <a href="./icon.html">cem-icon</a> source.
73
- </div>
74
- <div> <code>label</code> attribute defines the label text.
75
- </div>
76
- <h1>Slots</h1>
77
- <div> <code>leading</code> placeholder for leading icon</div>
78
- <div> <code>label</code> placeholder for label text</div>
79
- <div> <code>trailing</code> placeholder for trailing icon</div>
80
- <div> <code>supporting</code> placeholder for supporting text</div>
81
- <div> <code>warn</code> warning text, </div>
82
- <p>
83
- <code>warn</code> slot content would overlap the <code>supporting</code> slot when not empty.
84
- Default slot implementation is sensitive to <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validationMessage"
85
- >validationMessage property</a>.
86
- </p>
87
- <details>
88
- <summary>Error handling and styling</summary>
89
- Something small enough to escape casual notice.
90
- </details>
91
-
92
- </section>
93
- <custom-element tag="cem-input" hidden>
94
- <template id="cem-input">
95
- <attribute name="value" select="//selected[//selected/event] ?? //attributes/@value" ></attribute>
96
- <attribute name="name" ></attribute>
97
- <attribute name="type" ></attribute>
98
- <attribute name="autocapitalize" ></attribute>
99
- <attribute name="disabled" ></attribute>
100
- <attribute name="multiple" ></attribute>
101
- <attribute name="readonly" ></attribute>
102
- <attribute name="required" ></attribute>
103
- <attribute name="incremental" ></attribute>
104
- <attribute name="max" ></attribute>
105
- <attribute name="maxlength" ></attribute>
106
- <attribute name="min" ></attribute>
107
- <attribute name="minlength" ></attribute>
108
- <attribute name="size" ></attribute>
109
- <attribute name="step" ></attribute>
110
- <attribute name="tabindex" ></attribute>
111
- <attribute name="autocomplete" ></attribute>
112
- <attribute name="form" ></attribute>
113
- <attribute name="id" ></attribute>
114
- <attribute name="list" ></attribute>
115
- <attribute name="pattern" ></attribute>
116
- <attribute name="placeholder" ></attribute>
117
- <attribute name="title" ></attribute>
118
- <attribute name="leading" aria-description="leading icon" ></attribute>
119
- <attribute name="trailing" aria-description="trailing icon" ></attribute>
120
- <attribute name="label" aria-description="label text" ></attribute>
121
- <attribute name="supporting" aria-description="Supporting text" ></attribute>
122
-
123
- <style>
124
-
125
- &>dce-root
126
- {
127
- display: flex; flex-direction: column; justify-content: center;
128
- --input-padding: 0;
129
-
130
- --cem-input-container-shape: 0.25rem;
131
- --cem-input-background-color: var(--cem-list-background-color);
132
- --cem-input-container-elevation-shadow: 0px 3px 1px -2px rgba(0, 0, 0, .2), 0px 2px 2px 0px rgba(0, 0, 0, .14), 0px 1px 5px 0px rgba(0, 0, 0, .12);
133
- --cem-input-focus-transition: all 280ms cubic-bezier(0.4, 0, 0.2, 1);
134
-
135
- &:has(input:invalid,input:user-invalid,input:out-of-range, .warn>*:not(:empty) )
136
- { --cem-filled-text-field-label-text-color: var(--alert-color,red);
137
- --cem-input-outline-color:var(--cem-filled-text-field-label-text-color);
138
- --cem-input-outline: inset 0 -1px 0 var(--cem-input-outline-color);
139
- --cem-outline-color-focus: var(--cem-input-outline-color);
140
- color: var(--cem-filled-text-field-label-text-color);
141
- .supporting{ display: none; }
142
- }
143
- &>label
144
- { display: flex; flex: 1; gap: 0.5rem;
145
- padding: 0.5rem 1rem;
146
- background-color: var(--cem-filled-text-field-container-color, var(--cem-app-surface-variant));
147
- &:hover
148
- { --cem-filled-text-field-container-color: var(--cem-filled-text-field-container-color-hover,silver);
149
- --cem-input-outline-color:var(--text-color,black);
150
- box-shadow: inset 0 -1px 0 var(--cem-input-outline-color,black);
151
- color:var(--text-color,black)
152
- }
153
- box-shadow: var(--cem-input-outline);
154
- transition: var(--drop-transition);
155
- box-sizing: border-box;
156
- min-height: 3.5rem;
157
- color: var(--cem-filled-text-field-label-text-color);
158
- position: relative;
159
- &>.entry{ display: flex;flex-direction: column; justify-content: center;flex:1; }
160
- label{display: flex;}
161
- input
162
- { background: none; padding: var(--input-padding);
163
- &,&:focus,&:focus-visible{ border: none; outline: none; }
164
- &:placeholder-shown{ border: none; outline:none; }
165
- &[value=""]{ height: 0; }
166
- &:focus,&:focus-visible,&[placeholder*=""]{ height: auto; }
167
-
168
- color: var(--cem-filled-text-field-input-text-color, var(--cem-app-on-surface));
169
- caret-color: var(--cem-filled-text-field-caret-color, var(--cem-app-primary));
170
- font-size: 1rem;
171
- transition: var(--drop-transition);
172
- }
173
- &:after{ display: block; width: 0; height: 0; content: ' ';
174
- left:0;
175
- transition: var(--cem-input-focus-transition);
176
- position: absolute; align-self: center;
177
- bottom: var(--cem-focus-outline-height);
178
- }
179
- }
180
- &:focus-within
181
- {
182
- &> label
183
- { font-size: small; justify-content: space-between;
184
- color: var(--cem-outline-color-focus);
185
- input{ caret-color: var(--cem-outline-color-focus); }
186
- &:after{ width: 100%; height: var(--cem-focus-outline-height);
187
- left:0;
188
- background: none;
189
- box-shadow: 0 var(--cem-focus-outline-height) 0 var(--cem-outline-color-focus);
190
- align-self: center;
191
- transition: var(--cem-input-focus-transition);
192
- }
193
- }
194
- }
195
- label:has( input:not([value=""]) ){ font-size: small; justify-content: space-between;}
196
- slice{display: none;}
197
- .warn,.supporting
198
- {
199
- padding: 0.25rem 1rem;
200
- font-size: var(--cem-form-field-subscript-text-size, var(--cem-sys-body-small-size));
201
- }
202
- [slot="trailing"],[slot="leading"]{display: flex;}
203
- }
204
- </style>
205
- <label>
206
- <slot name="leading">
207
- <if test="$leading">
208
- <cem-icon image="{$leading}"></cem-icon>
209
- </if>
210
- </slot>
211
- <div class="entry">
212
- <slot name="label">
213
- <if test="$label">
214
- <span class="label">{$label}</span>
215
- </if>
216
- </slot>
217
- <slot name="input">
218
- <xhtml:input
219
- type="{$type}"
220
- value="{/datadom/attributes/value }"
221
- slice="selected" slice-event="input"
222
- size="2"
223
- >
224
- <if test="hasBoolAttribute($required)" ><attribute name="required" >{$required }</attribute></if>
225
- <if test="hasBoolAttribute($disabled)" ><attribute name="disabled" >{$disabled }</attribute></if>
226
- <if test="hasBoolAttribute($multiple)" ><attribute name="multiple" >{$multiple }</attribute></if>
227
- <if test="hasBoolAttribute($readonly)" ><attribute name="readonly" >{$readonly }</attribute></if>
228
- <if test="hasBoolAttribute($incremental)" ><attribute name="incremental" >{$incremental }</attribute></if>
229
- <if test="$max" ><attribute name="max" >{$max }</attribute></if>
230
- <if test="$maxlength" ><attribute name="maxlength" >{$maxlength }</attribute></if>
231
- <if test="$min" ><attribute name="min" >{$min }</attribute></if>
232
- <if test="$minlength" ><attribute name="minlength" >{$minlength }</attribute></if>
233
- <if test="$size" ><attribute name="size" >{$size }</attribute></if>
234
- <if test="$step" ><attribute name="step" >{$step }</attribute></if>
235
- <if test="$tabindex" ><attribute name="tabindex" >{$tabindex }</attribute></if>
236
- <if test="$autocapitalize" ><attribute name="autocapitalize" >{$autocapitalize }</attribute></if>
237
- <if test="$autocomplete" ><attribute name="autocomplete" >{$autocomplete }</attribute></if>
238
- <if test="$form" ><attribute name="form" >{$form }</attribute></if>
239
- <if test="$id" ><attribute name="id" >{$id }</attribute></if>
240
- <if test="$list" ><attribute name="list" >{$list }</attribute></if>
241
- <if test="$name" ><attribute name="name" >{$name }</attribute></if>
242
- <if test="$pattern" ><attribute name="pattern" >{$pattern }</attribute></if>
243
- <if test="$placeholder" ><attribute name="placeholder" >{$placeholder }</attribute></if>
244
- <if test="$title" ><attribute name="title" >{$title }</attribute></if>
245
-
246
- <slice name="focused" slice-event="blur" slice-value="0"></slice>
247
- <slice name="focused" slice-event="focus" slice-value="1"></slice>
248
- </xhtml:input>
249
- </slot>
250
- </div>
251
- <slot name="trailing">
252
- <if test="$trailing">
253
- <cem-icon image="{$trailing}"></cem-icon>
254
- </if>
255
- </slot>
256
- </label>
257
- <div class="supporting">
258
- <slot name="supporting">
259
- <if test="$supporting">
260
- {$supporting}
261
- </if>
262
- </slot>
263
- </div>
264
- <div class="warn">
265
- <slot name="warn">{//warn}</slot>
266
- </div>
267
- </template>
268
- </custom-element>
269
-
270
- <custom-element tag="cem-demo-input-types" hidden>
271
- <template>
272
- <attribute name="value" select="//type"></attribute>
273
- <label>Type:
274
- <select slice="type">
275
- <option value="text" > text </option>
276
- <option value="date" > date </option>
277
- <option value="datetime-local"> datetime-local </option>
278
- <option value="email" > email </option>
279
- <option value="month" > month </option>
280
- <option value="number" > number </option>
281
- <option value="password" > password </option>
282
- <option value="tel" > tel </option>
283
- <option value="text" > text </option>
284
- <option value="time" > time </option>
285
- <option value="url" > url </option>
286
- <option value="week" > week </option>
287
- <optgroup label="other types do not make a sense for cem-input">
288
- <option value="button" > button </option>
289
- <option value="checkbox" > checkbox </option>
290
- <option value="color" > color </option>
291
- <option value="file" > file </option>
292
- <option value="hidden" > hidden </option>
293
- <option value="image" > image </option>
294
- <option value="radio" > radio </option>
295
- <option value="range" > range </option>
296
- <option value="reset" > reset </option>
297
- <option value="search" > search </option>
298
- <option value="submit" > submit </option>
299
- </optgroup>
300
- </select>
301
- </label>
302
- </template>
303
- </custom-element>
304
-
305
- <custom-element tag="cem-demo-cb">
306
- <template>
307
- <attribute name="slice" ></attribute>
308
- <attribute name="value" select="//val"></attribute>
309
- <label><input type="checkbox" value="{$slice}" slice="val" /> {$slice} </label>
310
- </template>
311
- </custom-element>
312
-
313
- <custom-element tag="cem-demo-tx">
314
- <template>
315
- <attribute name="slice" ></attribute>
316
- <attribute name="value" select="//val"></attribute>
317
- <style>input,label{ width: 100%; } </style>
318
- <label>{$slice}<input slice="val" value="{$value}"/></label>
319
- </template>
320
- </custom-element>
321
-
322
- <custom-element tag="cem-demo-in">
323
- <template>
324
- <attribute name="slice" ></attribute>
325
- <attribute name="value" select="//val"></attribute>
326
- <style>input,label{ width: 100%; } </style>
327
- <label>{$slice}<input slice="val" type="number"/></label>
328
- </template>
329
- </custom-element>
330
-
331
- <html-demo-element legend="Most features" description="Focus to see the cursor in input with label shifted upward "
332
- class="flat-attr"
333
- >
334
- <template>
335
- <cem-input label="String field with leading and trailing icon "
336
- placeholder="type here"
337
- supporting="required field. Clear to see placeholder."
338
- leading="search"
339
- trailing="close"
340
- ></cem-input>
341
- </template>
342
- </html-demo-element>
343
-
344
- <html-demo-element legend="No value" description="Focus to see the cursor in input with label shifted upward ">
345
- <template>
346
- <cem-input label="String field" ></cem-input>
347
- </template>
348
- </html-demo-element>
349
-
350
- <html-demo-element legend="No value with placeholder" description="focus to see the placeholder text" class="flat-attr">
351
- <template>
352
- <cem-input label="Number" type="number" placeholder="Enter the numeric value">
353
- </cem-input>
354
- </template>
355
- </html-demo-element>
356
-
357
- <html-demo-element legend="Value defined" description="The value should be visible" >
358
- <template>
359
- <cem-input label="Text" type="text" value="abc"></cem-input>
360
- </template>
361
- </html-demo-element>
362
-
363
- <html-demo-element legend="leading and trailing slots" >
364
- <div slot="description"><code>leading</code> slot inserted before input,
365
- <code>trailing</code> slot injected after</div>
366
-
367
- <template>
368
- <cem-input label="slots sample" type="text" >
369
- <div slot="leading"><cem-icon image="edit"></cem-icon></div>
370
- <div slot="trailing">
371
- <cem-icon image="👁"></cem-icon>
372
- ️<cem-icon image="close"></cem-icon>️
373
- </div>
374
- </cem-input>
375
- </template>
376
- </html-demo-element>
377
-
378
-
379
- <html-demo-element legend="password with trailing slots interaction" >
380
- <div slot="description"><code>trailing</code> and other slots can become functional </div>
381
- <p>Those slots can be used for error or hint UI; persistent or triggered by hover/focus.<br/>
382
- <a href="./autocomplete.html">cem-autocomplete</a> uses <code>trailing</code> slot for
383
- <a href="./menu.html">menu</a> with suggestions.
384
- </p>
385
- <p>Click in input field to see the focus leading icon <cem-icon image="edit"></cem-icon>
386
- changed to <cem-icon image="history_edu"></cem-icon></p>
387
- <template>
388
- <custom-element>
389
- <template id="cem-password">
390
- <attribute name="value" select="//password[//password/event]"></attribute>
391
-
392
- <style>
393
- .input-focused{ display: none; }
394
- .input-unfocused{ display: inline-flex; }
395
- &:focus-within{
396
- .input-focused{ display: inline-flex; }
397
- .input-unfocused{ display:none; }
398
- }
399
- .eye-contailer
400
- { display: flex;
401
- align-items: center;
402
- }
403
-
404
- [type="checkbox"],.visible-ico{ display: none; }
405
-
406
- &:has([type="checkbox"]:checked)
407
- {
408
- .visible-ico{ display: inline-flex; }
409
- .invisible-ico{ display: none; }
410
- }
411
- .invisible-ico
412
- { color:var(--cem-action-primary-color);
413
- background-color: var(--cem-action-primary-background);
414
- transition: var(--cem-action-transition);
415
- &:hover{
416
- background-color: var(--cem-action-primary-background-hover);
417
- box-shadow: var(--cem-action-box-shadow-hover); }
418
- &:focus{ background-color: var(--cem-action-primary-background-focus); }
419
- &:active{ background-color: var(--cem-action-primary-background-active); }
420
- }
421
- </style>
422
- <input type="checkbox" slice="visible" id="visible-cb" />
423
- <cem-input label="password sample" slice="password" value="{//password[//password/event]}">
424
- <attribute name="type"><if test="not(//visible='on')">password</if></attribute>
425
- <div slot="leading">
426
- <cem-icon image="history_edu" class="input-focused"></cem-icon>
427
- <cem-icon image="edit" class="input-unfocused"></cem-icon>
428
- </div>
429
- <div slot="trailing">
430
- <label class="eye-contailer" for="visible-cb">
431
- <cem-icon image="visibility" class="visible-ico" tabindex="0"></cem-icon>
432
- <cem-icon image="visibility_off" class="invisible-ico" tabindex="0"></cem-icon>
433
- </label>
434
- </div>
435
- </cem-input>
436
- </template>
437
- </custom-element>
438
- </template>
439
- </html-demo-element>
440
-
441
-
442
- <html-demo-element legend="Native error support" >
443
- <div slot="descrition">Native <a href="https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation">
444
- Form validation</a> is supported. See also <a href="../../custom-element/demo/form.html"><code>custom-element</code> form handling</a> </div>
445
- <div><code>required</code> attribute would trigger the system message if the field is empty.</div>
446
- <div>
447
- Press Next button to see the browser error popup.</div>
448
- <template>
449
- <form>
450
- <cem-input required></cem-input>
451
- <button>Next</button>
452
- </form>
453
- </template>
454
- </html-demo-element>
455
-
456
- <html-demo-element legend="Error message">
457
- <div slot="description"><code>warn</code> attribute and slot is used for warning message</div>
458
- <div slot="description"><code>supporting</code> attribute and slot is used for supplementary message,
459
- hidden when <code>warn</code> is not empty </div>
460
- <template>
461
-
462
- <cem-input warn="warning message" label="text" value="abc"></cem-input>
463
- <hr/>
464
- <cem-input supporting="complimentary message" label="text" value="abc"></cem-input>
465
- <hr/>
466
- <cem-input warn="warning message" supporting="complimentary message is overridden by warning" label="text" value="abc"></cem-input>
467
- <hr/>
468
- <cem-input warn="warning message" label="text" value="abc">
469
- <div slot="warn"><cem-icon image="report" size="small"></cem-icon><b>abc</b> is not valid value</div>
470
- </cem-input>
471
- </template>
472
- </html-demo-element>
473
-
474
-
475
- <html-demo-element legend="INPUT field attributes playground" id="play" style="flex: 2 2 80vw;">
476
- <div slot="descrition">
477
- <p> Underlying implementation uses
478
- <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">HTML input</a>.
479
- All its attributes are supported.
480
- </p>
481
- <custom-element >
482
- <template>
483
- <style>
484
- &>dce-root
485
- { display: flex; flex-wrap: wrap; gap: 2rem; align-items: center;
486
- &>*{ flex: 1 1 10rem; }
487
- }
488
- label{ display: block; }
489
- </style>
490
- <cem-demo-cb slice="disabled" ></cem-demo-cb>
491
- <cem-demo-cb slice="multiple" ></cem-demo-cb>
492
- <cem-demo-cb slice="readonly" ></cem-demo-cb>
493
- <cem-demo-cb slice="required" ></cem-demo-cb>
494
- <cem-demo-cb slice="incremental" ></cem-demo-cb>
495
- <cem-demo-in slice="max" ></cem-demo-in>
496
- <cem-demo-in slice="maxlength" ></cem-demo-in>
497
- <cem-demo-in slice="min" ></cem-demo-in>
498
- <cem-demo-in slice="minlength" ></cem-demo-in>
499
- <cem-demo-in slice="size" ></cem-demo-in>
500
- <cem-demo-in slice="step" ></cem-demo-in>
501
- <cem-demo-in slice="tabindex" ></cem-demo-in>
502
- <cem-demo-tx slice="autocapitalize" title="on sentences off none words characters "></cem-demo-tx>
503
- <cem-demo-tx slice="autocomplete" ></cem-demo-tx>
504
- <cem-demo-tx slice="form" ></cem-demo-tx>
505
- <cem-demo-tx slice="id" ></cem-demo-tx>
506
- <cem-demo-tx slice="list" ></cem-demo-tx>
507
- <cem-demo-tx slice="name" ></cem-demo-tx>
508
- <cem-demo-tx slice="pattern" ></cem-demo-tx>
509
- <cem-demo-tx slice="placeholder" ></cem-demo-tx>
510
- <cem-demo-tx slice="title" ></cem-demo-tx>
511
- <cem-demo-tx slice="value" value="abc" ></cem-demo-tx>
512
- &bull;
513
- <cem-demo-tx slice="label" title="label text" ></cem-demo-tx>
514
- <cem-demo-tx slice="leading" title="leading icon" ></cem-demo-tx>
515
- <cem-demo-tx slice="trailing" title="trailing icon" ></cem-demo-tx>
516
- <cem-demo-tx slice="supporting" title="supporting text" ></cem-demo-tx>
517
-
518
- <cem-demo-input-types slice="type"></cem-demo-input-types>
519
-
520
- <form action="#play">
521
- <cem-input type="{//type}" >
522
- <if test="//disabled = 'disabled'" ><attribute name="disabled" ></attribute></if>
523
- <if test="//multiple = 'multiple'" ><attribute name="multiple" ></attribute></if>
524
- <if test="//readonly = 'readonly'" ><attribute name="readonly" ></attribute></if>
525
- <if test="//required = 'required'" ><attribute name="required" ></attribute></if>
526
- <if test="//incremental = 'incremental'" ><attribute name="incremental" ></attribute></if>
527
- <if test="not(//max = '')" ><attribute name="max" >{//max }</attribute></if>
528
- <if test="not(//maxlength = '')" ><attribute name="maxlength" >{//maxlength }</attribute></if>
529
- <if test="not(//min = '')" ><attribute name="min" >{//min }</attribute></if>
530
- <if test="not(//minlength = '')" ><attribute name="minlength" >{//minlength }</attribute></if>
531
- <if test="not(//size = '')" ><attribute name="size" >{//size }</attribute></if>
532
- <if test="not(//step = '')" ><attribute name="step" >{//step }</attribute></if>
533
- <if test="not(//tabindex = '')" ><attribute name="tabindex" >{//tabindex }</attribute></if>
534
- <if test="not(//autocapitalize='')" ><attribute name="autocapitalize" >{//autocapitalize }</attribute></if>
535
- <if test="not(//autocomplete = '')" ><attribute name="autocomplete" >{//autocomplete }</attribute></if>
536
- <if test="not(//form = '')" ><attribute name="form" >{//form }</attribute></if>
537
- <if test="not(//id = '')" ><attribute name="id" >{//id }</attribute></if>
538
- <if test="not(//list = '')" ><attribute name="list" >{//list }</attribute></if>
539
- <if test="not(//name = '')" ><attribute name="name" >{//name }</attribute></if>
540
- <if test="not(//pattern = '')" ><attribute name="pattern" >{//pattern }</attribute></if>
541
- <if test="not(//placeholder = '')" ><attribute name="placeholder" >{//placeholder }</attribute></if>
542
- <if test="not(//title = '')" ><attribute name="title" >{//title }</attribute></if>
543
- <if test="not(//value = '')" ><attribute name="value" >{//value }</attribute></if>
544
- <if test="not(//label = '')" ><attribute name="label" >{//label }</attribute></if>
545
- <if test="not(//leading = '')" ><attribute name="leading" >{//leading }</attribute></if>
546
- <if test="not(//trailing = '')" ><attribute name="trailing" >{//trailing }</attribute></if>
547
- <if test="not(//supporting = '')" ><attribute name="supporting" >{//supporting }</attribute></if>
548
- </cem-input>
549
- <button>Next</button>
550
- <if test="//disabled = 'disabled'" >//disabled = 'disabled' </if>
551
-
552
- </form>
553
- </template>
554
- </custom-element>
555
-
556
- </div>
557
- <template>
558
- </template>
559
- </html-demo-element>
560
-
561
- </main>
562
- <footer>
563
- <hr/>
564
- Powered by Syngrafact Corp. ©2024.<br/>
565
- <a href="../../LICENSE"> Code and documentation licensed under an Apache License 2.0 </a>
566
- </footer>
567
- <!--<script type="module" src="./html-demo-element.js"></script>-->
568
- <script type="module" src="https://unpkg.com/html-demo-element@1/html-demo-element.js"></script>
569
-
570
- </body>
1
+ <!DOCTYPE html>
2
+ <html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
6
+ <title>Components - custom-element - Material Design</title>
7
+ <link href="../../custom-element/demo/wc-square.svg" rel="icon"/>
8
+ <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
9
+ <link crossorigin="anonymous" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css"
10
+ integrity="sha384-DyZ88mC6Up2uqS4h/KRgHuoeGwBcD4Ng9SiP4dIRy0EXTlnuz47vAwmeGwVChigm" rel="stylesheet"/>
11
+
12
+ <script type="importmap">
13
+ {
14
+ "imports": {
15
+ "@epa-wg/": "../../"
16
+ }
17
+ }
18
+ </script>
19
+ <script src="../../custom-element/module-url.js" type="module"></script>
20
+ <script src="../../custom-element/custom-element.js" type="module"></script>
21
+ <style>
22
+ @import "../angular.css";
23
+ @import "../material.css";
24
+ @import "../theme/semantic.css";
25
+ @import "../demo.css";
26
+ main{
27
+ display: flex; flex-wrap: wrap;
28
+ gap: 3rem;
29
+ padding: 5rem;
30
+ &>p{ min-width: 90%; }
31
+ html-demo-element{flex:1; width: 100%; }
32
+ }
33
+ html-demo-element.flat-attr{
34
+ .token.attr-name:before{content:'\A '; }
35
+ }
36
+ </style>
37
+ </head>
38
+
39
+ <body>
40
+ <custom-element hidden src="./icon-link.html#cem-icon-link" tag="cem-icon-link"></custom-element>
41
+ <custom-element hidden src="./icon.html#cem-icon" tag="cem-icon"></custom-element>
42
+
43
+
44
+ <header class="cem-theme-teal">
45
+ <custom-element src="../index.html#nav-head" ></custom-element>
46
+ </header>
47
+ <pre>
48
+ TODO
49
+ * error handling & styling
50
+ * link to form error handling
51
+ * password show text 👁️ & clear button
52
+ * slice propagation to owner DCE
53
+ * tokens as in https://material-web.dev/components/text-field/#filled-text-field-tokens
54
+ or by css in https://material.angular.io/components/input/overview
55
+ * outlined variation
56
+ * docs w/ how to use
57
+ </pre>
58
+ <main>
59
+ <section>
60
+ <p><code>cem-input</code> is text input component from &lt;custom-element&gt; Material suite based on the
61
+ <a href="https://material.io/components" >Material Design specification</a>,
62
+ <a href="https://m3.material.io/components/text-fields/specs" >text fields</a> in particular.
63
+ </p>
64
+ <p>Other implementations: <a href="https://material-web.dev/components/text-field/">Material Web</a>(Lit),
65
+ <a href="https://material.angular.io/components/input/overview">Angular Material</a>
66
+ </p>
67
+ <h1>Attributes</h1>
68
+ <div> <code>leading, label, trailing, supporting </code> attributes define the text when slot
69
+ with same name is omitted.
70
+ </div>
71
+ <div> <code>leading</code>, <code>trailing</code> attributes defines the
72
+ <a href="./icon.html">cem-icon</a> source.
73
+ </div>
74
+ <div> <code>label</code> attribute defines the label text.
75
+ </div>
76
+ <h1>Slots</h1>
77
+ <div> <code>leading</code> placeholder for leading icon</div>
78
+ <div> <code>label</code> placeholder for label text</div>
79
+ <div> <code>trailing</code> placeholder for trailing icon</div>
80
+ <div> <code>supporting</code> placeholder for supporting text</div>
81
+ <div> <code>warn</code> warning text, </div>
82
+ <p>
83
+ <code>warn</code> slot content would overlap the <code>supporting</code> slot when not empty.
84
+ Default slot implementation is sensitive to <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validationMessage"
85
+ >validationMessage property</a>.
86
+ </p>
87
+ <details>
88
+ <summary>Error handling and styling</summary>
89
+ Something small enough to escape casual notice.
90
+ </details>
91
+
92
+ </section>
93
+ <custom-element tag="cem-input" hidden>
94
+ <template id="cem-input">
95
+ <attribute name="value" select="//selected[//selected/event] ?? //attributes/@value" ></attribute>
96
+ <attribute name="name" ></attribute>
97
+ <attribute name="type" ></attribute>
98
+ <attribute name="autocapitalize" ></attribute>
99
+ <attribute name="disabled" ></attribute>
100
+ <attribute name="multiple" ></attribute>
101
+ <attribute name="readonly" ></attribute>
102
+ <attribute name="required" ></attribute>
103
+ <attribute name="incremental" ></attribute>
104
+ <attribute name="max" ></attribute>
105
+ <attribute name="maxlength" ></attribute>
106
+ <attribute name="min" ></attribute>
107
+ <attribute name="minlength" ></attribute>
108
+ <attribute name="size" ></attribute>
109
+ <attribute name="step" ></attribute>
110
+ <attribute name="tabindex" ></attribute>
111
+ <attribute name="autocomplete" ></attribute>
112
+ <attribute name="form" ></attribute>
113
+ <attribute name="id" ></attribute>
114
+ <attribute name="list" ></attribute>
115
+ <attribute name="pattern" ></attribute>
116
+ <attribute name="placeholder" ></attribute>
117
+ <attribute name="title" ></attribute>
118
+ <attribute name="leading" aria-description="leading icon" ></attribute>
119
+ <attribute name="trailing" aria-description="trailing icon" ></attribute>
120
+ <attribute name="label" aria-description="label text" ></attribute>
121
+ <attribute name="supporting" aria-description="Supporting text" ></attribute>
122
+
123
+ <style>
124
+
125
+ &>dce-root
126
+ {
127
+ display: flex; flex-direction: column; justify-content: center;
128
+ --input-padding: 0;
129
+
130
+ --cem-input-container-shape: 0.25rem;
131
+ --cem-input-background-color: var(--cem-list-background-color);
132
+ --cem-input-container-elevation-shadow: 0px 3px 1px -2px rgba(0, 0, 0, .2), 0px 2px 2px 0px rgba(0, 0, 0, .14), 0px 1px 5px 0px rgba(0, 0, 0, .12);
133
+ --cem-input-focus-transition: all 280ms cubic-bezier(0.4, 0, 0.2, 1);
134
+
135
+ &:has(input:invalid,input:user-invalid,input:out-of-range, .warn>*:not(:empty) )
136
+ { --cem-filled-text-field-label-text-color: var(--alert-color,red);
137
+ --cem-input-outline-color:var(--cem-filled-text-field-label-text-color);
138
+ --cem-input-outline: inset 0 -1px 0 var(--cem-input-outline-color);
139
+ --cem-outline-color-focus: var(--cem-input-outline-color);
140
+ color: var(--cem-filled-text-field-label-text-color);
141
+ .supporting{ display: none; }
142
+ }
143
+ &>label
144
+ { display: flex; flex: 1; gap: 0.5rem;
145
+ padding: 0.5rem 1rem;
146
+ background-color: var(--cem-filled-text-field-container-color, var(--cem-app-surface-variant));
147
+ &:hover
148
+ { --cem-filled-text-field-container-color: var(--cem-filled-text-field-container-color-hover,silver);
149
+ --cem-input-outline-color:var(--text-color,black);
150
+ box-shadow: inset 0 -1px 0 var(--cem-input-outline-color,black);
151
+ color:var(--text-color,black)
152
+ }
153
+ box-shadow: var(--cem-input-outline);
154
+ transition: var(--drop-transition);
155
+ box-sizing: border-box;
156
+ min-height: 3.5rem;
157
+ color: var(--cem-filled-text-field-label-text-color);
158
+ position: relative;
159
+ &>.entry{ display: flex;flex-direction: column; justify-content: center;flex:1; }
160
+ label{display: flex;}
161
+ input
162
+ { background: none; padding: var(--input-padding);
163
+ &,&:focus,&:focus-visible{ border: none; outline: none; }
164
+ &:placeholder-shown{ border: none; outline:none; }
165
+ &[value=""]{ height: 0; }
166
+ &:focus,&:focus-visible,&[placeholder*=""]{ height: auto; }
167
+
168
+ color: var(--cem-filled-text-field-input-text-color, var(--cem-app-on-surface));
169
+ caret-color: var(--cem-filled-text-field-caret-color, var(--cem-app-primary));
170
+ font-size: 1rem;
171
+ transition: var(--drop-transition);
172
+ }
173
+ &:after{ display: block; width: 0; height: 0; content: ' ';
174
+ left:0;
175
+ transition: var(--cem-input-focus-transition);
176
+ position: absolute; align-self: center;
177
+ bottom: var(--cem-focus-outline-height);
178
+ }
179
+ }
180
+ &:focus-within
181
+ {
182
+ &> label
183
+ { font-size: small; justify-content: space-between;
184
+ color: var(--cem-outline-color-focus);
185
+ input{ caret-color: var(--cem-outline-color-focus); }
186
+ &:after{ width: 100%; height: var(--cem-focus-outline-height);
187
+ left:0;
188
+ background: none;
189
+ box-shadow: 0 var(--cem-focus-outline-height) 0 var(--cem-outline-color-focus);
190
+ align-self: center;
191
+ transition: var(--cem-input-focus-transition);
192
+ }
193
+ }
194
+ }
195
+ label:has( input:not([value=""]) ){ font-size: small; justify-content: space-between;}
196
+ slice{display: none;}
197
+ .warn,.supporting
198
+ {
199
+ padding: 0.25rem 1rem;
200
+ font-size: var(--cem-form-field-subscript-text-size, var(--cem-sys-body-small-size));
201
+ }
202
+ [slot="trailing"],[slot="leading"]{display: flex;}
203
+ }
204
+ </style>
205
+ <label>
206
+ <slot name="leading">
207
+ <if test="$leading">
208
+ <cem-icon image="{$leading}"></cem-icon>
209
+ </if>
210
+ </slot>
211
+ <div class="entry">
212
+ <slot name="label">
213
+ <if test="$label">
214
+ <span class="label">{$label}</span>
215
+ </if>
216
+ </slot>
217
+ <slot name="input">
218
+ <xhtml:input
219
+ type="{$type}"
220
+ value="{/datadom/attributes/value }"
221
+ slice="selected" slice-event="input"
222
+ size="2"
223
+ >
224
+ <if test="hasBoolAttribute($required)" ><attribute name="required" >{$required }</attribute></if>
225
+ <if test="hasBoolAttribute($disabled)" ><attribute name="disabled" >{$disabled }</attribute></if>
226
+ <if test="hasBoolAttribute($multiple)" ><attribute name="multiple" >{$multiple }</attribute></if>
227
+ <if test="hasBoolAttribute($readonly)" ><attribute name="readonly" >{$readonly }</attribute></if>
228
+ <if test="hasBoolAttribute($incremental)" ><attribute name="incremental" >{$incremental }</attribute></if>
229
+ <if test="$max" ><attribute name="max" >{$max }</attribute></if>
230
+ <if test="$maxlength" ><attribute name="maxlength" >{$maxlength }</attribute></if>
231
+ <if test="$min" ><attribute name="min" >{$min }</attribute></if>
232
+ <if test="$minlength" ><attribute name="minlength" >{$minlength }</attribute></if>
233
+ <if test="$size" ><attribute name="size" >{$size }</attribute></if>
234
+ <if test="$step" ><attribute name="step" >{$step }</attribute></if>
235
+ <if test="$tabindex" ><attribute name="tabindex" >{$tabindex }</attribute></if>
236
+ <if test="$autocapitalize" ><attribute name="autocapitalize" >{$autocapitalize }</attribute></if>
237
+ <if test="$autocomplete" ><attribute name="autocomplete" >{$autocomplete }</attribute></if>
238
+ <if test="$form" ><attribute name="form" >{$form }</attribute></if>
239
+ <if test="$id" ><attribute name="id" >{$id }</attribute></if>
240
+ <if test="$list" ><attribute name="list" >{$list }</attribute></if>
241
+ <if test="$name" ><attribute name="name" >{$name }</attribute></if>
242
+ <if test="$pattern" ><attribute name="pattern" >{$pattern }</attribute></if>
243
+ <if test="$placeholder" ><attribute name="placeholder" >{$placeholder }</attribute></if>
244
+ <if test="$title" ><attribute name="title" >{$title }</attribute></if>
245
+
246
+ <slice name="focused" slice-event="blur" slice-value="0"></slice>
247
+ <slice name="focused" slice-event="focus" slice-value="1"></slice>
248
+ </xhtml:input>
249
+ </slot>
250
+ </div>
251
+ <slot name="trailing">
252
+ <if test="$trailing">
253
+ <cem-icon image="{$trailing}"></cem-icon>
254
+ </if>
255
+ </slot>
256
+ </label>
257
+ <div class="supporting">
258
+ <slot name="supporting">
259
+ <if test="$supporting">
260
+ {$supporting}
261
+ </if>
262
+ </slot>
263
+ </div>
264
+ <div class="warn">
265
+ <slot name="warn">{//warn}</slot>
266
+ </div>
267
+ </template>
268
+ </custom-element>
269
+
270
+ <custom-element tag="cem-demo-input-types" hidden>
271
+ <template>
272
+ <attribute name="value" select="//type"></attribute>
273
+ <label>Type:
274
+ <select slice="type">
275
+ <option value="text" > text </option>
276
+ <option value="date" > date </option>
277
+ <option value="datetime-local"> datetime-local </option>
278
+ <option value="email" > email </option>
279
+ <option value="month" > month </option>
280
+ <option value="number" > number </option>
281
+ <option value="password" > password </option>
282
+ <option value="tel" > tel </option>
283
+ <option value="text" > text </option>
284
+ <option value="time" > time </option>
285
+ <option value="url" > url </option>
286
+ <option value="week" > week </option>
287
+ <optgroup label="other types do not make a sense for cem-input">
288
+ <option value="button" > button </option>
289
+ <option value="checkbox" > checkbox </option>
290
+ <option value="color" > color </option>
291
+ <option value="file" > file </option>
292
+ <option value="hidden" > hidden </option>
293
+ <option value="image" > image </option>
294
+ <option value="radio" > radio </option>
295
+ <option value="range" > range </option>
296
+ <option value="reset" > reset </option>
297
+ <option value="search" > search </option>
298
+ <option value="submit" > submit </option>
299
+ </optgroup>
300
+ </select>
301
+ </label>
302
+ </template>
303
+ </custom-element>
304
+
305
+ <custom-element tag="cem-demo-cb">
306
+ <template>
307
+ <attribute name="slice" ></attribute>
308
+ <attribute name="value" select="//val"></attribute>
309
+ <label><input type="checkbox" value="{$slice}" slice="val" /> {$slice} </label>
310
+ </template>
311
+ </custom-element>
312
+
313
+ <custom-element tag="cem-demo-tx">
314
+ <template>
315
+ <attribute name="slice" ></attribute>
316
+ <attribute name="value" select="//val"></attribute>
317
+ <style>input,label{ width: 100%; } </style>
318
+ <label>{$slice}<input slice="val" value="{$value}"/></label>
319
+ </template>
320
+ </custom-element>
321
+
322
+ <custom-element tag="cem-demo-in">
323
+ <template>
324
+ <attribute name="slice" ></attribute>
325
+ <attribute name="value" select="//val"></attribute>
326
+ <style>input,label{ width: 100%; } </style>
327
+ <label>{$slice}<input slice="val" type="number"/></label>
328
+ </template>
329
+ </custom-element>
330
+
331
+ <html-demo-element legend="Most features" description="Focus to see the cursor in input with label shifted upward "
332
+ class="flat-attr"
333
+ >
334
+ <template>
335
+ <cem-input label="String field with leading and trailing icon "
336
+ placeholder="type here"
337
+ supporting="required field. Clear to see placeholder."
338
+ leading="search"
339
+ trailing="close"
340
+ ></cem-input>
341
+ </template>
342
+ </html-demo-element>
343
+
344
+ <html-demo-element legend="No value" description="Focus to see the cursor in input with label shifted upward ">
345
+ <template>
346
+ <cem-input label="String field" ></cem-input>
347
+ </template>
348
+ </html-demo-element>
349
+
350
+ <html-demo-element legend="No value with placeholder" description="focus to see the placeholder text" class="flat-attr">
351
+ <template>
352
+ <cem-input label="Number" type="number" placeholder="Enter the numeric value">
353
+ </cem-input>
354
+ </template>
355
+ </html-demo-element>
356
+
357
+ <html-demo-element legend="Value defined" description="The value should be visible" >
358
+ <template>
359
+ <cem-input label="Text" type="text" value="abc"></cem-input>
360
+ </template>
361
+ </html-demo-element>
362
+
363
+ <html-demo-element legend="leading and trailing slots" >
364
+ <div slot="description"><code>leading</code> slot inserted before input,
365
+ <code>trailing</code> slot injected after</div>
366
+
367
+ <template>
368
+ <cem-input label="slots sample" type="text" >
369
+ <div slot="leading"><cem-icon image="edit"></cem-icon></div>
370
+ <div slot="trailing">
371
+ <cem-icon image="👁"></cem-icon>
372
+ ️<cem-icon image="close"></cem-icon>️
373
+ </div>
374
+ </cem-input>
375
+ </template>
376
+ </html-demo-element>
377
+
378
+
379
+ <html-demo-element legend="password with trailing slots interaction" >
380
+ <div slot="description"><code>trailing</code> and other slots can become functional </div>
381
+ <p>Those slots can be used for error or hint UI; persistent or triggered by hover/focus.<br/>
382
+ <a href="./autocomplete.html">cem-autocomplete</a> uses <code>trailing</code> slot for
383
+ <a href="./menu.html">menu</a> with suggestions.
384
+ </p>
385
+ <p>Click in input field to see the focus leading icon <cem-icon image="edit"></cem-icon>
386
+ changed to <cem-icon image="history_edu"></cem-icon></p>
387
+ <template>
388
+ <custom-element>
389
+ <template id="cem-password">
390
+ <attribute name="value" select="//password[//password/event]"></attribute>
391
+
392
+ <style>
393
+ .input-focused{ display: none; }
394
+ .input-unfocused{ display: inline-flex; }
395
+ &:focus-within{
396
+ .input-focused{ display: inline-flex; }
397
+ .input-unfocused{ display:none; }
398
+ }
399
+ .eye-contailer
400
+ { display: flex;
401
+ align-items: center;
402
+ }
403
+
404
+ [type="checkbox"],.visible-ico{ display: none; }
405
+
406
+ &:has([type="checkbox"]:checked)
407
+ {
408
+ .visible-ico{ display: inline-flex; }
409
+ .invisible-ico{ display: none; }
410
+ }
411
+ .invisible-ico
412
+ { color:var(--cem-action-primary-color);
413
+ background-color: var(--cem-action-primary-background);
414
+ transition: var(--cem-action-transition);
415
+ &:hover{
416
+ background-color: var(--cem-action-primary-background-hover);
417
+ box-shadow: var(--cem-action-box-shadow-hover); }
418
+ &:focus{ background-color: var(--cem-action-primary-background-focus); }
419
+ &:active{ background-color: var(--cem-action-primary-background-active); }
420
+ }
421
+ </style>
422
+ <input type="checkbox" slice="visible" id="visible-cb" />
423
+ <cem-input label="password sample" slice="password" value="{//password[//password/event]}">
424
+ <attribute name="type"><if test="not(//visible='on')">password</if></attribute>
425
+ <div slot="leading">
426
+ <cem-icon image="history_edu" class="input-focused"></cem-icon>
427
+ <cem-icon image="edit" class="input-unfocused"></cem-icon>
428
+ </div>
429
+ <div slot="trailing">
430
+ <label class="eye-contailer" for="visible-cb">
431
+ <cem-icon image="visibility" class="visible-ico" tabindex="0"></cem-icon>
432
+ <cem-icon image="visibility_off" class="invisible-ico" tabindex="0"></cem-icon>
433
+ </label>
434
+ </div>
435
+ </cem-input>
436
+ </template>
437
+ </custom-element>
438
+ </template>
439
+ </html-demo-element>
440
+
441
+
442
+ <html-demo-element legend="Native error support" >
443
+ <div slot="descrition">Native <a href="https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation">
444
+ Form validation</a> is supported. See also <a href="../../custom-element/demo/form.html"><code>custom-element</code> form handling</a> </div>
445
+ <div><code>required</code> attribute would trigger the system message if the field is empty.</div>
446
+ <div>
447
+ Press Next button to see the browser error popup.</div>
448
+ <template>
449
+ <form>
450
+ <cem-input required></cem-input>
451
+ <button>Next</button>
452
+ </form>
453
+ </template>
454
+ </html-demo-element>
455
+
456
+ <html-demo-element legend="Error message">
457
+ <div slot="description"><code>warn</code> attribute and slot is used for warning message</div>
458
+ <div slot="description"><code>supporting</code> attribute and slot is used for supplementary message,
459
+ hidden when <code>warn</code> is not empty </div>
460
+ <template>
461
+
462
+ <cem-input warn="warning message" label="text" value="abc"></cem-input>
463
+ <hr/>
464
+ <cem-input supporting="complimentary message" label="text" value="abc"></cem-input>
465
+ <hr/>
466
+ <cem-input warn="warning message" supporting="complimentary message is overridden by warning" label="text" value="abc"></cem-input>
467
+ <hr/>
468
+ <cem-input warn="warning message" label="text" value="abc">
469
+ <div slot="warn"><cem-icon image="report" size="small"></cem-icon><b>abc</b> is not valid value</div>
470
+ </cem-input>
471
+ </template>
472
+ </html-demo-element>
473
+
474
+
475
+ <html-demo-element legend="INPUT field attributes playground" id="play" style="flex: 2 2 80vw;">
476
+ <div slot="descrition">
477
+ <p> Underlying implementation uses
478
+ <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">HTML input</a>.
479
+ All its attributes are supported.
480
+ </p>
481
+ <custom-element >
482
+ <template>
483
+ <style>
484
+ &>dce-root
485
+ { display: flex; flex-wrap: wrap; gap: 2rem; align-items: center;
486
+ &>*{ flex: 1 1 10rem; }
487
+ }
488
+ label{ display: block; }
489
+ </style>
490
+ <cem-demo-cb slice="disabled" ></cem-demo-cb>
491
+ <cem-demo-cb slice="multiple" ></cem-demo-cb>
492
+ <cem-demo-cb slice="readonly" ></cem-demo-cb>
493
+ <cem-demo-cb slice="required" ></cem-demo-cb>
494
+ <cem-demo-cb slice="incremental" ></cem-demo-cb>
495
+ <cem-demo-in slice="max" ></cem-demo-in>
496
+ <cem-demo-in slice="maxlength" ></cem-demo-in>
497
+ <cem-demo-in slice="min" ></cem-demo-in>
498
+ <cem-demo-in slice="minlength" ></cem-demo-in>
499
+ <cem-demo-in slice="size" ></cem-demo-in>
500
+ <cem-demo-in slice="step" ></cem-demo-in>
501
+ <cem-demo-in slice="tabindex" ></cem-demo-in>
502
+ <cem-demo-tx slice="autocapitalize" title="on sentences off none words characters "></cem-demo-tx>
503
+ <cem-demo-tx slice="autocomplete" ></cem-demo-tx>
504
+ <cem-demo-tx slice="form" ></cem-demo-tx>
505
+ <cem-demo-tx slice="id" ></cem-demo-tx>
506
+ <cem-demo-tx slice="list" ></cem-demo-tx>
507
+ <cem-demo-tx slice="name" ></cem-demo-tx>
508
+ <cem-demo-tx slice="pattern" ></cem-demo-tx>
509
+ <cem-demo-tx slice="placeholder" ></cem-demo-tx>
510
+ <cem-demo-tx slice="title" ></cem-demo-tx>
511
+ <cem-demo-tx slice="value" value="abc" ></cem-demo-tx>
512
+ &bull;
513
+ <cem-demo-tx slice="label" title="label text" ></cem-demo-tx>
514
+ <cem-demo-tx slice="leading" title="leading icon" ></cem-demo-tx>
515
+ <cem-demo-tx slice="trailing" title="trailing icon" ></cem-demo-tx>
516
+ <cem-demo-tx slice="supporting" title="supporting text" ></cem-demo-tx>
517
+
518
+ <cem-demo-input-types slice="type"></cem-demo-input-types>
519
+
520
+ <form action="#play">
521
+ <cem-input type="{//type}" >
522
+ <if test="//disabled = 'disabled'" ><attribute name="disabled" ></attribute></if>
523
+ <if test="//multiple = 'multiple'" ><attribute name="multiple" ></attribute></if>
524
+ <if test="//readonly = 'readonly'" ><attribute name="readonly" ></attribute></if>
525
+ <if test="//required = 'required'" ><attribute name="required" ></attribute></if>
526
+ <if test="//incremental = 'incremental'" ><attribute name="incremental" ></attribute></if>
527
+ <if test="not(//max = '')" ><attribute name="max" >{//max }</attribute></if>
528
+ <if test="not(//maxlength = '')" ><attribute name="maxlength" >{//maxlength }</attribute></if>
529
+ <if test="not(//min = '')" ><attribute name="min" >{//min }</attribute></if>
530
+ <if test="not(//minlength = '')" ><attribute name="minlength" >{//minlength }</attribute></if>
531
+ <if test="not(//size = '')" ><attribute name="size" >{//size }</attribute></if>
532
+ <if test="not(//step = '')" ><attribute name="step" >{//step }</attribute></if>
533
+ <if test="not(//tabindex = '')" ><attribute name="tabindex" >{//tabindex }</attribute></if>
534
+ <if test="not(//autocapitalize='')" ><attribute name="autocapitalize" >{//autocapitalize }</attribute></if>
535
+ <if test="not(//autocomplete = '')" ><attribute name="autocomplete" >{//autocomplete }</attribute></if>
536
+ <if test="not(//form = '')" ><attribute name="form" >{//form }</attribute></if>
537
+ <if test="not(//id = '')" ><attribute name="id" >{//id }</attribute></if>
538
+ <if test="not(//list = '')" ><attribute name="list" >{//list }</attribute></if>
539
+ <if test="not(//name = '')" ><attribute name="name" >{//name }</attribute></if>
540
+ <if test="not(//pattern = '')" ><attribute name="pattern" >{//pattern }</attribute></if>
541
+ <if test="not(//placeholder = '')" ><attribute name="placeholder" >{//placeholder }</attribute></if>
542
+ <if test="not(//title = '')" ><attribute name="title" >{//title }</attribute></if>
543
+ <if test="not(//value = '')" ><attribute name="value" >{//value }</attribute></if>
544
+ <if test="not(//label = '')" ><attribute name="label" >{//label }</attribute></if>
545
+ <if test="not(//leading = '')" ><attribute name="leading" >{//leading }</attribute></if>
546
+ <if test="not(//trailing = '')" ><attribute name="trailing" >{//trailing }</attribute></if>
547
+ <if test="not(//supporting = '')" ><attribute name="supporting" >{//supporting }</attribute></if>
548
+ </cem-input>
549
+ <button>Next</button>
550
+ <if test="//disabled = 'disabled'" >//disabled = 'disabled' </if>
551
+
552
+ </form>
553
+ </template>
554
+ </custom-element>
555
+
556
+ </div>
557
+ <template>
558
+ </template>
559
+ </html-demo-element>
560
+
561
+ </main>
562
+ <footer>
563
+ <hr/>
564
+ <a href="../../LICENSE"> Code and documentation licensed under an Apache License 2.0 </a>
565
+ </footer>
566
+ <!--<script type="module" src="./html-demo-element.js"></script>-->
567
+ <script type="module" src="https://unpkg.com/html-demo-element@1/html-demo-element.js"></script>
568
+
569
+ </body>
571
570
  </html>