@mohirlab/react 0.2.0 → 0.4.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 (41) hide show
  1. package/dist/components/badge/badge.css.d.ts +1 -5
  2. package/dist/components/badge/badge.css.d.ts.map +1 -1
  3. package/dist/components/button/button.css.d.ts +3 -4
  4. package/dist/components/button/button.css.d.ts.map +1 -1
  5. package/dist/components/choice/choice.d.ts +46 -0
  6. package/dist/components/choice/choice.d.ts.map +1 -0
  7. package/dist/components/choice/choice.js +184 -0
  8. package/dist/components/choice/choice.js.map +1 -0
  9. package/dist/components/choice/choice.styles.js +21 -0
  10. package/dist/components/choice/choice.styles.js.map +1 -0
  11. package/dist/components/choice/index.d.ts +2 -0
  12. package/dist/components/field/use-field-control.js +21 -0
  13. package/dist/components/field/use-field-control.js.map +1 -0
  14. package/dist/components/input/index.d.ts +2 -2
  15. package/dist/components/input/input.css.d.ts +2 -3
  16. package/dist/components/input/input.css.d.ts.map +1 -1
  17. package/dist/components/input/input.d.ts +12 -0
  18. package/dist/components/input/input.d.ts.map +1 -1
  19. package/dist/components/input/input.js +32 -11
  20. package/dist/components/input/input.js.map +1 -1
  21. package/dist/components/input/input.styles.js +3 -1
  22. package/dist/components/select/index.d.ts +2 -0
  23. package/dist/components/select/select.d.ts +14 -0
  24. package/dist/components/select/select.d.ts.map +1 -0
  25. package/dist/components/select/select.js +44 -0
  26. package/dist/components/select/select.js.map +1 -0
  27. package/dist/components/select/select.styles.js +7 -0
  28. package/dist/components/select/select.styles.js.map +1 -0
  29. package/dist/components/slider/index.d.ts +2 -0
  30. package/dist/components/slider/slider.d.ts +18 -0
  31. package/dist/components/slider/slider.d.ts.map +1 -0
  32. package/dist/components/slider/slider.js +50 -0
  33. package/dist/components/slider/slider.js.map +1 -0
  34. package/dist/components/slider/slider.styles.js +7 -0
  35. package/dist/components/slider/slider.styles.js.map +1 -0
  36. package/dist/components/text/text.css.d.ts +1 -2
  37. package/dist/components/text/text.css.d.ts.map +1 -1
  38. package/dist/index.d.ts +8 -2
  39. package/dist/index.js +6 -3
  40. package/dist/styles.css +628 -274
  41. package/package.json +7 -6
