@pagamio/frontend-commons-lib 0.8.261 → 0.8.263

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.
@@ -102,13 +102,21 @@ const DateRangePickerWithPresets = ({ value, onChange, presets = defaultDatePres
102
102
  }, [isOpen, value, selectedPreset]);
103
103
  // Format the display text
104
104
  const displayText = useMemo(() => {
105
- if (!value?.from)
106
- return placeholder;
107
- if (value.to) {
108
- return `${format(value.from, dateFormat)} - ${format(value.to, dateFormat)}`;
105
+ // Custom range with dates selected — show the formatted date range
106
+ if (value?.from) {
107
+ if (value.to) {
108
+ return `${format(value.from, dateFormat)} - ${format(value.to, dateFormat)}`;
109
+ }
110
+ return format(value.from, dateFormat);
111
+ }
112
+ // No custom dates — show the active preset label
113
+ if (selectedPreset && selectedPreset !== 'custom') {
114
+ const activePreset = presets.find((p) => p.value === selectedPreset);
115
+ if (activePreset)
116
+ return activePreset.label;
109
117
  }
110
- return format(value.from, dateFormat);
111
- }, [value, dateFormat, placeholder]);
118
+ return placeholder;
119
+ }, [value, dateFormat, placeholder, selectedPreset, presets]);
112
120
  // Handle preset selection
113
121
  const handlePresetSelect = (preset) => {
114
122
  // For custom preset, preserve current selection or clear it
@@ -160,7 +168,7 @@ const DateRangePickerWithPresets = ({ value, onChange, presets = defaultDatePres
160
168
  ? `${format(tempRange.from, dateFormat)} - ${format(tempRange.to, dateFormat)}`
161
169
  : tempRange?.from
162
170
  ? format(tempRange.from, dateFormat)
163
- : 'Select a range' }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { variant: "outline", size: "sm", onClick: handleCancel, children: "Cancel" }), _jsx(Button, { size: "sm", onClick: handleApply, disabled: !tempRange?.from, children: "Apply" })] })] })] }))] }) })] }));
171
+ : 'Select a range' }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { variant: "outline", size: "sm", onClick: handleCancel, children: "Cancel" }), _jsx(Button, { size: "sm", onClick: handleApply, disabled: !tempRange?.from || !tempRange?.to, children: "Apply" })] })] })] }))] }) })] }));
164
172
  };
165
173
  DateRangePickerWithPresets.displayName = 'DateRangePickerWithPresets';
166
174
  export default DateRangePickerWithPresets;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { InputProps } from '../../../types';
3
+ declare const ColorInput: React.ForwardRefExoticComponent<Omit<InputProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
4
+ export default ColorInput;
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ColorInput as MantineColorInput } from '@mantine/core';
3
+ import React from 'react';
4
+ const ColorInput = React.forwardRef(({ field, error, value, onChange, ...props }, ref) => {
5
+ return (_jsxs(_Fragment, { children: [_jsx("label", { htmlFor: field.name, className: "block text-sm font-medium text-foreground", children: field.label }), _jsx(MantineColorInput, { ref: ref, id: field.name, value: value || '', onChange: (color) => onChange(color), disabled: field.disabled, placeholder: field.placeholder || 'Pick a color', format: "hex", swatches: [
6
+ '#25262b',
7
+ '#868e96',
8
+ '#fa5252',
9
+ '#e64980',
10
+ '#be4bdb',
11
+ '#7950f2',
12
+ '#4c6ef5',
13
+ '#228be6',
14
+ '#15aabf',
15
+ '#12b886',
16
+ '#40c057',
17
+ '#82c91e',
18
+ '#fab005',
19
+ '#fd7e14',
20
+ ], error: error?.message, className: "mt-1" })] }));
21
+ });
22
+ export default ColorInput;
@@ -0,0 +1 @@
1
+ export { default as ColorInput } from './ColorInput';
@@ -0,0 +1 @@
1
+ export { default as ColorInput } from './ColorInput';
@@ -31,9 +31,10 @@ export const setupInputRegistry = async () => {
31
31
  return getRegistryPromise();
32
32
  };
33
33
  const doSetup = async () => {
34
- const [{ default: CardExpiryInput }, { default: CheckboxInput }, { default: CreditCardInput }, { default: DateInput }, { default: EmailInput }, { default: LabelInput }, { default: MultiSelectInputComponent }, { default: NumberInput }, { default: PasswordInput }, { default: RadioInput }, { default: SelectInput }, { default: TextareaInputFW }, { default: TimeInput }, { default: ToggleSwitchInput }, { default: UploadFieldForm }, { default: PhoneInput },] = await Promise.all([
34
+ const [{ default: CardExpiryInput }, { default: CheckboxInput }, { default: ColorInput }, { default: CreditCardInput }, { default: DateInput }, { default: EmailInput }, { default: LabelInput }, { default: MultiSelectInputComponent }, { default: NumberInput }, { default: PasswordInput }, { default: RadioInput }, { default: SelectInput }, { default: TextareaInputFW }, { default: TimeInput }, { default: ToggleSwitchInput }, { default: UploadFieldForm }, { default: PhoneInput },] = await Promise.all([
35
35
  import('../components/inputs/card-expiry-input/CardExpiryInput'),
36
36
  import('../components/inputs/checkbox-input/CheckboxInput'),
37
+ import('../components/inputs/color-input/ColorInput'),
37
38
  import('../components/inputs/credit-card-input/CreditCardInput'),
38
39
  import('../components/inputs/date-input/DateInput'),
39
40
  import('../components/inputs/email-input/EmailInput'),
@@ -51,6 +52,7 @@ const doSetup = async () => {
51
52
  ]);
52
53
  registerInput('card-expiry-input', CardExpiryInput);
53
54
  registerInput('checkbox', CheckboxInput);
55
+ registerInput('color', ColorInput);
54
56
  registerInput('credit-card', CreditCardInput);
55
57
  registerInput('date', DateInput);
56
58
  registerInput('email', EmailInput);
@@ -130,7 +130,7 @@ export interface DependencyValidation {
130
130
  /**
131
131
  * Available field types supported by the form engine
132
132
  */
133
- export type FieldType = 'card-expiry-input' | 'checkbox' | 'credit-card' | 'date' | 'email' | 'file' | 'multi-select' | 'number' | 'password' | 'radio' | 'searchable-multi-select' | 'select' | 'switch' | 'tel' | 'text' | 'textarea' | 'time';
133
+ export type FieldType = 'card-expiry-input' | 'checkbox' | 'color' | 'credit-card' | 'date' | 'email' | 'file' | 'multi-select' | 'number' | 'password' | 'radio' | 'searchable-multi-select' | 'select' | 'switch' | 'tel' | 'text' | 'textarea' | 'time';
134
134
  /**
135
135
  * Defines the structure of a form field
136
136
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pagamio/frontend-commons-lib",
3
3
  "description": "Pagamio library for Frontend reusable components like the form engine and table container",
4
- "version": "0.8.261",
4
+ "version": "0.8.263",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "provenance": false