@diabolic/hangover 0.1.2 → 0.1.3

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.
package/dist/index.cjs.js CHANGED
@@ -34,7 +34,8 @@ function DropdownTrigger({
34
34
  const {
35
35
  triggerRef,
36
36
  isOpen,
37
- fireEvent
37
+ fireEvent,
38
+ t
38
39
  } = useDropdownContext();
39
40
  const child = react.Children.only(children);
40
41
  function handleClick(e) {
@@ -49,12 +50,14 @@ function DropdownTrigger({
49
50
  }
50
51
  child.props.onClick?.(e);
51
52
  }
53
+ const childChildren = child.props.children;
54
+ const translatedChildren = typeof childChildren === 'string' ? t(childChildren) : childChildren;
52
55
  return /*#__PURE__*/react.cloneElement(child, {
53
56
  ref: triggerRef,
54
57
  onClick: handleClick,
55
58
  'aria-expanded': isOpen,
56
59
  'aria-haspopup': 'dialog'
57
- });
60
+ }, translatedChildren);
58
61
  }
59
62
 
60
63
  /**
@@ -393,6 +396,7 @@ function DropdownPanel({
393
396
  placement: actualPlacement,
394
397
  style: style,
395
398
  className: classNames,
399
+ title: t(title),
396
400
  ...rest,
397
401
  children: children
398
402
  }) : /*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -401,7 +405,7 @@ function DropdownPanel({
401
405
  style: style,
402
406
  role: "dialog",
403
407
  "aria-modal": "true",
404
- "aria-label": "Dropdown",
408
+ "aria-label": t('Dropdown'),
405
409
  ...rest,
406
410
  children: [title && /*#__PURE__*/jsxRuntime.jsx("div", {
407
411
  className: "hangoverDropdown-panel-title",
@@ -3368,10 +3372,10 @@ function DropdownGroup({
3368
3372
  const visibleItemIds = react.useMemo(() => {
3369
3373
  const searchableItems = react.Children.toArray(children).map(child => ({
3370
3374
  id: child?.props?.id,
3371
- label: typeof child?.props?.children === 'string' ? child.props.children : ''
3375
+ label: typeof child?.props?.children === 'string' ? t(child.props.children) : ''
3372
3376
  }));
3373
3377
  return getMatchingItemIds(searchableItems, searchQuery);
3374
- }, [children, searchQuery]);
3378
+ }, [children, searchQuery, t]);
3375
3379
  const groupContextValue = {
3376
3380
  groupLabel: label,
3377
3381
  groupId,
package/dist/index.esm.js CHANGED
@@ -30,7 +30,8 @@ function DropdownTrigger({
30
30
  const {
31
31
  triggerRef,
32
32
  isOpen,
33
- fireEvent
33
+ fireEvent,
34
+ t
34
35
  } = useDropdownContext();
35
36
  const child = Children.only(children);
36
37
  function handleClick(e) {
@@ -45,12 +46,14 @@ function DropdownTrigger({
45
46
  }
46
47
  child.props.onClick?.(e);
47
48
  }
49
+ const childChildren = child.props.children;
50
+ const translatedChildren = typeof childChildren === 'string' ? t(childChildren) : childChildren;
48
51
  return /*#__PURE__*/cloneElement(child, {
49
52
  ref: triggerRef,
50
53
  onClick: handleClick,
51
54
  'aria-expanded': isOpen,
52
55
  'aria-haspopup': 'dialog'
53
- });
56
+ }, translatedChildren);
54
57
  }
55
58
 
56
59
  /**
@@ -389,6 +392,7 @@ function DropdownPanel({
389
392
  placement: actualPlacement,
390
393
  style: style,
391
394
  className: classNames,
395
+ title: t(title),
392
396
  ...rest,
393
397
  children: children
394
398
  }) : /*#__PURE__*/jsxs("div", {
@@ -397,7 +401,7 @@ function DropdownPanel({
397
401
  style: style,
398
402
  role: "dialog",
399
403
  "aria-modal": "true",
400
- "aria-label": "Dropdown",
404
+ "aria-label": t('Dropdown'),
401
405
  ...rest,
402
406
  children: [title && /*#__PURE__*/jsx("div", {
403
407
  className: "hangoverDropdown-panel-title",
@@ -3364,10 +3368,10 @@ function DropdownGroup({
3364
3368
  const visibleItemIds = useMemo(() => {
3365
3369
  const searchableItems = Children.toArray(children).map(child => ({
3366
3370
  id: child?.props?.id,
3367
- label: typeof child?.props?.children === 'string' ? child.props.children : ''
3371
+ label: typeof child?.props?.children === 'string' ? t(child.props.children) : ''
3368
3372
  }));
3369
3373
  return getMatchingItemIds(searchableItems, searchQuery);
3370
- }, [children, searchQuery]);
3374
+ }, [children, searchQuery, t]);
3371
3375
  const groupContextValue = {
3372
3376
  groupLabel: label,
3373
3377
  groupId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diabolic/hangover",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "A headless-style, compound React dropdown/field-picker component library",
5
5
  "license": "MIT",
6
6
  "author": "bugrakaan",