@txstate-mws/svelte-components 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/.eslintrc.cjs +37 -0
  2. package/README.md +33 -14
  3. package/docs/stores.md +1 -1
  4. package/package.json +24 -74
  5. package/playwright.config.js +112 -0
  6. package/src/app.html +14 -0
  7. package/src/global.d.ts +1 -0
  8. package/src/lib/actions/buttonify.ts +27 -0
  9. package/src/lib/actions/glue.ts +96 -0
  10. package/src/lib/actions/index.ts +7 -0
  11. package/src/lib/actions/offset.ts +43 -0
  12. package/src/lib/actions/portal.ts +13 -0
  13. package/src/lib/actions/resize.ts +72 -0
  14. package/src/lib/actions/sticky.ts +105 -0
  15. package/src/lib/actions/stickyfixed.ts +160 -0
  16. package/src/lib/components/Card.svelte +25 -0
  17. package/src/lib/components/CardLayout.svelte +188 -0
  18. package/{dist/ts → src/lib}/components/CollapsingTable.svelte +6 -5
  19. package/{dist/ts → src/lib}/components/ConditionalWrapper.svelte +0 -0
  20. package/{dist/ts → src/lib}/components/FocusLock.svelte +7 -6
  21. package/{dist/ts → src/lib}/components/Modal.svelte +5 -4
  22. package/src/lib/components/MultiSelect.svelte +174 -0
  23. package/{dist/ts → src/lib}/components/PopupMenu.svelte +22 -16
  24. package/{dist/ts → src/lib}/components/ScreenReaderOnly.svelte +2 -2
  25. package/src/lib/components/index.ts +9 -0
  26. package/src/lib/index.ts +4 -0
  27. package/src/lib/types/CardLayout.ts +14 -0
  28. package/src/lib/types/CollapsingTable.ts +8 -0
  29. package/src/lib/types/PopupMenu.ts +5 -0
  30. package/src/lib/types/index.ts +3 -0
  31. package/src/lib/util/bodyoffset.ts +77 -0
  32. package/src/lib/util/index.ts +3 -0
  33. package/src/lib/util/repositioned.ts +91 -0
  34. package/src/lib/util/util.ts +36 -0
  35. package/src/routes/__layout.svelte +125 -0
  36. package/src/routes/actions/index.svelte +1 -0
  37. package/src/routes/actions/offset.svelte +4 -0
  38. package/src/routes/actions/offsetdebounce.svelte +4 -0
  39. package/src/routes/actions/resize.svelte +4 -0
  40. package/src/routes/actions/resizedebounce.svelte +4 -0
  41. package/src/routes/actions/sticky.svelte +4 -0
  42. package/src/routes/cards/index.svelte +4 -0
  43. package/src/routes/cards/preserve.svelte +4 -0
  44. package/src/routes/collapsingtable/index.svelte +4 -0
  45. package/src/routes/collapsingtable/stickyheader.svelte +4 -0
  46. package/src/routes/index.svelte +2 -0
  47. package/src/routes/modal.svelte +4 -0
  48. package/src/routes/multiselect.svelte +4 -0
  49. package/src/routes/popupmenu/body.svelte +4 -0
  50. package/src/routes/popupmenu/complex.svelte +4 -0
  51. package/src/routes/popupmenu/empty.svelte +5 -0
  52. package/src/routes/popupmenu/index.svelte +4 -0
  53. package/src/routes/popupmenu/parent.svelte +4 -0
  54. package/src/routes/popupmenu/scrollable.svelte +27 -0
  55. package/src/routes/popupmenu/showselected.svelte +4 -0
  56. package/src/test/Cards.svelte +64 -0
  57. package/{dist/ts/tests/CollapsingTable → src/test}/CollapsingTableTest.svelte +2 -2
  58. package/{dist/ts/tests/Modal → src/test}/ModalTest.svelte +3 -3
  59. package/src/test/MultiSelectTest.svelte +26 -0
  60. package/{dist/ts/tests/Actions → src/test}/Offset.svelte +2 -4
  61. package/{dist/ts/tests/PopupMenu → src/test}/PopupMenuBody.svelte +1 -1
  62. package/{dist/ts/tests/PopupMenu → src/test}/PopupMenuButtonIsParent.svelte +2 -2
  63. package/{dist/ts/tests/PopupMenu → src/test}/PopupMenuComplex.svelte +2 -2
  64. package/{dist/ts/tests/PopupMenu → src/test}/PopupMenuSimple.svelte +2 -2
  65. package/{dist/ts/tests/Actions → src/test}/Resize.svelte +2 -4
  66. package/{dist/ts/tests/Actions → src/test}/Sticky.svelte +1 -1
  67. package/static/layout.css +263 -0
  68. package/svelte.config.js +15 -0
  69. package/tests/.eslintrc.cjs +19 -0
  70. package/tests/CardLayout.test.js +41 -0
  71. package/tests/CollapsingTable.test.js +37 -0
  72. package/tests/Modal.test.js +18 -0
  73. package/tests/MultiSelect.test.js +58 -0
  74. package/tests/PopupMenu.test.js +55 -0
  75. package/tests/common.js +4 -0
  76. package/tsconfig.json +31 -0
  77. package/LICENSE +0 -21
  78. package/dist/actions/buttonify.js +0 -31
  79. package/dist/actions/buttonify.js.map +0 -1
  80. package/dist/actions/glue.js +0 -87
  81. package/dist/actions/glue.js.map +0 -1
  82. package/dist/actions/index.js +0 -20
  83. package/dist/actions/index.js.map +0 -1
  84. package/dist/actions/offset.js +0 -35
  85. package/dist/actions/offset.js.map +0 -1
  86. package/dist/actions/portal.js +0 -19
  87. package/dist/actions/portal.js.map +0 -1
  88. package/dist/actions/resize.js +0 -48
  89. package/dist/actions/resize.js.map +0 -1
  90. package/dist/actions/sticky.js +0 -93
  91. package/dist/actions/sticky.js.map +0 -1
  92. package/dist/actions/stickyfixed.js +0 -166
  93. package/dist/actions/stickyfixed.js.map +0 -1
  94. package/dist/components/CollapsingTable.svelte +0 -147
  95. package/dist/components/ConditionalWrapper.svelte +0 -38
  96. package/dist/components/FocusLock.svelte +0 -105
  97. package/dist/components/Modal.svelte +0 -52
  98. package/dist/components/PopupMenu.svelte +0 -282
  99. package/dist/components/ScreenReaderOnly.svelte +0 -25
  100. package/dist/components/index.js +0 -19
  101. package/dist/components/index.js.map +0 -1
  102. package/dist/index.js +0 -17
  103. package/dist/index.js.map +0 -1
  104. package/dist/lib/activestore.js +0 -123
  105. package/dist/lib/activestore.js.map +0 -1
  106. package/dist/lib/bodyoffset.js +0 -76
  107. package/dist/lib/bodyoffset.js.map +0 -1
  108. package/dist/lib/convertedstore.js +0 -41
  109. package/dist/lib/convertedstore.js.map +0 -1
  110. package/dist/lib/derivedstore.js +0 -65
  111. package/dist/lib/derivedstore.js.map +0 -1
  112. package/dist/lib/index.js +0 -22
  113. package/dist/lib/index.js.map +0 -1
  114. package/dist/lib/repositioned.js +0 -92
  115. package/dist/lib/repositioned.js.map +0 -1
  116. package/dist/lib/safestore.js +0 -16
  117. package/dist/lib/safestore.js.map +0 -1
  118. package/dist/lib/store.js +0 -27
  119. package/dist/lib/store.js.map +0 -1
  120. package/dist/lib/substore.js +0 -47
  121. package/dist/lib/substore.js.map +0 -1
  122. package/dist/lib/util.js +0 -16
  123. package/dist/lib/util.js.map +0 -1
  124. package/dist/ts/actions/buttonify.d.ts +0 -8
  125. package/dist/ts/actions/glue.d.ts +0 -16
  126. package/dist/ts/actions/index.d.ts +0 -7
  127. package/dist/ts/actions/offset.d.ts +0 -15
  128. package/dist/ts/actions/portal.d.ts +0 -4
  129. package/dist/ts/actions/resize.d.ts +0 -16
  130. package/dist/ts/actions/sticky.d.ts +0 -33
  131. package/dist/ts/actions/stickyfixed.d.ts +0 -25
  132. package/dist/ts/components/index.d.ts +0 -6
  133. package/dist/ts/index.d.ts +0 -4
  134. package/dist/ts/lib/activestore.d.ts +0 -60
  135. package/dist/ts/lib/bodyoffset.d.ts +0 -13
  136. package/dist/ts/lib/convertedstore.d.ts +0 -16
  137. package/dist/ts/lib/derivedstore.d.ts +0 -23
  138. package/dist/ts/lib/index.d.ts +0 -9
  139. package/dist/ts/lib/repositioned.d.ts +0 -13
  140. package/dist/ts/lib/safestore.d.ts +0 -4
  141. package/dist/ts/lib/store.d.ts +0 -16
  142. package/dist/ts/lib/substore.d.ts +0 -24
  143. package/dist/ts/lib/util.d.ts +0 -2
  144. package/dist/ts/tests/Actions/Actions.stories.d.ts +0 -1
  145. package/dist/ts/tests/CollapsingTable/CollapsingTable.stories.d.ts +0 -1
  146. package/dist/ts/tests/CollapsingTable/CollapsingTable.test.d.ts +0 -1
  147. package/dist/ts/tests/Modal/Modal.stories.d.ts +0 -1
  148. package/dist/ts/tests/Modal/Modal.test.d.ts +0 -1
  149. package/dist/ts/tests/PopupMenu/PopupMenu.stories.d.ts +0 -1
  150. package/dist/ts/tests/PopupMenu/PopupMenu.test.d.ts +0 -1
  151. package/dist/ts/tests/stores/deepstore.test.d.ts +0 -1
  152. package/dist/ts/types/CollapsingTable.d.ts +0 -8
  153. package/dist/ts/types/PopupMenu.d.ts +0 -5
  154. package/dist/ts/types/index.d.ts +0 -2
  155. package/dist/types/CollapsingTable.js +0 -3
  156. package/dist/types/CollapsingTable.js.map +0 -1
  157. package/dist/types/PopupMenu.js +0 -3
  158. package/dist/types/PopupMenu.js.map +0 -1
  159. package/dist/types/index.js +0 -15
  160. package/dist/types/index.js.map +0 -1
  161. package/esm/index.js +0 -1
  162. package/esm/package.json +0 -3
