@alacris/ui 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -46,10 +46,10 @@ The published package is plain ESM. Point an import map at a pinned CDN build of
46
46
  <script type="importmap">
47
47
  {
48
48
  "imports": {
49
- "@alacris/core": "https://cdn.jsdelivr.net/npm/@alacris/core@0.11.0/dist/alacris.js",
50
- "@alacris/ui": "https://cdn.jsdelivr.net/npm/@alacris/ui@0.2.2/src/index.js",
51
- "@alacris/ui/theme": "https://cdn.jsdelivr.net/npm/@alacris/ui@0.2.2/src/theme/index.js",
52
- "@alacris/ui/components/": "https://cdn.jsdelivr.net/npm/@alacris/ui@0.2.2/src/components/"
49
+ "@alacris/core": "https://cdn.jsdelivr.net/npm/@alacris/core@0.11.1/dist/alacris.js",
50
+ "@alacris/ui": "https://cdn.jsdelivr.net/npm/@alacris/ui@0.2.3/src/index.js",
51
+ "@alacris/ui/theme": "https://cdn.jsdelivr.net/npm/@alacris/ui@0.2.3/src/theme/index.js",
52
+ "@alacris/ui/components/": "https://cdn.jsdelivr.net/npm/@alacris/ui@0.2.3/src/components/"
53
53
  }
54
54
  }
55
55
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alacris/ui",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Themeable design system for Alacris — Material defaults, sixty-eight custom elements, ESM-only, no build step.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -37,6 +37,11 @@ const t = vars('ui-text-field', {
37
37
  radius: sys.radius.xs,
38
38
  font: sys.type.bodyLg,
39
39
  height: '56px',
40
+
41
+ // The lane reserved at the end of a number field for its stepper. It is a
42
+ // variable because the buttons are the browser's and their width is not the
43
+ // same on every engine — a consumer with a denser field can shorten it.
44
+ stepperWidth: '18px',
40
45
  });
41
46
 
42
47
  const styles = css`
@@ -217,6 +222,43 @@ const styles = css`
217
222
  .filled.has-label textarea { padding-top: ${sys.space(7)}; }
218
223
  .with-leading.multiline .field { padding-inline-start: ${sys.space(4)}; }
219
224
  .with-leading.multiline textarea { padding-inline-start: 0; }
225
+ /* A number field's stepper gets its own lane.
226
+
227
+ The browser draws the spin buttons inside the input's content box, at the
228
+ inline end, and they are painted over whatever is already there: the
229
+ floating label, the placeholder, and the value itself once it is long
230
+ enough. On a narrow field it lands squarely on the label — a chevron
231
+ sitting on the word it is meant to sit beside.
232
+
233
+ So the end of the field is reserved for it. The input is padded by the
234
+ stepper's width, and the label and legend are shortened by the same
235
+ amount so a long label ellipsises before it reaches the buttons rather
236
+ than sliding underneath them. appearance:none does not help here: it
237
+ removes the field's own chrome and leaves the ::-webkit-*-spin-button
238
+ alone, which is why this needs saying explicitly. */
239
+ .numeric input { padding-inline-end: ${t.stepperWidth}; }
240
+ .numeric .label {
241
+ max-inline-size: calc(100% - ${sys.space(4)} - ${t.stepperWidth});
242
+ overflow: hidden;
243
+ text-overflow: ellipsis;
244
+ white-space: nowrap;
245
+ }
246
+ .numeric legend { max-inline-size: calc(100% - ${t.stepperWidth}); }
247
+ .numeric input::-webkit-outer-spin-button,
248
+ .numeric input::-webkit-inner-spin-button {
249
+ /* Held at the end of the reserved lane rather than tight against the
250
+ text, and always visible: a stepper that appears on hover is a control
251
+ nobody knows is there. */
252
+ margin: 0;
253
+ margin-inline-start: ${sys.space(2)};
254
+ opacity: 1;
255
+ }
256
+ /* Firefox draws no buttons at all unless asked, so the reserved lane would
257
+ be an empty gap. Asking for them makes the two engines agree. */
258
+ @supports (-moz-appearance: number-input) {
259
+ .numeric input { -moz-appearance: number-input; }
260
+ }
261
+
220
262
  input::placeholder, textarea::placeholder { color: ${t.labelFg}; opacity: 0; transition: opacity ${sys.duration.short2} linear; }
221
263
  .floating input::placeholder, .floating textarea::placeholder { opacity: 1; }
222
264
 
@@ -255,7 +297,8 @@ define('ui-text-field', {
255
297
  const cls = computed(() =>
256
298
  ['root', variant(), floating() && 'floating', focused() && 'focused',
257
299
  error() && 'error', disabled() && 'disabled', label() && 'has-label',
258
- hasLeading() && 'with-leading', type() === 'textarea' && 'multiline'].filter(Boolean).join(' '));
300
+ hasLeading() && 'with-leading', type() === 'textarea' && 'multiline',
301
+ type() === 'number' && 'numeric'].filter(Boolean).join(' '));
259
302
 
260
303
  const onInput = (e) => {
261
304
  value.set(e.target.value);