@@ -0,0 +1,50 @@
1
+ import { useState } from "react";
2
+ import { assignInlineVars } from "@vanilla-extract/dynamic";
3
+ import { cx } from "../../utils/cx.js";
4
+ import { useFieldControl } from "../field/use-field-control.js";
5
+ import { fill, output, slider } from "./slider.styles.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/slider/slider.tsx
8
+ /** A native range input with a filled track. Arrow keys, Page Up/Down, Home and End work natively. */
9
+ function Slider({ value, defaultValue, onValueChange, min = 0, max = 100, step = 1, format, className, style, id, required, disabled, onChange, ...rest }) {
10
+ const control = useFieldControl({
11
+ id,
12
+ required,
13
+ disabled,
14
+ "aria-describedby": rest["aria-describedby"]
15
+ });
16
+ const [internal, setInternal] = useState(defaultValue ?? (min + max) / 2);
17
+ const current = value ?? internal;
18
+ const percent = max === min ? 0 : (current - min) / (max - min) * 100;
19
+ return /* @__PURE__ */ jsx("input", {
20
+ ...rest,
21
+ ...control,
22
+ type: "range",
23
+ min,
24
+ max,
25
+ step,
26
+ value: current,
27
+ "aria-valuetext": format?.(current),
28
+ onChange: (event) => {
29
+ onChange?.(event);
30
+ const next = Number(event.target.value);
31
+ if (value === void 0) setInternal(next);
32
+ onValueChange?.(next);
33
+ },
34
+ className: cx(slider, className),
35
+ style: {
36
+ ...style,
37
+ ...assignInlineVars({ [fill]: `${percent}%` })
38
+ }
39
+ });
40
+ }
41
+ /** Label row for a slider inside a `Field`: puts the current value at the end. */
42
+ function SliderValue({ children }) {
43
+ return /* @__PURE__ */ jsx("output", {
44
+ className: output,
45
+ children
46
+ });
47
+ }
48
+ export { Slider, SliderValue };
49
+
50
+ //# sourceMappingURL=slider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slider.js","names":["styles.slider","styles.fill","styles.output"],"sources":["../../../src/components/slider/slider.tsx"],"sourcesContent":["import { useState, type ComponentPropsWithRef, type ReactNode } from 'react';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { cx } from '../../utils/cx';\nimport { useFieldControl } from '../field/use-field-control';\nimport * as styles from './slider.css';\n\nexport interface SliderProps extends Omit<\n ComponentPropsWithRef<'input'>,\n 'type' | 'value' | 'defaultValue' | 'size'\n> {\n value?: number;\n defaultValue?: number;\n onValueChange?: (value: number) => void;\n min?: number;\n max?: number;\n step?: number;\n /** Format the value for `aria-valuetext` and for `SliderValue`, e.g. `(v) => \\`${v}%\\``. */\n format?: (value: number) => string;\n}\n\n/** A native range input with a filled track. Arrow keys, Page Up/Down, Home and End work natively. */\nexport function Slider({\n value,\n defaultValue,\n onValueChange,\n min = 0,\n max = 100,\n step = 1,\n format,\n className,\n style,\n id,\n required,\n disabled,\n onChange,\n ...rest\n}: SliderProps) {\n const control = useFieldControl({ id, required, disabled, 'aria-describedby': rest['aria-describedby'] });\n const [internal, setInternal] = useState(defaultValue ?? (min + max) / 2);\n const current = value ?? internal;\n const percent = max === min ? 0 : ((current - min) / (max - min)) * 100;\n return (\n <input\n {...rest}\n {...control}\n type=\"range\"\n min={min}\n max={max}\n step={step}\n value={current}\n aria-valuetext={format?.(current)}\n onChange={(event) => {\n onChange?.(event);\n const next = Number(event.target.value);\n if (value === undefined) setInternal(next);\n onValueChange?.(next);\n }}\n className={cx(styles.slider, className)}\n style={{ ...style, ...assignInlineVars({ [styles.fill]: `${percent}%` }) }}\n />\n );\n}\n\n/** Label row for a slider inside a `Field`: puts the current value at the end. */\nexport function SliderValue({ children }: { children: ReactNode }) {\n return <output className={styles.output}>{children}</output>;\n}\n"],"mappings":";;;;;;;;AAqBA,SAAgB,OAAO,EACrB,OACA,cACA,eACA,MAAM,GACN,MAAM,KACN,OAAO,GACP,QACA,WACA,OACA,IACA,UACA,UACA,UACA,GAAG,QACW;CACd,MAAM,UAAU,gBAAgB;EAAE;EAAI;EAAU;EAAU,oBAAoB,KAAK;CAAoB,CAAC;CACxG,MAAM,CAAC,UAAU,eAAe,SAAS,iBAAiB,MAAM,OAAO,CAAC;CACxE,MAAM,UAAU,SAAS;CACzB,MAAM,UAAU,QAAQ,MAAM,KAAM,UAAU,QAAQ,MAAM,OAAQ;CACpE,OACE,oBAAC,SAAD;EACE,GAAI;EACJ,GAAI;EACJ,MAAK;EACA;EACA;EACC;EACN,OAAO;EACP,kBAAgB,SAAS,OAAO;EAChC,WAAW,UAAU;GACnB,WAAW,KAAK;GAChB,MAAM,OAAO,OAAO,MAAM,OAAO,KAAK;GACtC,IAAI,UAAU,KAAA,GAAW,YAAY,IAAI;GACzC,gBAAgB,IAAI;EACtB;EACA,WAAW,GAAGA,QAAe,SAAS;EACtC,OAAO;GAAE,GAAG;GAAO,GAAG,iBAAiB,GAAGC,OAAc,GAAG,QAAQ,GAAG,CAAC;EAAE;CAC1E,CAAA;AAEL;;AAGA,SAAgB,YAAY,EAAE,YAAqC;CACjE,OAAO,oBAAC,UAAD;EAAQ,WAAWC;EAAgB;CAAiB,CAAA;AAC7D"}
@@ -0,0 +1,7 @@
1
+ // src/components/slider/slider.css.ts
2
+ var fill = "var(--ml_kzlle60)";
3
+ var output = "ml_kzlle63";
4
+ var slider = "ml_kzlle61";
5
+ export { fill, output, slider };
6
+
7
+ //# sourceMappingURL=slider.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slider.styles.js","names":[],"sources":[],"mappings":""}
@@ -35,9 +35,8 @@ export declare const text: import("@vanilla-extract/recipes").RuntimeFn<{
35
35
  fontSize: `var(--${string})`;
36
36
  lineHeight: `var(--${string})`;
37
37
  };