@@ -0,0 +1,263 @@
1
+ :root {
2
+ --menu-width: 12rem;
3
+ }
4
+
5
+ .pure-img-responsive {
6
+ max-width: 100%;
7
+ height: auto;
8
+ }
9
+
10
+ /*
11
+ Add transition to containers so they can push in and out.
12
+ */
13
+ #layout,
14
+ #menu,
15
+ .menu-link {
16
+ -webkit-transition: all 0.2s ease-out;
17
+ -moz-transition: all 0.2s ease-out;
18
+ -ms-transition: all 0.2s ease-out;
19
+ -o-transition: all 0.2s ease-out;
20
+ transition: all 0.2s ease-out;
21
+ }
22
+
23
+ /*
24
+ This is the parent `<div>` that contains the menu and the content area.
25
+ */
26
+ #layout {
27
+ position: relative;
28
+ left: 0;
29
+ padding-left: 0;
30
+ }
31
+ #layout.active #menu {
32
+ left: var(--menu-width);
33
+ }
34
+
35
+ #layout.active .menu-link {
36
+ left: var(--menu-width);
37
+ }
38
+ /*
39
+ The content `<div>` is where all your content goes.
40
+ */
41
+ .content {
42
+ margin: 2em auto;
43
+ padding: 0 2em;
44
+ max-width: 1200px;
45
+ margin-bottom: 50px;
46
+ line-height: 1.6em;
47
+ }
48
+
49
+ .header {
50
+ margin: 0;
51
+ color: #333;
52
+ text-align: center;
53
+ padding: 2.5em 2em 0;
54
+ border-bottom: 1px solid #eee;
55
+ }
56
+ .header h1 {
57
+ margin: 0.2em 0;
58
+ font-size: 3em;
59
+ font-weight: 300;
60
+ }
61
+ .header h2 {
62
+ font-weight: 300;
63
+ color: #ccc;
64
+ padding: 0;
65
+ margin-top: 0;
66
+ }
67
+
68
+ .content-subhead {
69
+ margin: 50px 0 20px 0;
70
+ font-weight: 300;
71
+ color: #888;
72
+ }
73
+
74
+
75
+
76
+ /*
77
+ The `#menu` `<div>` is the parent `<div>` that contains the `.pure-menu` that
78
+ appears on the left side of the page.
79
+ */
80
+
81
+ #menu {
82
+ margin-left: calc(-1 * var(--menu-width));
83
+ width: var(--menu-width);
84
+ position: fixed;
85
+ top: 0;
86
+ left: 0;
87
+ bottom: 0;
88
+ z-index: 1000; /* so the menu or its navicon stays above all content */
89
+ background: #191818;
90
+ overflow-y: auto;
91
+ }
92
+ /*
93
+ All anchors inside the menu should be styled like this.
94
+ */
95
+ #menu a {
96
+ color: #999;
97
+ border: none;
98
+ padding: 0.6em;
99
+ }
100
+
101
+ /*
102
+ Remove all background/borders, since we are applying them to #menu.
103
+ */
104
+ #menu .pure-menu,
105
+ #menu .pure-menu ul {
106
+ border: none;
107
+ background: transparent;
108
+ }
109
+
110
+ /*
111
+ Add that light border to separate items into groups.
112
+ */
113
+ #menu .pure-menu ul,
114
+ #menu .pure-menu .menu-item-divided {
115
+ border-top: 1px solid #666;
116
+ }
117
+ /*
118
+ Change color of the anchor links on hover/focus.
119
+ */
120
+ #menu .pure-menu li a:hover,
121
+ #menu .pure-menu li a:focus {
122
+ background: #333;
123
+ }
124
+ #menu .pure-menu li.pure-menu-selected a:hover,
125
+ #menu .pure-menu li.pure-menu-selected a:focus,
126
+ #menu .pure-menu li.pure-menu-subselected a:hover,
127
+ #menu .pure-menu li.pure-menu-subselected a:focus {
128
+ background: inherit;
129
+ }
130
+
131
+
132
+ #menu .pure-menu-parent {
133
+ border-top: 1px solid #666;
134
+ }
135
+ #menu .pure-menu-parent a {
136
+ color: #fff;
137
+ }
138
+ /*
139
+ This styles the selected menu item `<li>`.
140
+ */
141
+ #menu .pure-menu-selected {
142
+ background: #1f8dd6;
143
+ }
144
+ /*
145
+ This styles a link within a selected menu item `<li>`.
146
+ */
147
+ #menu .pure-menu-selected a {
148
+ color: #fff;
149
+ }
150
+
151
+ #menu .pure-menu-parent.pure-menu-subselected {
152
+ background: #8bb6d3;
153
+ }
154
+ #menu .pure-menu-parent.pure-menu-subselected a {
155
+ color: black;
156
+ }
157
+
158
+ /*
159
+ This styles the menu heading.
160
+ */
161
+ #menu .pure-menu-heading {
162
+ font-size: 110%;
163
+ color: #fff;
164
+ margin: 0;
165
+ }
166
+
167
+ /* -- Dynamic Button For Responsive Menu -------------------------------------*/
168
+
169
+ /*
170
+ The button to open/close the Menu is custom-made and not part of Pure. Here's
171
+ how it works:
172
+ */
173
+
174
+ /*
175
+ `.menu-link` represents the responsive menu toggle that shows/hides on
176
+ small screens.
177
+ */
178
+ .menu-link {
179
+ position: fixed;
180
+ display: block; /* show this only on small screens */
181
+ top: 0;
182
+ left: 0; /* "#menu width" */
183
+ background: #000;
184
+ background: rgba(0,0,0,0.7);
185
+ font-size: 10px; /* change this value to increase/decrease button size */
186
+ z-index: 10;
187
+ width: 3em;
188
+ height: 2em;
189
+ padding: 2.1em 1.6em;
190
+ }
191
+
192
+ .menu-link:hover,
193
+ .menu-link:focus {
194
+ background: #000;
195
+ }
196
+
197
+ .menu-link span {
198
+ display: block;
199
+ position: absolute;
200
+ top: 50%;
201
+ left: 50%;
202
+ transform: translate(-50%, -50%);
203
+ }
204
+
205
+ .menu-link span,
206
+ .menu-link span:before,
207
+ .menu-link span:after {
208
+ background-color: #fff;
209
+ pointer-events: none;
210
+ width: 2em;
211
+ height: 0.2em;
212
+ }
213
+
214
+ .menu-link span:before,
215
+ .menu-link span:after {
216
+ position: absolute;
217
+ margin-top: -0.6em;
218
+ content: " ";
219
+ }
220
+
221
+ .menu-link span:after {
222
+ margin-top: 0.6em;
223
+ }
224
+
225
+
226
+ /* -- Responsive Styles (Media Queries) ------------------------------------- */
227
+
228
+ /*
229
+ Hides the menu at `48em`, but modify this based on your app's needs.
230
+ */
231
+ @media (min-width: 48em) {
232
+
233
+ .header,
234
+ .content {
235
+ padding-left: 2em;
236
+ padding-right: 2em;
237
+ }
238
+
239
+ #layout {
240
+ padding-left: var(--menu-width); /* left col width "#menu" */
241
+ left: 0;
242
+ }
243
+ #menu {
244
+ left: var(--menu-width);
245
+ }
246
+
247
+ .menu-link {
248
+ display: none;
249
+ }
250
+ }
251
+
252
+ @media (max-width: 48em) {
253
+ /* Only apply this when the window is small. Otherwise, the following
254
+ case results in extra padding on the left:
255
+ * Make the window small.
256
+ * Tap the menu to trigger the active state.
257
+ * Make the window large again.
258
+ */
259
+ #layout.active {
260
+ position: relative;
261
+ left: var(--menu-width);
262
+ }
263
+ }
@@ -0,0 +1,15 @@
1
+ import adapter from '@sveltejs/adapter-auto';
2
+ import preprocess from 'svelte-preprocess';
3
+
4
+ /** @type {import('@sveltejs/kit').Config} */
5
+ const config = {
6
+ // Consult https://github.com/sveltejs/svelte-preprocess
7
+ // for more information about preprocessors
8
+ preprocess: preprocess(),
9
+
10
+ kit: {
11
+ adapter: adapter()
12
+ }
13
+ };
14
+
15
+ export default config;
@@ -0,0 +1,19 @@
1
+ module.exports = {
2
+ root: true,
3
+ parser: undefined,
4
+ extends: 'standard',
5
+ plugins: [],
6
+ ignorePatterns: [],
7
+ overrides: [],
8
+ settings: {},
9
+ rules: {
10
+ },
11
+ parserOptions: {
12
+ sourceType: 'module'
13
+ },
14
+ env: {
15
+ browser: true,
16
+ es2017: true,
17
+ node: true
18
+ }
19
+ }
@@ -0,0 +1,41 @@
1
+ import { test, expect } from '@playwright/test'
2
+ import { goto } from './common.js'
3
+
4
+ test.describe('Image Layout', () => {
5
+ test.beforeEach(async ({ page }) => {
6
+ await goto(page, '/cards')
7
+ })
8
+
9
+ test('should show all 9 cards', async ({ page }) => {
10
+ const cards = page.locator('.cardlayout-card')
11
+ await expect(cards).toHaveCount(9)
12
+ })
13
+ test('should place each card further from the top than the last', async ({ page }) => {
14
+ const cards = page.locator('.cardlayout-card')
15
+ await expect(cards).toHaveCount(9)
16
+
17
+ let lastoffset = 0
18
+ for (let i = 0; i < 9; i++) {
19
+ const top = (await cards.nth(i).boundingBox()).y
20
+ expect(top).toBeGreaterThanOrEqual(lastoffset)
21
+ lastoffset = top
22
+ }
23
+ expect(lastoffset).toBeGreaterThan(0)
24
+ })
25
+ })
26
+ test.describe('Preserve Order Layout', () => {
27
+ test.beforeEach(async ({ page }) => {
28
+ await goto(page, '/cards/preserve')
29
+ })
30
+
31
+ test('should preserve card order when instructed', async ({ page }) => {
32
+ const cards = page.locator('.cardlayout-card')
33
+ await expect(cards).toHaveCount(9)
34
+ let lastleft = 0
35
+ for (let i = 0; i < 9; i++) {
36
+ const left = (await cards.nth(i).boundingBox()).x
37
+ expect(left).toBeGreaterThanOrEqual(lastleft)
38
+ lastleft = left
39
+ }
40
+ })
41
+ })
@@ -0,0 +1,37 @@
1
+ import { test, expect } from '@playwright/test'
2
+ import { goto } from './common.js'
3
+
4
+ test.beforeEach(async ({ page }) => {
5
+ await goto(page, '/collapsingtable')
6
+ })
7
+
8
+ test('has two rows in tbody', async ({ page }) => {
9
+ await expect(page.locator('text=John Smith')).toHaveCount(1)
10
+ await expect(page.locator('text=Mary Sue')).toHaveCount(1)
11
+ })
12
+ test('hides the numerated columns on a small screen', async ({ page }) => {
13
+ await page.setViewportSize({ width: 400, height: 1024 })
14
+ await expect(page.locator('text="one"')).toHaveCount(0)
15
+ })
16
+
17
+ test('menu toggles when button is clicked', async ({ page }) => {
18
+ await page.setViewportSize({ width: 400, height: 1024 })
19
+ const button = page.locator('th').last()
20
+ const menuitemtwo = page.locator('text="two"')
21
+ await expect(menuitemtwo).toHaveCount(0)
22
+ button.click()
23
+ await expect(menuitemtwo).toHaveCount(1)
24
+ button.click()
25
+ await expect(menuitemtwo).toHaveCount(0)
26
+ })
27
+
28
+ test('able to activate a new row', async ({ page }) => {
29
+ await page.setViewportSize({ width: 400, height: 1024 })
30
+ const button = page.locator('th').last()
31
+ const menuitemtwo = page.locator('text="two"')
32
+ await expect(menuitemtwo).toHaveCount(0)
33
+ button.click()
34
+ await expect(menuitemtwo).toHaveCount(1)
35
+ menuitemtwo.click()
36
+ await expect(page.locator('text="2"')).toHaveCount(3)
37
+ })
@@ -0,0 +1,18 @@
1
+ import { test, expect } from '@playwright/test'
2
+ import { goto } from './common.js'
3
+
4
+ test.beforeEach(async ({ page }) => {
5
+ await goto(page, '/modal')
6
+ })
7
+
8
+ test('modal is active on first render, escape dismisses, hitting enter on the button brings it back, escaping puts focus on the button', async ({ page }) => {
9
+ const button = page.locator('#test-button')
10
+ const nameInput = page.locator('#firstname')
11
+ await expect(nameInput).toHaveCount(1)
12
+ await nameInput.press('Escape')
13
+ await expect(nameInput).toHaveCount(0)
14
+ await button.press('Enter')
15
+ await expect(nameInput).toHaveCount(1)
16
+ await nameInput.press('Escape')
17
+ await expect(page.locator('#test-button')).toBeFocused()
18
+ })
@@ -0,0 +1,58 @@
1
+ import { test, expect } from '@playwright/test'
2
+ import { goto } from './common.js'
3
+
4
+ test.beforeEach(async ({ page }) => {
5
+ await goto(page, '/multiselect')
6
+ })
7
+
8
+ test('menus open on focus', async ({ page }) => {
9
+ const firstselect = page.locator('[name="test1"]')
10
+ const secondselect = page.locator('[name="test2"]')
11
+ const appleInSecond = page.locator('text="Apple"')
12
+ const bananaInFirst = page.locator('text="banana"')
13
+ await expect(appleInSecond).toHaveCount(0)
14
+ await expect(bananaInFirst).toHaveCount(0)
15
+ firstselect.focus()
16
+ await expect(bananaInFirst).toHaveCount(1)
17
+ secondselect.focus()
18
+ await expect(bananaInFirst).toHaveCount(0)
19
+ await expect(appleInSecond).toHaveCount(1)
20
+ secondselect.press('Escape')
21
+ await expect(appleInSecond).toHaveCount(0)
22
+ })
23
+
24
+ test('able to add and remove items', async ({ page }) => {
25
+ const firstselect = page.locator('[name="test1"]')
26
+ const secondselect = page.locator('[name="test2"]')
27
+ const bananaInFirst = page.locator('text="banana"')
28
+ const orangeInFirst = page.locator('text="orange"')
29
+ const appleInSecond = page.locator('text="Apple"')
30
+ const bananaInSecond = page.locator('text="Banana"')
31
+ const orangeInSecond = page.locator('text="Orange"')
32
+ await expect(bananaInFirst).toHaveCount(0)
33
+ firstselect.focus()
34
+ await expect(bananaInFirst).toHaveCount(1)
35
+ bananaInFirst.click()
36
+ await expect(orangeInFirst).toHaveCount(0)
37
+ await expect(bananaInFirst).toHaveCount(1)
38
+ bananaInFirst.click()
39
+ await expect(bananaInFirst).toHaveCount(0)
40
+
41
+ await expect(appleInSecond).toHaveCount(0)
42
+ await expect(bananaInSecond).toHaveCount(1)
43
+ secondselect.press('Backspace')
44
+ secondselect.press('Escape')
45
+ await expect(bananaInSecond).toHaveCount(0)
46
+ secondselect.press('ArrowLeft')
47
+ await expect(orangeInSecond).toHaveCount(1)
48
+ await expect(orangeInSecond).toHaveClass(/hilited/)
49
+ })
50
+
51
+ test('typing in the input reduces the options in the menu', async ({ page }) => {
52
+ const firstselect = page.locator('[name="test1"]')
53
+ const bananaInFirst = page.locator('text="banana"')
54
+ const orangeInFirst = page.locator('text="orange"')
55
+ firstselect.type('ora')
56
+ await expect(bananaInFirst).toHaveCount(0)
57
+ await expect(orangeInFirst).toHaveCount(1)
58
+ })
@@ -0,0 +1,55 @@
1
+ import { test, expect } from '@playwright/test'
2
+ import { goto } from './common.js'
3
+
4
+ test.beforeEach(async ({ page }) => {
5
+ await goto(page, '/popupmenu')
6
+ })
7
+
8
+ test('menu toggles when button is clicked', async ({ page }) => {
9
+ const button = page.locator('#test-button')
10
+ const monday = page.locator('text="Monday"')
11
+ await expect(button).toHaveCount(1)
12
+ await expect(monday).toHaveCount(0)
13
+ button.click()
14
+ await expect(monday).toHaveCount(1)
15
+ button.click()
16
+ await expect(monday).toHaveCount(0)
17
+ button.press('Enter')
18
+ await expect(monday).toHaveCount(1)
19
+ button.press('Enter')
20
+ await expect(monday).toHaveCount(0)
21
+ })
22
+
23
+ test('has five menu items', async ({ page }) => {
24
+ const button = page.locator('#test-button')
25
+ await expect(button).toHaveCount(1)
26
+ button.click()
27
+ await expect(page.locator('text="Monday"')).toHaveCount(1)
28
+ await expect(page.locator('text="Tuesday"')).toHaveCount(1)
29
+ await expect(page.locator('text="Wednesday"')).toHaveCount(1)
30
+ await expect(page.locator('text="Thursday"')).toHaveCount(1)
31
+ await expect(page.locator('text="Friday"')).toHaveCount(1)
32
+ })
33
+
34
+ test('clicking a menu option selects it', async ({ page }) => {
35
+ const button = page.locator('#test-button')
36
+ await expect(button).toHaveCount(1)
37
+ button.click()
38
+ const option = page.locator('text="Monday"')
39
+ await expect(option).toHaveCount(1)
40
+ await expect(page.locator('text=selected: 1')).toHaveCount(0)
41
+ option.click()
42
+ await expect(page.locator('text=selected: 1')).toHaveCount(1)
43
+ })
44
+
45
+ test('may select a menu option with the keyboard', async ({ page }) => {
46
+ const button = page.locator('#test-button')
47
+ await expect(button).toHaveCount(1)
48
+ button.click()
49
+ const option = page.locator('text="Monday"')
50
+ await expect(option).toHaveCount(1)
51
+ await expect(page.locator('text=selected: 1')).toHaveCount(0)
52
+ await button.press('ArrowDown')
53
+ await button.press('Enter')
54
+ await expect(page.locator('text=selected: 1')).toHaveCount(1)
55
+ })
@@ -0,0 +1,4 @@
1
+ export async function goto (page, href) {
2
+ await page.goto(href, { waitUntil: 'commit' })
3
+ await page.evaluate(() => new Promise(resolve => window.addEventListener('sveltekit:start', resolve)))
4
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "compilerOptions": {
3
+ "moduleResolution": "node",
4
+ "module": "es2020",
5
+ "lib": ["es2020", "DOM"],
6
+ "target": "es2020",
7
+ /**
8
+ svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript
9
+ to enforce using \`import type\` instead of \`import\` for Types.
10
+ */
11
+ "importsNotUsedAsValues": "error",
12
+ "isolatedModules": true,
13
+ "resolveJsonModule": true,
14
+ /**
15
+ To have warnings/errors of the Svelte compiler at the correct position,
16
+ enable source maps by default.
17
+ */
18
+ "sourceMap": true,
19
+ "esModuleInterop": true,
20
+ "skipLibCheck": true,
21
+ "forceConsistentCasingInFileNames": true,
22
+ "baseUrl": ".",
23
+ "allowJs": true,
24
+ "checkJs": true,
25
+ "paths": {
26
+ "$lib": ["src/lib"],
27
+ "$lib/*": ["src/lib/*"]
28
+ }
29
+ },
30
+ "include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.ts", "src/**/*.svelte"]
31
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Texas State ETC
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buttonify = void 0;
4
- /**
5
- * Turns any HTML element into an accessible button that responds to keyboard events and has
6
- * role="button" and the tabindex attribute set. You are still responsible for making sure it has
7
- * readable content or a good label.
8
- */
9
- function buttonify(node) {
10
- function keydown(e) {
11
- if (e.key === 'Enter') {
12
- if (!e.shiftKey && !e.metaKey && !e.ctrlKey && !e.altKey) {
13
- e.preventDefault();
14
- e.stopPropagation();
15
- node.dispatchEvent(new CustomEvent('click'));
16
- }
17
- }
18
- }
19
- node.addEventListener('keydown', keydown);
20
- if (node.tabIndex < 0)
21
- node.tabIndex = 0;
22
- node.setAttribute('role', 'button');
23
- node.style.cursor = 'pointer';
24
- return {
25
- destroy() {
26
- node.removeEventListener('keydown', keydown);
27
- }
28
- };
29
- }
30
- exports.buttonify = buttonify;
31
- //# sourceMappingURL=buttonify.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buttonify.js","sourceRoot":"","sources":["../../src/actions/buttonify.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,SAAgB,SAAS,CAAE,IAAiB;IAC1C,SAAS,OAAO,CAAE,CAAgB;QAChC,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,EAAE;YACrB,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE;gBACxD,CAAC,CAAC,cAAc,EAAE,CAAA;gBAClB,CAAC,CAAC,eAAe,EAAE,CAAA;gBACnB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,CAAA;aAC7C;SACF;IACH,CAAC;IAED,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IACzC,IAAI,IAAI,CAAC,QAAQ,GAAG,CAAC;QAAE,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAA;IACxC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IACnC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAA;IAE7B,OAAO;QACL,OAAO;YACL,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;QAC9C,CAAC;KACF,CAAA;AACH,CAAC;AArBD,8BAqBC"}