@g4rcez/components 0.0.49 → 0.0.50

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.
@@ -33,3 +33,6 @@ export const Alert = forwardRef(function Alert({ className, theme, Icon, onClose
33
33
  const close = () => onClose?.(false);
34
34
  return (_jsx("div", { "data-open": !!open, "aria-hidden": !open, className: "pointer-events-none w-full isolate aria-hidden:pointer-events-auto", children: _jsx(Collapse, { "data-open": !!open, open: !!open, children: _jsxs(Polymorph, { ...props, className: css(alertVariants({ theme }), className), ref: ref, "data-theme": theme, role: "alert", as: props.as ?? "div", children: [_jsxs("h4", { className: "mb-2 flex items-center gap-2", children: [!Icon && theme === "success" ? _jsx(CheckCircleIcon, { size: 20 }) : null, !Icon && theme === "info" ? _jsx(InfoIcon, { size: 20 }) : null, !Icon && theme === "danger" ? _jsx(TriangleAlertIcon, { size: 20 }) : null, Icon, _jsx("span", { className: "tracking-3 text-balance text-lg font-semibold", children: props.title })] }), props.children, onClose !== undefined ? (_jsx("button", { type: "button", onClick: close, className: "absolute right-3 top-3 text-foreground transition-colors duration-300 ease-in-out hover:text-danger", children: _jsx(XIcon, { size: 20 }) })) : null] }) }) }));
35
35
  });
36
+ const Testing = (props) => {
37
+ return;
38
+ };
@@ -62,17 +62,17 @@ export const Calendar = ({ RenderOnDay, changeOnlyOnClick = false, labelRange, d
62
62
  const translate = useTranslations();
63
63
  const root = useRef(null);
64
64
  const { date, range } = props;
65
- const now = date || new Date();
65
+ const providedDate = date || new Date();
66
66
  const monthClicked = useRef(null);
67
67
  const [state, dispatch] = useReducer({
68
- date: now,
68
+ date: providedDate,
69
69
  isAnimating: false,
70
- year: formatYear(now),
71
- months: getOptionsMonth(now, locale),
70
+ year: formatYear(providedDate),
72
71
  direction: undefined,
73
72
  range: { from: range?.from, to: range?.to },
73
+ months: getOptionsMonth(providedDate, locale),
74
74
  selectMode: (rangeMode ? "from" : undefined),
75
- week: eachDayOfInterval({ start: startOfWeek(now), end: endOfWeek(now) }),
75
+ week: eachDayOfInterval({ start: startOfWeek(providedDate), end: endOfWeek(providedDate) }),
76
76
  }, (get) => ({
77
77
  onChangeYear: (year) => ({ year }),
78
78
  setToday: () => ({ date: startOfDay(new Date()) }),
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAoF,MAAM,OAAO,CAAC;AAIzG,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC;AAErF,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,UAAU,CAAC,GAAG;IACrF,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,qBAAqB,CAAC;CACjC,CAAC;AAIF,eAAO,MAAM,MAAM,4GAuBjB,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,qBAAqB,EAAE,CAAC;CACpC,CAAC;AAaF,eAAO,MAAM,YAAY,yGAiQxB,CAAC"}
1
+ {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAoF,MAAM,OAAO,CAAC;AAIzG,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC;AAErF,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,UAAU,CAAC,GAAG;IACrF,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,qBAAqB,CAAC;CACjC,CAAC;AAIF,eAAO,MAAM,MAAM,4GAuBjB,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,qBAAqB,EAAE,CAAC;CACpC,CAAC;AAaF,eAAO,MAAM,YAAY,yGAiRxB,CAAC"}
@@ -1,5 +1,4 @@
1
1
  "use client";
2
- import { createElement as _createElement } from "react";
3
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
3
  import { autoUpdate, FloatingFocusManager, FloatingPortal, offset, size, useDismiss, useFloating, useInteractions, useListNavigation, useRole, useTransitionStyles, } from "@floating-ui/react";
5
4
  import Fuzzy from "fuzzy-search";
@@ -13,7 +12,7 @@ const Frag = (props) => _jsx(Fragment, { children: props.children });
13
12
  export const Option = forwardRef(({ selected, active, onClick, option, ...props }, ref) => {
14
13
  const Label = option.Render ?? Frag;
15
14
  const children = option.label ?? option.value;
16
- return (_jsx("li", { ...props, ref: ref, role: "option", "aria-selected": active, className: "w-full border-b border-tooltip-border last:border-transparent", children: _jsxs("button", { type: "button", "data-value": option.value, onClick: onClick, "aria-selected": active, "aria-checked": active, "aria-current": active, className: `flex w-full cursor-pointer justify-between p-2 text-left ${active ? "bg-primary text-primary-foreground" : ""} ${selected ? "bg-primary/70 text-primary-foreground" : ""}`, children: [_jsx(Label, { ...props, label: option.label, value: option.value, children: children }), active ? (_jsx("span", { children: _jsx(CheckIcon, { "aria-hidden": true, className: "text-current", absoluteStrokeWidth: true, strokeWidth: 2, size: 22 }) })) : null] }) }));
15
+ return (_jsx("li", { ...props, ref: ref, role: "option", "aria-selected": active, className: "w-full border-b border-tooltip-border last:border-transparent", children: _jsxs("button", { type: "button", "data-value": option.value, onClick: onClick, "aria-selected": active, "aria-checked": active, "aria-current": active, className: `flex w-full cursor-pointer justify-between p-2 text-left ${active ? "bg-primary-hover text-primary-foreground" : ""} ${selected ? "bg-primary text-primary-foreground" : ""}`, children: [_jsx(Label, { ...props, label: option.label, value: option.value, children: children }), active ? (_jsx("span", { children: _jsx(CheckIcon, { "aria-hidden": true, className: "text-current", absoluteStrokeWidth: true, strokeWidth: 2, size: 22 }) })) : null] }) }));
17
16
  });
18
17
  const transitionStyles = {
19
18
  duration: 300,
@@ -29,10 +28,19 @@ export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedba
29
28
  const [open, setOpen] = useState(false);
30
29
  const [shadow, setShadow] = useState("");
31
30
  const [value, setValue] = useState(defaults);
32
- const [label, setLabel] = useState(defaults);
31
+ const [label, setLabel] = useState(() => options.find((x) => x.value === defaults)?.label ?? defaults);
33
32
  const [index, setIndex] = useState(null);
34
33
  const listRef = useRef(emptyRef);
35
- const innerOptions = dynamicOption && shadow !== "" ? [{ value: shadow, label: shadow, "data-dynamic": "true" }, ...options] : options;
34
+ const innerOptions = dynamicOption && shadow !== ""
35
+ ? [
36
+ {
37
+ value: shadow,
38
+ label: shadow,
39
+ "data-dynamic": "true",
40
+ },
41
+ ...options,
42
+ ]
43
+ : options;
36
44
  const list = new Fuzzy(innerOptions, ["value", "label"], fuzzyOptions).search(shadow);
37
45
  const pattern = dynamicOption
38
46
  ? undefined
@@ -156,11 +164,18 @@ export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedba
156
164
  },
157
165
  }), "data-value": value, "data-error": !!error, "data-name": id, "data-target": id, required: required, value: open ? shadow : label || value, "aria-autocomplete": "list", autoComplete: "off", className: css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "group-focus-within:border-primary group-hover:border-primary", props.className) }), _jsx("input", { id: id, name: id, type: "hidden", "data-origin": id, ref: externalRef, required: required, defaultValue: props.value || value || undefined }), _jsx(FloatingPortal, { preserveTabOrder: true, children: open ? (_jsx(FloatingFocusManager, { guards: true, returnFocus: false, context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: _jsx("ul", { ...getFloatingProps({
158
166
  ref: refs.setFloating,
159
- style: { position: strategy, left: (x ?? 0) + 16, top: y ?? 0, ...transitions.styles },
160
- }), "data-floating": "true", className: "z-floating m-0 origin-[top_center] list-none overflow-auto overflow-y-auto rounded-b-lg rounded-t-lg border border-floating-border bg-floating-background p-0 text-foreground shadow-floating", children: list.map((option, i) => (_createElement(Option, { ...getItemProps({
161
- onClick: () => onSelect(option, i),
162
- ref: (node) => void (listRef.current[i] = node),
163
- selected: index === i,
164
- active: value === option.value,
165
- }), key: `${option.value}-option`, option: option, selected: index === i, active: value === option.value }))) }) })) : null })] }));
167
+ style: {
168
+ position: strategy,
169
+ left: (x ?? 0) + (!!value ? 26 : 16),
170
+ top: y ?? 0,
171
+ ...transitions.styles,
172
+ },
173
+ }), "data-floating": "true", className: "z-floating m-0 origin-[top_center] list-none overflow-auto overflow-y-auto rounded-b-lg rounded-t-lg border border-floating-border bg-floating-background p-0 text-foreground shadow-floating", children: list.map((option, i) => {
174
+ const active = value === option.value || value === option.label;
175
+ return (_jsx(Option, { ...getItemProps({
176
+ onClick: () => onSelect(option, i),
177
+ ref: (node) => void (listRef.current[i] = node),
178
+ selected: index === i,
179
+ }), option: option, active: active, selected: index === i }, `${option.value}-option`));
180
+ }) }) })) : null })] }));
166
181
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAA2B,cAAc,EAAoD,MAAM,OAAO,CAAC;AAMzH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,OAAO,EAAa,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAoB,GAAG,EAA+B,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAStG,KAAK,eAAe,CAAC,CAAC,SAAS,EAAE,IAAI,cAAc,CAAC,gBAAgB,CAAC,GACjE,mBAAmB,CAAC,CAAC,CAAC,GAAG;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,UAAU,EAAE,WAAW,EAAE,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5B,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAChE,WAAW,CAAC,EA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AI,CAAC,SAAS,EAAE,SAAS,UAAU,CAAC,CAAC,CAAC,4CA6GvD,CAAC"}
@@ -114,7 +114,6 @@ export const Table = (props) => {
114
114
  }, {
115
115
  postMiddleware: [
116
116
  (state, prev) => {
117
- console.log("->", state, prev);
118
117
  props.set?.(state);
119
118
  compareAndExec(prev?.filters ?? [], state.filters ?? [], props.setFilters);
120
119
  compareAndExec(prev?.sorters ?? [], state.sorters ?? [], props.setSorters);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@g4rcez/components",
3
- "version": "0.0.49",
3
+ "version": "0.0.50",
4
4
  "sideEffects": false,
5
5
  "private": false,
6
6
  "packageManager": "pnpm@8.15.3",