@faststore/ui 2.0.48-alpha.0 → 2.0.50-alpha.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.
@@ -1,5 +0,0 @@
1
- import type { PropsWithChildren } from 'react';
2
- import { RadioGroupContext } from './useRadioGroup';
3
- export type RadioGroupProps = PropsWithChildren<RadioGroupContext>;
4
- declare const RadioGroup: ({ name, onChange, children, selectedValue, }: RadioGroupProps) => JSX.Element;
5
- export default RadioGroup;
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- import { RadioGroupContext } from './useRadioGroup';
3
- const RadioGroup = ({ name, onChange, children, selectedValue, }) => {
4
- const contextValues = React.useMemo(() => {
5
- return { name, selectedValue, onChange };
6
- }, [name, selectedValue, onChange]);
7
- return (React.createElement(RadioGroupContext.Provider, { value: contextValues }, children));
8
- };
9
- export default RadioGroup;
10
- //# sourceMappingURL=RadioGroup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RadioGroup.js","sourceRoot":"","sources":["../../../../src/components/molecules/RadioGroup/RadioGroup.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAInD,MAAM,UAAU,GAAG,CAAC,EAClB,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,aAAa,GACG,EAAE,EAAE;IACpB,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACvC,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA;IAC1C,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAA;IAEnC,OAAO,CACL,oBAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,IAC7C,QAAQ,CACkB,CAC9B,CAAA;AACH,CAAC,CAAA;AAED,eAAe,UAAU,CAAA"}
@@ -1,19 +0,0 @@
1
- import type { InputHTMLAttributes } from 'react';
2
- import React from 'react';
3
- export interface RadioOptionProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
4
- /**
5
- * ID to find this component in testing tools (e.g.: cypress,
6
- * testing-library, and jest).
7
- */
8
- testId?: string;
9
- /**
10
- * Attribute to set aria-label option as required.
11
- */
12
- label: string;
13
- /**
14
- * Value to be emitted when radio is clicked.
15
- */
16
- value: string | number;
17
- }
18
- declare const RadioOption: React.ForwardRefExoticComponent<RadioOptionProps & React.RefAttributes<HTMLInputElement>>;
19
- export default RadioOption;
@@ -1,11 +0,0 @@
1
- import React, { forwardRef } from 'react';
2
- import { Radio } from '@faststore/components';
3
- import { useRadioGroup } from './useRadioGroup';
4
- const RadioOption = forwardRef(function RadioOption({ label, value, children, testId = 'store-radio-option', ...otherProps }, ref) {
5
- const { name, selectedValue, onChange } = useRadioGroup();
6
- return (React.createElement("label", { "aria-label": label, "data-fs-radio-option": true },
7
- React.createElement(Radio, { "data-fs-radio-option-item": true, ref: ref, name: name, checked: value === selectedValue, onChange: onChange, value: value, testId: testId, ...otherProps }),
8
- children));
9
- });
10
- export default RadioOption;
11
- //# sourceMappingURL=RadioOption.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RadioOption.js","sourceRoot":"","sources":["../../../../src/components/molecules/RadioGroup/RadioOption.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAmB/C,MAAM,WAAW,GAAG,UAAU,CAC5B,SAAS,WAAW,CAClB,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,oBAAoB,EAAE,GAAG,UAAU,EAAE,EACxE,GAAG;IAEH,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,CAAA;IAEzD,OAAO,CACL,6CAAmB,KAAK;QACtB,oBAAC,KAAK,uCAEJ,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,KAAK,KAAK,aAAa,EAChC,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,KACV,UAAU,GACd;QACD,QAAQ,CACH,CACT,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,WAAW,CAAA"}
@@ -1,4 +0,0 @@
1
- export { default } from './RadioGroup';
2
- export type { RadioGroupProps } from './RadioGroup';
3
- export { default as RadioOption } from './RadioOption';
4
- export type { RadioOptionProps } from './RadioOption';
@@ -1,3 +0,0 @@
1
- export { default } from './RadioGroup';
2
- export { default as RadioOption } from './RadioOption';
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/molecules/RadioGroup/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA"}
@@ -1,17 +0,0 @@
1
- import type { ChangeEventHandler } from 'react';
2
- export interface RadioGroupContext {
3
- /**
4
- * Name to link children by context.
5
- */
6
- name: string;
7
- /**
8
- * Value of checked child.
9
- */
10
- selectedValue?: string | number;
11
- /**
12
- * Function that is triggered when any children is checked.
13
- */
14
- onChange?: ChangeEventHandler<HTMLInputElement>;
15
- }
16
- export declare const RadioGroupContext: import("react").Context<RadioGroupContext | undefined>;
17
- export declare function useRadioGroup(): RadioGroupContext;
@@ -1,10 +0,0 @@
1
- import { createContext, useContext } from 'react';
2
- export const RadioGroupContext = createContext(undefined);
3
- export function useRadioGroup() {
4
- const context = useContext(RadioGroupContext);
5
- if (!context) {
6
- throw new Error(`useRadioOption hook cannot be used outside the RadioGroup context`);
7
- }
8
- return context;
9
- }
10
- //# sourceMappingURL=useRadioGroup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useRadioGroup.js","sourceRoot":"","sources":["../../../../src/components/molecules/RadioGroup/useRadioGroup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAiBjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAC5C,SAAS,CACV,CAAA;AAED,MAAM,UAAU,aAAa;IAC3B,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAA;IAE7C,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAA;KACF;IAED,OAAO,OAAO,CAAA;AAChB,CAAC"}
@@ -1,25 +0,0 @@
1
- import type { PropsWithChildren } from 'react'
2
- import React from 'react'
3
-
4
- import { RadioGroupContext } from './useRadioGroup'
5
-
6
- export type RadioGroupProps = PropsWithChildren<RadioGroupContext>
7
-
8
- const RadioGroup = ({
9
- name,
10
- onChange,
11
- children,
12
- selectedValue,
13
- }: RadioGroupProps) => {
14
- const contextValues = React.useMemo(() => {
15
- return { name, selectedValue, onChange }
16
- }, [name, selectedValue, onChange])
17
-
18
- return (
19
- <RadioGroupContext.Provider value={contextValues}>
20
- {children}
21
- </RadioGroupContext.Provider>
22
- )
23
- }
24
-
25
- export default RadioGroup
@@ -1,49 +0,0 @@
1
- import type { InputHTMLAttributes } from 'react'
2
- import React, { forwardRef } from 'react'
3
-
4
- import { Radio } from '@faststore/components'
5
- import { useRadioGroup } from './useRadioGroup'
6
-
7
- export interface RadioOptionProps
8
- extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
9
- /**
10
- * ID to find this component in testing tools (e.g.: cypress,
11
- * testing-library, and jest).
12
- */
13
- testId?: string
14
- /**
15
- * Attribute to set aria-label option as required.
16
- */
17
- label: string
18
- /**
19
- * Value to be emitted when radio is clicked.
20
- */
21
- value: string | number
22
- }
23
-
24
- const RadioOption = forwardRef<HTMLInputElement, RadioOptionProps>(
25
- function RadioOption(
26
- { label, value, children, testId = 'store-radio-option', ...otherProps },
27
- ref
28
- ) {
29
- const { name, selectedValue, onChange } = useRadioGroup()
30
-
31
- return (
32
- <label aria-label={label} data-fs-radio-option>
33
- <Radio
34
- data-fs-radio-option-item
35
- ref={ref}
36
- name={name}
37
- checked={value === selectedValue}
38
- onChange={onChange}
39
- value={value}
40
- testId={testId}
41
- {...otherProps}
42
- />
43
- {children}
44
- </label>
45
- )
46
- }
47
- )
48
-
49
- export default RadioOption
@@ -1,5 +0,0 @@
1
- export { default } from './RadioGroup'
2
- export type { RadioGroupProps } from './RadioGroup'
3
-
4
- export { default as RadioOption } from './RadioOption'
5
- export type { RadioOptionProps } from './RadioOption'
@@ -1,33 +0,0 @@
1
- import type { ChangeEventHandler } from 'react'
2
- import { createContext, useContext } from 'react'
3
-
4
- export interface RadioGroupContext {
5
- /**
6
- * Name to link children by context.
7
- */
8
- name: string
9
- /**
10
- * Value of checked child.
11
- */
12
- selectedValue?: string | number
13
- /**
14
- * Function that is triggered when any children is checked.
15
- */
16
- onChange?: ChangeEventHandler<HTMLInputElement>
17
- }
18
-
19
- export const RadioGroupContext = createContext<RadioGroupContext | undefined>(
20
- undefined
21
- )
22
-
23
- export function useRadioGroup() {
24
- const context = useContext(RadioGroupContext)
25
-
26
- if (!context) {
27
- throw new Error(
28
- `useRadioOption hook cannot be used outside the RadioGroup context`
29
- )
30
- }
31
-
32
- return context
33
- }