@sqrzro/ui 4.0.0-alpha.75 → 4.0.0-alpha.77

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.
@@ -5,8 +5,8 @@ import { usePathname } from 'next/navigation';
5
5
  import Switch from '../../../forms/components/Switch';
6
6
  import { useClassNames } from '../../../styles/context';
7
7
  import tw from '../../../styles/classnames/utility/tw';
8
+ import normalizeHref from '../../../utility/normalize-href';
8
9
  import Link from '../../elements/Link';
9
- import normalizeHref from '../utility/normalize-href';
10
10
  import ListItemSecondary from '../ListItemSecondary';
11
11
  import ListItemMeta from '../ListItemMeta';
12
12
  import ListItemMenu from '../ListItemMenu';
@@ -4,7 +4,7 @@ import { formatDate, formatDatetime, formatMoney, formatPoints, formatTime } fro
4
4
  import { usePathname } from 'next/navigation';
5
5
  import Link from '../../../components/elements/Link';
6
6
  import Reference from '../../../components/elements/Reference';
7
- import normalizeHref from './normalize-href';
7
+ import normalizeHref from '../../../utility/normalize-href';
8
8
  function renderDefault(value) {
9
9
  return value;
10
10
  }
@@ -3,6 +3,8 @@ import type { CheckboxInputComponentProps } from '../CheckboxInput';
3
3
  import type { ColorInputComponentProps } from '../ColorInput';
4
4
  import type { DropdownComponentProps } from '../Dropdown';
5
5
  import type { ImageInputComponentProps } from '../ImageInput';
6
+ import type { NumberInputComponentProps } from '../NumberInput';
7
+ import type { PointsInputComponentProps } from '../PointsInput';
6
8
  import type { SwitchComponentProps } from '../Switch';
7
9
  import type { TextAreaComponentProps } from '../TextArea';
8
10
  import type { TextInputComponentProps } from '../TextInput';
@@ -14,6 +16,12 @@ export type EditableDropdownFormFieldProps<T> = EditableFormFieldComponentProps<
14
16
  export declare function EditableDropdownFormField<T>(props: Readonly<EditableDropdownFormFieldProps<T>>): React.ReactElement;
15
17
  export type EditableImageFormFieldProps = EditableFormFieldComponentProps<string | null> & ImageInputComponentProps;
16
18
  export declare function EditableImageFormField(props: Readonly<EditableImageFormFieldProps>): React.ReactElement;
19
+ export type EditableMoneyFormFieldProps = EditableFormFieldComponentProps<number> & PointsInputComponentProps;
20
+ export declare function EditableMoneyFormField(props: Readonly<EditableMoneyFormFieldProps>): React.ReactElement;
21
+ export type EditableNumberFormFieldProps = EditableFormFieldComponentProps<number> & NumberInputComponentProps;
22
+ export declare function EditableNumberFormField(props: Readonly<EditableNumberFormFieldProps>): React.ReactElement;
23
+ export type EditablePointsFormFieldProps = EditableFormFieldComponentProps<number> & PointsInputComponentProps;
24
+ export declare function EditablePointsFormField(props: Readonly<EditablePointsFormFieldProps>): React.ReactElement;
17
25
  export type EditableSwitchFormFieldProps = EditableFormFieldComponentProps<boolean> & SwitchComponentProps;
18
26
  export declare function EditableSwitchFormField(props: Readonly<EditableSwitchFormFieldProps>): React.ReactElement;
19
27
  export type EditableTextAreaFormFieldProps = EditableFormFieldComponentProps<string> & TextAreaComponentProps;
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback } from 'react';
3
+ import { formatMoney, formatPoints } from '@sqrzro/utility';
3
4
  import { useClassNames } from '../../../styles/context';
4
5
  import tw from '../../../styles/classnames/utility/tw';
5
6
  import extractEditableInputProps from '../../utility/extract-editable-input-props';
@@ -8,6 +9,8 @@ import ColorInput from '../ColorInput';
8
9
  import Dropdown from '../Dropdown';