38
- /** The workshop label: mono, uppercase, tracked. */
38
+ /** The eyebrow: small, uppercase, tracked. */
39
39
  label: {
40
- fontFamily: `var(--${string})`;
41
40
  fontSize: `var(--${string})`;
42
41
  fontWeight: `var(--${string})`;
43
42
  letterSpacing: `var(--${string})`;
@@ -1 +1 @@
1
- {"version":3,"file":"text.css.d.ts","names":[],"sources":["../../../src/components/text/text.css.ts"],"mappings":";qBAQa,yCAAI;;;;;;;;;;;;;;;;;MAmBT;MACA;MACA;MACA;;;MAGA;MACA;MACA;;;;;;;;MAGO;MAAwB;;;;;;;;;;;;;;;;;;MAatB;;;MACF;;;MACC;;;MACA;;;MACA;;;MACC;;;;;;;;;;;;;YAWL,eAAe,YAAY,sBAAsB"}
1
+ {"version":3,"file":"text.css.d.ts","names":[],"sources":["../../../src/components/text/text.css.ts"],"mappings":";qBAQa,yCAAI;;;;;;;;;;;;;;;;;MAmBT;MACA;MACA;MACA;;;MAGA;MACA;MACA;;;;;;;;MAGO;MAAwB;;;;;;;;;;;;;;;;;MAYtB;;;MACF;;;MACC;;;MACA;;;MACA;;;MACC;;;;;;;;;;;;;YAWL,eAAe,YAAY,sBAAsB"}
package/dist/index.d.ts CHANGED
@@ -10,6 +10,8 @@ import "./components/button/index.js";
10
10
  import { Card, CardHeader, CardProps } from "./components/card/card.js";
11
11
  import { CardMedia, CardMediaProps } from "./components/card/card-media.js";
12
12
  import "./components/card/index.js";
13
+ import { Checkbox, CheckboxProps, Radio, RadioGroup, RadioGroupProps, RadioProps, Switch, SwitchProps } from "./components/choice/choice.js";
14
+ import "./components/choice/index.js";
13
15
  import { Dialog, DialogActions, DialogBody, DialogProps } from "./components/dialog/dialog.js";
14
16
  import "./components/dialog/index.js";
15
17
  import { Field, FieldProps } from "./components/field/field.js";
@@ -17,11 +19,15 @@ import { FieldContextValue, useField } from "./components/field/field-context.js
17
19
  import "./components/field/index.js";
18
20
  import { Icon, IconProps } from "./components/icon/icon.js";
19
21
  import "./components/icon/index.js";
20
- import { Input, InputProps } from "./components/input/input.js";
22
+ import { Input, InputProps, Textarea, TextareaProps } from "./components/input/input.js";
21
23
  import "./components/input/index.js";
22
24
  import { Placement } from "./components/popover/popover.css.js";
23
25
  import { Popover, PopoverProps, Tooltip, TooltipProps } from "./components/popover/popover.js";
24
26
  import "./components/popover/index.js";
27
+ import { Select, SelectProps } from "./components/select/select.js";
28
+ import "./components/select/index.js";
29
+ import { Slider, SliderProps, SliderValue } from "./components/slider/slider.js";
30
+ import "./components/slider/index.js";
25
31
  import { Heading, HeadingProps, MarginProps, Text, TextProps } from "./components/text/text.js";
26
32
  import "./components/text/index.js";
27
33
  import { ToastOptions, ToastProvider, ToastProviderProps, ToastTone, useToast } from "./components/toast/toast.js";
@@ -31,4 +37,4 @@ import { PresenceState, usePresence } from "./hooks/use-presence.js";
31
37
  import { useDisclosure } from "./hooks/use-disclosure.js";
32
38
  import "./hooks/index.js";
33
39
  import { cx } from "./utils/cx.js";
34
- export { Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, Badge, type BadgeProps, Box, type BoxProps, Button, type ButtonProps, Card, CardHeader, CardMedia, type CardMediaProps, type CardProps, Dialog, DialogActions, DialogBody, type DialogProps, Field, type FieldContextValue, type FieldProps, Heading, type HeadingProps, Icon, type IconProps, Input, type InputProps, type MarginProps, type Placement, Popover, type PopoverProps, type PresenceState, Stack, type StackProps, Text, type TextProps, ThemeScope, type ThemeScopeProps, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastTone, Tooltip, type TooltipProps, cx, splitSprinkles, useDisclosure, useField, usePresence, useToast };
40
+ export { Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, Badge, type BadgeProps, Box, type BoxProps, Button, type ButtonProps, Card, CardHeader, CardMedia, type CardMediaProps, type CardProps, Checkbox, type CheckboxProps, Dialog, DialogActions, DialogBody, type DialogProps, Field, type FieldContextValue, type FieldProps, Heading, type HeadingProps, Icon, type IconProps, Input, type InputProps, type MarginProps, type Placement, Popover, type PopoverProps, type PresenceState, Radio, RadioGroup, type RadioGroupProps, type RadioProps, Select, type SelectProps, Slider, type SliderProps, SliderValue, Stack, type StackProps, Switch, type SwitchProps, Text, type TextProps, Textarea, type TextareaProps, ThemeScope, type ThemeScopeProps, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastTone, Tooltip, type TooltipProps, cx, splitSprinkles, useDisclosure, useField, usePresence, useToast };
package/dist/index.js CHANGED
@@ -6,15 +6,18 @@ import { Stack } from "./components/box/stack.js";
6
6
  import { Button } from "./components/button/button.js";
7
7
  import { Card, CardHeader } from "./components/card/card.js";
8
8
  import { CardMedia } from "./components/card/card-media.js";
9
- import { usePresence } from "./hooks/use-presence.js";
10
9
  import { Icon } from "./components/icon/icon.js";
10
+ import { Checkbox, Radio, RadioGroup, Switch } from "./components/choice/choice.js";
11
+ import { usePresence } from "./hooks/use-presence.js";
11
12
  import { Dialog, DialogActions, DialogBody } from "./components/dialog/dialog.js";
12
13
  import { useField } from "./components/field/field-context.js";
13
14
  import { Field } from "./components/field/field.js";
14
- import { Input } from "./components/input/input.js";
15
+ import { Input, Textarea } from "./components/input/input.js";
15
16
  import { Popover, Tooltip } from "./components/popover/popover.js";
17
+ import { Select } from "./components/select/select.js";
18
+ import { Slider, SliderValue } from "./components/slider/slider.js";
16
19
  import { Heading, Text } from "./components/text/text.js";
17
20
  import { ToastProvider, useToast } from "./components/toast/toast.js";
18
21
  import { cx } from "./utils/cx.js";
19
22
  import { useDisclosure } from "./hooks/use-disclosure.js";
20
- export { Avatar, AvatarGroup, Badge, Box, Button, Card, CardHeader, CardMedia, Dialog, DialogActions, DialogBody, Field, Heading, Icon, Input, Popover, Stack, Text, ThemeScope, ToastProvider, Tooltip, cx, splitSprinkles, useDisclosure, useField, usePresence, useToast };
23
+ export { Avatar, AvatarGroup, Badge, Box, Button, Card, CardHeader, CardMedia, Checkbox, Dialog, DialogActions, DialogBody, Field, Heading, Icon, Input, Popover, Radio, RadioGroup, Select, Slider, SliderValue, Stack, Switch, Text, Textarea, ThemeScope, ToastProvider, Tooltip, cx, splitSprinkles, useDisclosure, useField, usePresence, useToast };