@pismo/marola 2.0.0 → 2.0.2

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.
@@ -1,15 +1,8 @@
1
1
  import { StoryObj } from '@storybook/react';
2
+ import { RadioButtonProps } from './RadioButton';
2
3
  declare const meta: {
3
4
  title: string;
4
- component: ({ className, name, label, checked, disabled, "data-testid": dataTestId, onChange, }: {
5
- className?: string | undefined;
6
- name?: string | undefined;
7
- label?: import('react').ReactNode;
8
- checked?: boolean | undefined;
9
- disabled?: boolean | undefined;
10
- 'data-testid'?: string | undefined;
11
- onChange: (state: boolean) => void;
12
- }) => import("react/jsx-runtime").JSX.Element;
5
+ component: ({ className, name, label, disabled, defaultValue, checked, "data-testid": dataTestId, onChange, children, }: RadioButtonProps) => import("react/jsx-runtime").JSX.Element;
13
6
  tags: string[];
14
7
  parameters: {
15
8
  layout: string;
@@ -18,6 +11,8 @@ declare const meta: {
18
11
  export default meta;
19
12
  type Story = StoryObj<typeof meta>;
20
13
  export declare const Simple: Story;
21
- export declare const WithLabel: Story;
22
- export declare const Disabled: Story;
23
- export declare const WithOnChangeAction: Story;
14
+ export declare const WithDisabledOption: Story;
15
+ export declare const WithOnChangeTrigger: Story;
16
+ export declare const WithDefaultValue: Story;
17
+ export declare const WithLegacyLabel: Story;
18
+ export declare const DisabledLegacy: Story;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ type RadioOptionProps = {
3
+ /** Component label */
4
+ label?: React.ReactNode;
5
+ /** Component value */
6
+ value?: string | number | boolean;
7
+ /** Disabled state */
8
+ disabled?: boolean;
9
+ /**Option testId */
10
+ 'data-testid'?: string;
11
+ };
12
+ export declare const RadioOption: ({ label, value, disabled, "data-testid": dataTestId }: RadioOptionProps) => import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1,438 @@
1
+ import { jsxs as A, jsx as k } from "react/jsx-runtime";
2
+ import { c as B } from "../../clsx-OuTLNxxd.js";
3
+ import "../Icon/Icon.js";
4
+ import { Typography as K } from "../Typography/Typography.js";
5
+ import * as a from "react";
6
+ import "../Input/Input.js";
7
+ import "../Avatar/Avatar.js";
8
+ import "../Button/Button.js";
9
+ import "../../Toggle-DEVeyo2f.js";
10
+ import "../Dialog/Dialog.js";
11
+ import "../IconButton/IconButton.js";
12
+ import "../InputSearch/InputSearch.js";
13
+ import "../Select/Select.js";
14
+ import "../Popover/Popover.js";
15
+ import { u as v, a as j, b as E, c as U, d as w, e as F, m as I, f as q, g as V, h as M, r as z, i as J, N as Q, s as N } from "../../RadioButton.module-B4kmS66R.js";
16
+ import "../Table/Table.js";
17
+ import "../Tabs/Tabs.js";
18
+ import "../../Group-Cyc1W1kV.js";
19
+ import "../../contexts/SnackbarProvider/SnackbarProvider.js";
20
+ import { P as s } from "../../useSlotProps-DSnfx453.js";
21
+ import { r as W } from "../../index-CATDT7fJ.js";
22
+ function X(r, e = !1) {
23
+ const [n, o] = a.useState(), [t, d] = a.useState(r);
24
+ return r && !t && (d(!0), n !== "starting" && !e && o("starting")), !r && t && n !== "ending" && o("ending"), !r && !t && n === "ending" && o(void 0), v(() => {
25
+ if (!r)
26
+ return;
27
+ e && o("starting");
28
+ const i = requestAnimationFrame(() => {
29
+ o(void 0);
30
+ });
31
+ return () => {
32
+ cancelAnimationFrame(i);
33
+ };
34
+ }, [r, e]), a.useMemo(() => ({
35
+ mounted: t,
36
+ setMounted: d,
37
+ transitionStatus: n
38
+ }), [t, n]);
39
+ }
40
+ function Y(r = {}) {
41
+ const {
42
+ label: e,
43
+ metadata: n
44
+ } = r, {
45
+ register: o,
46
+ unregister: t,
47
+ map: d,
48
+ elementsRef: i,
49
+ labelsRef: u
50
+ } = j(), [l, m] = a.useState(null), f = a.useRef(null), R = a.useCallback((c) => {
51
+ if (f.current = c, l !== null && (i.current[l] = c, u)) {
52
+ const h = e !== void 0;
53
+ u.current[l] = h ? e : (c == null ? void 0 : c.textContent) ?? null;
54
+ }
55
+ }, [l, i, u, e]);
56
+ return v(() => {
57
+ const c = f.current;
58
+ if (c)
59
+ return o(c, n), () => {
60
+ t(c);
61
+ };
62
+ }, [o, t, n]), v(() => {
63
+ var h;
64
+ const c = f.current ? (h = d.get(f.current)) == null ? void 0 : h.index : null;
65
+ c != null && m(c);
66
+ }, [d]), a.useMemo(() => ({
67
+ ref: R,
68
+ index: l ?? -1
69
+ }), [l, R]);
70
+ }
71
+ const Z = {
72
+ "data-starting-style": ""
73
+ }, $ = {
74
+ "data-ending-style": ""
75
+ }, ee = {
76
+ transitionStatus(r) {
77
+ return r === "starting" ? Z : r === "ending" ? $ : null;
78
+ }
79
+ };
80
+ function te(r, e = !1) {
81
+ const n = a.useRef(-1), o = a.useRef(-1), t = E(() => {
82
+ cancelAnimationFrame(n.current), clearTimeout(o.current);
83
+ });
84
+ return a.useEffect(() => t, [t]), E((d) => {
85
+ t();
86
+ const i = r.current;
87
+ i && (typeof i.getAnimations != "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED ? d() : n.current = requestAnimationFrame(() => {
88
+ function u() {
89
+ i && Promise.allSettled(i.getAnimations().map((l) => l.finished)).then(() => {
90
+ W.flushSync(d);
91
+ });
92
+ }
93
+ e ? o.current = window.setTimeout(u) : u();
94
+ }));
95
+ });
96
+ }
97
+ function ne(r) {
98
+ const {
99
+ open: e,
100
+ ref: n,
101
+ onComplete: o
102
+ } = r, t = U(e), d = E(o), i = te(n, e);
103
+ v(() => {
104
+ i(() => {
105
+ e === t.current && d();
106
+ });
107
+ }, [e, d, i, t]);
108
+ }
109
+ const oe = {
110
+ clip: "rect(0 0 0 0)",
111
+ overflow: "hidden",
112
+ whiteSpace: "nowrap",
113
+ position: "fixed",
114
+ top: 0,
115
+ left: 0,
116
+ border: 0,
117
+ padding: 0,
118
+ width: 1,
119
+ height: 1,
120
+ margin: -1
121
+ };
122
+ function re(r) {
123
+ const {
124
+ disabled: e,
125
+ readOnly: n,
126
+ value: o,
127
+ required: t
128
+ } = r, {
129
+ checkedValue: d,
130
+ setCheckedValue: i,
131
+ onValueChange: u,
132
+ touched: l,
133
+ setTouched: m,
134
+ fieldControlValidation: f
135
+ } = w(), {
136
+ setDirty: R,
137
+ validityData: c,
138
+ setTouched: h,
139
+ setFilled: b,
140
+ validationMode: x
141
+ } = F(), g = d === o, C = a.useRef(null);
142
+ v(() => {
143
+ var y;
144
+ (y = C.current) != null && y.checked && b(!0);
145
+ }, [b]);
146
+ const P = a.useCallback((y) => I(f ? f.getValidationProps(y) : y, {
147
+ role: "radio",
148
+ type: "button",
149
+ "aria-checked": g,
150
+ "aria-required": t || void 0,
151
+ "aria-disabled": e || void 0,
152
+ "aria-readonly": n || void 0,
153
+ disabled: e,
154
+ onKeyDown(p) {
155
+ p.key === "Enter" && p.preventDefault();
156
+ },
157
+ onClick(p) {
158
+ var O;
159
+ p.defaultPrevented || e || n || (p.preventDefault(), (O = C.current) == null || O.click());
160
+ },
161
+ onFocus(p) {
162
+ var O;
163
+ p.defaultPrevented || e || n || !l || ((O = C.current) == null || O.click(), m(!1));
164
+ }
165
+ }), [f, g, t, e, n, l, m]), T = a.useCallback((y) => I(y, {
166
+ type: "radio",
167
+ ref: C,
168
+ tabIndex: -1,
169
+ style: oe,
170
+ "aria-hidden": !0,
171
+ disabled: e,
172
+ checked: g,
173
+ required: t,
174
+ readOnly: n,
175
+ onChange(p) {
176
+ p.nativeEvent.defaultPrevented || e || n || o == null || (h(!0), R(o !== c.initialValue), i(o), b(!0), u == null || u(o, p.nativeEvent), x === "onChange" && (f == null || f.commitValidation(o)));
177
+ }
178
+ }), [e, g, t, n, o, h, R, c.initialValue, i, b, u, x, f]);
179
+ return a.useMemo(() => ({
180
+ checked: g,
181
+ getRootProps: P,
182
+ getInputProps: T
183
+ }), [g, P, T]);
184
+ }
185
+ const D = /* @__PURE__ */ a.createContext(void 0);
186
+ process.env.NODE_ENV !== "production" && (D.displayName = "RadioRootContext");
187
+ function se() {
188
+ const r = a.useContext(D);
189
+ if (r === void 0)
190
+ throw new Error("Base UI: RadioRootContext is missing. Radio parts must be placed within <Radio.Root>.");
191
+ return r;
192
+ }
193
+ function ie(r = {}) {
194
+ const {
195
+ highlightedIndex: e,
196
+ onHighlightedIndexChange: n
197
+ } = q(), {
198
+ ref: o,
199
+ index: t
200
+ } = Y(r), d = e === t, i = a.useCallback((u = {}) => I(u, {
201
+ tabIndex: d ? 0 : -1,
202
+ onFocus() {
203
+ n(t);
204
+ }
205
+ }), [d, t, n]);
206
+ return a.useMemo(() => ({
207
+ getItemProps: i,
208
+ ref: o,
209
+ index: t
210
+ }), [i, o, t]);
211
+ }
212
+ function _(r) {
213
+ const {
214
+ render: e,
215
+ className: n,
216
+ itemRef: o,
217
+ metadata: t,
218
+ ...d
219
+ } = r, {
220
+ highlightedIndex: i
221
+ } = q(), {
222
+ getItemProps: u,
223
+ ref: l,
224
+ index: m
225
+ } = ie({
226
+ metadata: t
227
+ }), f = a.useMemo(() => ({
228
+ highlighted: m === i
229
+ }), [m, i]), R = V(o, l), {
230
+ renderElement: c
231
+ } = M({
232
+ propGetter: u,
233
+ ref: R,
234
+ render: e ?? "div",
235
+ state: f,
236
+ className: n,
237
+ extraProps: d
238
+ });
239
+ return c();
240
+ }
241
+ process.env.NODE_ENV !== "production" && (_.propTypes = {
242
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
243
+ // │ These PropTypes are generated from the TypeScript type definitions. │
244
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
245
+ // └─────────────────────────────────────────────────────────────────────┘
246
+ /**
247
+ * @ignore
248
+ */
249
+ children: s.node,
250
+ /**
251
+ * CSS class applied to the element, or a function that
252
+ * returns a class based on the component’s state.
253
+ */
254
+ className: s.oneOfType([s.func, s.string]),
255
+ /**
256
+ * @ignore
257
+ */
258
+ itemRef: z,
259
+ /**
260
+ * @ignore
261
+ */
262
+ metadata: s.any,
263
+ /**
264
+ * Allows you to replace the component’s HTML element
265
+ * with a different tag, or compose it with another component.
266
+ *
267
+ * Accepts a `ReactElement` or a function that returns the element to render.
268
+ */
269
+ render: s.oneOfType([s.element, s.func])
270
+ });
271
+ const H = {
272
+ checked(r) {
273
+ return r ? {
274
+ "data-checked": ""
275
+ } : {
276
+ "data-unchecked": ""
277
+ };
278
+ },
279
+ ...ee,
280
+ ...J
281
+ }, G = /* @__PURE__ */ a.forwardRef(function(e, n) {
282
+ const {
283
+ render: o,
284
+ className: t,
285
+ disabled: d = !1,
286
+ readOnly: i = !1,
287
+ required: u = !1,
288
+ ...l
289
+ } = e, {
290
+ disabled: m,
291
+ readOnly: f,
292
+ required: R,
293
+ setCheckedValue: c
294
+ } = w(), {
295
+ state: h,
296
+ disabled: b
297
+ } = F(), x = b || m || d, g = f || i, C = R || u, {
298
+ getRootProps: P,
299
+ getInputProps: T,
300
+ checked: y
301
+ } = re({
302
+ ...e,
303
+ disabled: x,
304
+ readOnly: g
305
+ }), p = a.useMemo(() => ({
306
+ ...h,
307
+ required: C,
308
+ disabled: x,
309
+ readOnly: g,
310
+ checked: y
311
+ }), [h, x, g, y, C]), O = a.useMemo(() => p, [p]), {
312
+ renderElement: S
313
+ } = M({
314
+ propGetter: P,
315
+ render: o ?? "button",
316
+ ref: n,
317
+ className: t,
318
+ state: p,
319
+ extraProps: l,
320
+ customStyleHookMapping: H
321
+ });
322
+ return /* @__PURE__ */ A(D.Provider, {
323
+ value: O,
324
+ children: [c === Q ? S() : /* @__PURE__ */ k(_, {
325
+ render: S()
326
+ }), /* @__PURE__ */ k("input", {
327
+ ...T()
328
+ })]
329
+ });
330
+ });
331
+ process.env.NODE_ENV !== "production" && (G.propTypes = {
332
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
333
+ // │ These PropTypes are generated from the TypeScript type definitions. │
334
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
335
+ // └─────────────────────────────────────────────────────────────────────┘
336
+ /**
337
+ * @ignore
338
+ */
339
+ children: s.node,
340
+ /**
341
+ * CSS class applied to the element, or a function that
342
+ * returns a class based on the component’s state.
343
+ */
344
+ className: s.oneOfType([s.func, s.string]),
345
+ /**
346
+ * Whether the component should ignore user interaction.
347
+ * @default false
348
+ */
349
+ disabled: s.bool,
350
+ /**
351
+ * Whether the user should be unable to select the radio button.
352
+ * @default false
353
+ */
354
+ readOnly: s.bool,
355
+ /**
356
+ * Allows you to replace the component’s HTML element
357
+ * with a different tag, or compose it with another component.
358
+ *
359
+ * Accepts a `ReactElement` or a function that returns the element to render.
360
+ */
361
+ render: s.oneOfType([s.element, s.func]),
362
+ /**
363
+ * Whether the user must choose a value before submitting a form.
364
+ * @default false
365
+ */
366
+ required: s.bool,
367
+ /**
368
+ * The unique identifying value of the radio in a group.
369
+ */
370
+ value: s.any.isRequired
371
+ });
372
+ const L = /* @__PURE__ */ a.forwardRef(function(e, n) {
373
+ const {
374
+ render: o,
375
+ className: t,
376
+ keepMounted: d = !1,
377
+ ...i
378
+ } = e, u = se(), l = u.checked, {
379
+ transitionStatus: m,
380
+ setMounted: f
381
+ } = X(l), R = a.useMemo(() => ({
382
+ ...u,
383
+ transitionStatus: m
384
+ }), [u, m]), c = a.useRef(null), h = V(n, c), {
385
+ renderElement: b
386
+ } = M({
387
+ render: o ?? "span",
388
+ ref: h,
389
+ className: t,
390
+ state: R,
391
+ extraProps: i,
392
+ customStyleHookMapping: H
393
+ });
394
+ return ne({
395
+ open: l,
396
+ ref: c,
397
+ onComplete() {
398
+ l || f(!1);
399
+ }
400
+ }), d || l ? b() : null;
401
+ });
402
+ process.env.NODE_ENV !== "production" && (L.propTypes = {
403
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
404
+ // │ These PropTypes are generated from the TypeScript type definitions. │
405
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
406
+ // └─────────────────────────────────────────────────────────────────────┘
407
+ /**
408
+ * @ignore
409
+ */
410
+ children: s.node,
411
+ /**
412
+ * CSS class applied to the element, or a function that
413
+ * returns a class based on the component’s state.
414
+ */
415
+ className: s.oneOfType([s.func, s.string]),
416
+ /**
417
+ * Whether to keep the HTML element in the DOM when the radio button is inactive.
418
+ * @default false
419
+ */
420
+ keepMounted: s.bool,
421
+ /**
422
+ * Allows you to replace the component’s HTML element
423
+ * with a different tag, or compose it with another component.
424
+ *
425
+ * Accepts a `ReactElement` or a function that returns the element to render.
426
+ */
427
+ render: s.oneOfType([s.element, s.func])
428
+ });
429
+ const Te = ({ label: r, value: e, disabled: n, "data-testid": o }) => {
430
+ const t = B(N["radio-label"], n && N["radio-label__disabled"]);
431
+ return /* @__PURE__ */ A("label", { className: N.option, "data-testid": o, children: [
432
+ /* @__PURE__ */ k(G, { disabled: n, value: e, className: N.radio, children: /* @__PURE__ */ k(L, { className: N.indicator }) }),
433
+ /* @__PURE__ */ k(K, { color: "var(--colors-neutral-text-color-text)", className: t, variant: "base-lg", children: r })
434
+ ] });
435
+ };
436
+ export {
437
+ Te as RadioOption
438
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pismo/marola",
3
3
  "description": "CDX tribe component library",
4
- "version": "2.0.0",
4
+ "version": "2.0.2",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",
@@ -97,6 +97,7 @@
97
97
  "vitest-preview": "^0.0.1"
98
98
  },
99
99
  "dependencies": {
100
+ "@base-ui-components/react": "^1.0.0-alpha.6",
100
101
  "@mui/base": "^5.0.0-beta.40",
101
102
  "@mui/material": "^5.15.15"
102
103
  }