9
10
  import EditableFormField from '../EditableFormField';
10
11
  import ImageInput from '../ImageInput';
12
+ import NumberInput from '../NumberInput';
13
+ import PointsInput from '../PointsInput';
11
14
  import Switch from '../Switch';
12
15
  import TextArea from '../TextArea';
13
16
  import TextInput from '../TextInput';
@@ -58,6 +61,21 @@ export function EditableImageFormField(props) {
58
61
  }, [fieldProps.value]);
59
62
  return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: renderValue });
60
63
  }
64
+ export function EditableMoneyFormField(props) {
65
+ const { fieldProps, inputProps } = extractEditableInputProps(props);
66
+ const renderInput = useCallback((renderProps) => (_jsx(PointsInput, { ...renderProps, ...inputProps, prefix: "\u00A3" })), [inputProps]);
67
+ return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: formatMoney });
68
+ }
69
+ export function EditableNumberFormField(props) {
70
+ const { fieldProps, inputProps } = extractEditableInputProps(props);
71
+ const renderInput = useCallback((renderProps) => (_jsx(NumberInput, { ...renderProps, ...inputProps })), [inputProps]);
72
+ return _jsx(EditableFormField, { ...fieldProps, render: renderInput });
73
+ }
74
+ export function EditablePointsFormField(props) {
75
+ const { fieldProps, inputProps } = extractEditableInputProps(props);
76
+ const renderInput = useCallback((renderProps) => (_jsx(PointsInput, { ...renderProps, ...inputProps })), [inputProps]);
77
+ return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: formatPoints });
78
+ }
61
79
  export function EditableSwitchFormField(props) {
62
80
  const { fieldProps, inputProps } = extractEditableInputProps(props);
63
81
  const renderInput = useCallback((renderProps) => (_jsx(Switch, { ...renderProps, ...inputProps, label: null })), [inputProps]);
@@ -5,9 +5,9 @@ import type { CalendarInputComponentProps } from '../CalendarInput';
5
5
  import type { CheckboxInputComponentProps } from '../CheckboxInput';
6
6
  import type { DropdownComponentProps } from '../Dropdown';
7
7
  import type { ImageInputComponentProps } from '../ImageInput';
8
- import type { PointsInputComponentProps } from '../PointsInput';
9
8
  import type { NumberInputComponentProps } from '../NumberInput';
10
9
  import type { PasswordInputComponentProps } from '../PasswordInput';
10
+ import type { PointsInputComponentProps } from '../PointsInput';
11
11
  import type { RangeCalendarInputComponentProps } from '../RangeCalendarInput';
12
12
  import type { SwitchComponentProps } from '../Switch';
13
13
  import type { TextAreaComponentProps } from '../TextArea';
@@ -32,6 +32,8 @@ export type NumberFormFieldProps = FormFieldComponentProps<number> & NumberInput
32
32
  export declare function NumberFormField(props: Readonly<NumberFormFieldProps>): React.ReactElement;
33
33
  export type PasswordFormFieldProps = FormFieldComponentProps<string> & PasswordInputComponentProps;
34
34
  export declare function PasswordFormField(props: Readonly<PasswordFormFieldProps>): React.ReactElement;
35
+ export type PointsFormFieldProps = FormFieldComponentProps<number> & PointsInputComponentProps;
36
+ export declare function PointsFormField(props: Readonly<PointsFormFieldProps>): React.ReactElement;
35
37
  export type RangeCalendarFormFieldProps = FormFieldComponentProps<[Date, Date] | null> & RangeCalendarInputComponentProps;
36
38
  export declare function RangeCalendarFormField(props: Readonly<RangeCalendarFormFieldProps>): React.ReactElement;
37
39
  export type SwitchFormFieldProps = FormFieldComponentProps<boolean> & SwitchComponentProps;
@@ -9,9 +9,9 @@ import CheckboxInput from '../CheckboxInput';
9
9
  import Dropdown from '../Dropdown';
10
10
  import FormField from '../FormField';
11
11
  import ImageInput from '../ImageInput';
12
- import PointsInput from '../PointsInput';
13
12
  import NumberInput from '../NumberInput';
14
13
  import PasswordInput from '../PasswordInput';
14
+ import PointsInput from '../PointsInput';
15
15
  import RangeCalendarInput from '../RangeCalendarInput';
16
16
  import Switch from '../Switch';
17
17
  import TextArea from '../TextArea';
@@ -53,7 +53,7 @@ export function ImageFormField(props) {
53
53
  }
54
54
  export function MoneyFormField(props) {
55
55
  const { fieldProps, inputProps } = extractInputProps(props);
56
- const renderInput = useCallback((renderProps) => (_jsx(PointsInput, { ...renderProps, ...inputProps })), [inputProps]);
56
+ const renderInput = useCallback((renderProps) => (_jsx(PointsInput, { ...renderProps, ...inputProps, prefix: "\u00A3" })), [inputProps]);
57
57
  return _jsx(FormField, { ...fieldProps, render: renderInput });
58
58
  }
59
59
  export function NumberFormField(props) {
@@ -66,6 +66,11 @@ export function PasswordFormField(props) {
66
66
  const renderInput = useCallback((renderProps) => (_jsx(PasswordInput, { ...renderProps, ...inputProps })), [inputProps]);
67
67
  return _jsx(FormField, { ...fieldProps, render: renderInput });
68
68
  }
69
+ export function PointsFormField(props) {
70
+ const { fieldProps, inputProps } = extractInputProps(props);
71
+ const renderInput = useCallback((renderProps) => (_jsx(PointsInput, { ...renderProps, ...inputProps })), [inputProps]);
72
+ return _jsx(FormField, { ...fieldProps, render: renderInput });
73
+ }
69
74
  export function RangeCalendarFormField(props) {
70
75
  const { fieldProps, inputProps } = extractInputProps(props);
71
76
  const renderInput = useCallback((renderProps) => (_jsx(RangeCalendarInput, { ...renderProps, ...inputProps })), [inputProps]);
@@ -1,5 +1,7 @@
1
- import { useRouter } from 'next/navigation';
1
+ import { usePathname, useRouter } from 'next/navigation';
2
+ import normalizeHref from '../utility/normalize-href';
2
3
  function useSuccess({ onSuccess, redirectOnSuccess, refreshOnSuccess, }) {
4
+ const pathname = usePathname();
3
5
  const router = useRouter();
4
6
  async function handleSuccess(response) {
5
7
  if (onSuccess) {
@@ -10,7 +12,7 @@ function useSuccess({ onSuccess, redirectOnSuccess, refreshOnSuccess, }) {
10
12
  ? await redirectOnSuccess(response)
11
13
  : redirectOnSuccess;
12
14
  if (url) {
13
- router.push(url);
15
+ router.push(normalizeHref(url, pathname));
14
16
  }
15
17
  }
16
18
  else if (refreshOnSuccess) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sqrzro/ui",
3
3
  "type": "module",
4
- "version": "4.0.0-alpha.75",
4
+ "version": "4.0.0-alpha.77",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "ISC",
@@ -50,15 +50,15 @@
50
50
  "dist/**/*"
51
51
  ],
52
52
  "dependencies": {
53
+ "@sqrzro/addons": "^4.0.0-alpha.14",
54
+ "@sqrzro/utility": "^4.0.0-alpha.22",
53
55
  "clsx": "^2.1.1",
54
56
  "drizzle-orm": "^0.45.2",
55
57
  "next": "^16.2.11",
56
58
  "react": "^19.2.8",
57
59
  "react-dom": "^19.2.8",
58
60
  "tailwind-merge": "^3.6.0",
59
- "use-deep-compare-effect": "^1.8.1",
60
- "@sqrzro/addons": "^4.0.0-alpha.14",
61
- "@sqrzro/utility": "^4.0.0-alpha.21"
61
+ "use-deep-compare-effect": "^1.8.1"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@storybook/addon-a11y": "^10.5.3",