|
8 | 8 |
|
9 | 9 | <script src="../../assets/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
|
10 | 10 |
|
| 11 | + <script type="module"> |
| 12 | + import '@polymer/iron-demo-helpers/demo-snippet.js'; |
| 13 | + import '@polymer/iron-demo-helpers/demo-pages-shared-styles.js'; |
| 14 | + </script> |
| 15 | + |
| 16 | + |
11 | 17 | <link href="../resources/vars.css" rel="stylesheet">
|
| 18 | + <link href="../resources/demo.css" rel="stylesheet"> |
12 | 19 | <style>
|
13 | 20 | .dynamic {
|
14 | 21 | background: #76ff03;
|
15 | 22 | }
|
16 | 23 |
|
17 |
| - xf-input{ |
| 24 | + xf-input { |
18 | 25 | display: block;
|
19 |
| - padding:10px 0; |
| 26 | + padding: 10px 0; |
20 | 27 | }
|
| 28 | + |
21 | 29 | xf-input[required]:after {
|
22 | 30 | content: "*";
|
23 | 31 | color: red;
|
24 | 32 | }
|
25 | 33 |
|
26 |
| - xf-output{ |
| 34 | + xf-output { |
27 | 35 | margin-bottom: 20px;
|
28 | 36 | }
|
29 | 37 | </style>
|
30 | 38 | </head>
|
31 | 39 | <body unresolved="unresolved">
|
32 | 40 |
|
| 41 | +<h1>Revalidation and Alerts</h1> |
33 | 42 |
|
34 |
| -<xf-form> |
35 |
| -<!-- <xf-message event="refresh-done">refresh has been done</xf-message>--> |
36 |
| - |
37 |
| - <xf-model id="model1"> |
38 |
| - <xf-instance> |
39 |
| - <data> |
40 |
| - <a>A</a> |
41 |
| - <b>B</b> |
42 |
| - <c>C</c> |
43 |
| - </data> |
44 |
| - </xf-instance> |
45 |
| - |
46 |
| - |
47 |
| - <xf-bind ref="a" constraint="string-length(.) = 1"></xf-bind> |
48 |
| - <xf-bind ref="b" constraint="string-length(.) = 1" alert="string must be exactly one character long"></xf-bind> |
49 |
| - <xf-bind ref="c" constraint="string-length(.) = 1"> |
50 |
| - <xf-alert><b>string must be exactly 1 character long</b></xf-alert> |
51 |
| - </xf-bind> |
52 |
| - <!-- |
53 |
| - <xf-bind ref="c" required=".=C" relevant="depends(../b) = 'B'"></xf-bind> |
54 |
| - --> |
55 |
| - |
56 |
| - |
57 |
| - </xf-model> |
58 |
| - <xf-group collapse="true"> |
59 |
| - |
60 |
| - |
61 |
| - <h1 class="{class}"> |
62 |
| - Revalidation</h1> |
| 43 | +<demo-snippet> |
| 44 | + <template> |
63 | 45 |
|
64 |
| - <xf-output id="output" ref="a"> |
65 |
| - <xf-label>a-label</xf-label> |
66 |
| - <xf-alert>Constraint <b>not</b> valid</xf-alert> |
67 |
| - <xf-hint>must be one character long</xf-hint> |
68 |
| - </xf-output> |
| 46 | + <xf-form> |
69 | 47 |
|
70 |
| -<!-- |
71 |
| - <xf-output id="output" ref="b">x |
72 |
| - <xf-label>b-label</xf-label> |
73 |
| - </xf-output> |
74 |
| - <xf-output id="output" ref="c"> |
75 |
| - <xf-label>c-label</xf-label> |
76 |
| - </xf-output> |
77 |
| ---> |
| 48 | + <xf-model id="model1"> |
| 49 | + <xf-instance> |
| 50 | + <data> |
| 51 | + <a>A</a> |
| 52 | + <b>B</b> |
| 53 | + <c>C</c> |
| 54 | + </data> |
| 55 | + </xf-instance> |
78 | 56 |
|
79 |
| - <xf-input label="A-label" ref="a"> |
80 |
| - <xf-alert>Constraint not valid</xf-alert> |
81 |
| - <xf-hint>must be one character long</xf-hint> |
82 |
| - </xf-input> |
83 | 57 |
|
| 58 | + <xf-bind ref="a" constraint="string-length(.) = 1"></xf-bind> |
| 59 | + <xf-bind ref="b" constraint="string-length(.) = 1" |
| 60 | + alert="string must be exactly one character long"></xf-bind> |
| 61 | + <xf-bind ref="c" constraint="string-length(.) = 1"> |
| 62 | + <xf-alert><b>string must be exactly 1 character long</b></xf-alert> |
| 63 | + </xf-bind> |
| 64 | + </xf-model> |
| 65 | + <xf-group collapse="true"> |
84 | 66 |
|
85 |
| - <xf-input label="B-label" ref="b"></xf-input> |
| 67 | + <xf-output id="output" ref="a"> |
| 68 | + <xf-label>a-label</xf-label> |
| 69 | + <xf-alert>Constraint <b>not</b> valid</xf-alert> |
| 70 | + <xf-hint>must be one character long</xf-hint> |
| 71 | + </xf-output> |
86 | 72 |
|
87 |
| - <xf-input label="C" ref="c"></xf-input> |
| 73 | + <xf-input label="A-label" ref="a"> |
| 74 | + <xf-alert>Constraint not valid</xf-alert> |
| 75 | + <xf-hint>must be one character long</xf-hint> |
| 76 | + </xf-input> |
88 | 77 |
|
| 78 | + <xf-input label="B-label" ref="b"></xf-input> |
89 | 79 |
|
90 |
| - </xf-group> |
91 |
| -</xf-form> |
| 80 | + <xf-input label="C" ref="c"></xf-input> |
92 | 81 |
|
| 82 | + </xf-group> |
| 83 | + </xf-form> |
| 84 | + </template> |
| 85 | +</demo-snippet> |
93 | 86 | <script type="module" src="../index.js"></script>
|
94 | 87 |
|
95 | 88 | </body>
|
|
0 commit comments