@cdx-ui/primitives 0.0.1-beta.5 → 0.0.1-beta.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.
- package/README.md +51 -25
- package/lib/commonjs/CLAUDE.md +32 -0
- package/lib/commonjs/avatar/createAvatarText.js +9 -1
- package/lib/commonjs/avatar/createAvatarText.js.map +1 -1
- package/lib/commonjs/button/createButtonText.js +1 -0
- package/lib/commonjs/button/createButtonText.js.map +1 -1
- package/lib/commonjs/checkbox/createCheckboxRoot.web.js +8 -3
- package/lib/commonjs/checkbox/createCheckboxRoot.web.js.map +1 -1
- package/lib/commonjs/chip/createChipRoot.js +132 -0
- package/lib/commonjs/chip/createChipRoot.js.map +1 -0
- package/lib/commonjs/chip/index.js +16 -0
- package/lib/commonjs/chip/index.js.map +1 -0
- package/lib/commonjs/chip/types.js +6 -0
- package/lib/commonjs/chip/types.js.map +1 -0
- package/lib/commonjs/field/createFieldLabel.js.map +1 -1
- package/lib/commonjs/index.js +45 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/input/createInputField.js +5 -0
- package/lib/commonjs/input/createInputField.js.map +1 -1
- package/lib/commonjs/link/context.js +11 -0
- package/lib/commonjs/link/context.js.map +1 -0
- package/lib/commonjs/link/createLink.js +28 -14
- package/lib/commonjs/link/createLink.js.map +1 -1
- package/lib/commonjs/link/index.js +13 -0
- package/lib/commonjs/link/index.js.map +1 -1
- package/lib/commonjs/list-item/createListItemRoot.js +36 -21
- package/lib/commonjs/list-item/createListItemRoot.js.map +1 -1
- package/lib/commonjs/radio/context.js +14 -0
- package/lib/commonjs/radio/context.js.map +1 -0
- package/lib/commonjs/radio/createRadioGroup.js +66 -0
- package/lib/commonjs/radio/createRadioGroup.js.map +1 -0
- package/lib/commonjs/radio/createRadioIndicator.js +43 -0
- package/lib/commonjs/radio/createRadioIndicator.js.map +1 -0
- package/lib/commonjs/radio/createRadioLabel.js +38 -0
- package/lib/commonjs/radio/createRadioLabel.js.map +1 -0
- package/lib/commonjs/radio/createRadioRoot.js +95 -0
- package/lib/commonjs/radio/createRadioRoot.js.map +1 -0
- package/lib/commonjs/radio/createRadioRoot.web.js +87 -0
- package/lib/commonjs/radio/createRadioRoot.web.js.map +1 -0
- package/lib/commonjs/radio/index.js +26 -0
- package/lib/commonjs/radio/index.js.map +1 -0
- package/lib/commonjs/radio/types.js +6 -0
- package/lib/commonjs/radio/types.js.map +1 -0
- package/lib/commonjs/radio/useRadioRoot.js +64 -0
- package/lib/commonjs/radio/useRadioRoot.js.map +1 -0
- package/lib/commonjs/select/createSelectIcon.js +3 -1
- package/lib/commonjs/select/createSelectIcon.js.map +1 -1
- package/lib/commonjs/select/createSelectTrigger.js +17 -4
- package/lib/commonjs/select/createSelectTrigger.js.map +1 -1
- package/lib/commonjs/tile/context.js +30 -0
- package/lib/commonjs/tile/context.js.map +1 -0
- package/lib/commonjs/tile/createTileContent.js +30 -0
- package/lib/commonjs/tile/createTileContent.js.map +1 -0
- package/lib/commonjs/tile/createTileDescription.js +28 -0
- package/lib/commonjs/tile/createTileDescription.js.map +1 -0
- package/lib/commonjs/tile/createTileGroup.js +112 -0
- package/lib/commonjs/tile/createTileGroup.js.map +1 -0
- package/lib/commonjs/tile/createTileIndicator.js +46 -0
- package/lib/commonjs/tile/createTileIndicator.js.map +1 -0
- package/lib/commonjs/tile/createTileLeadingSlot.js +34 -0
- package/lib/commonjs/tile/createTileLeadingSlot.js.map +1 -0
- package/lib/commonjs/tile/createTileRoot.js +133 -0
- package/lib/commonjs/tile/createTileRoot.js.map +1 -0
- package/lib/commonjs/tile/createTileTitle.js +28 -0
- package/lib/commonjs/tile/createTileTitle.js.map +1 -0
- package/lib/commonjs/tile/createTileTrailingSlot.js +35 -0
- package/lib/commonjs/tile/createTileTrailingSlot.js.map +1 -0
- package/lib/commonjs/tile/index.js +55 -0
- package/lib/commonjs/tile/index.js.map +1 -0
- package/lib/commonjs/tile/types.js +6 -0
- package/lib/commonjs/tile/types.js.map +1 -0
- package/lib/commonjs/utils/dataAttributes.js +6 -25
- package/lib/commonjs/utils/dataAttributes.js.map +1 -1
- package/lib/commonjs/utils/domDataAttributes.js +34 -0
- package/lib/commonjs/utils/domDataAttributes.js.map +1 -0
- package/lib/module/CLAUDE.md +32 -0
- package/lib/module/avatar/createAvatarText.js +9 -1
- package/lib/module/avatar/createAvatarText.js.map +1 -1
- package/lib/module/button/createButtonText.js +1 -0
- package/lib/module/button/createButtonText.js.map +1 -1
- package/lib/module/checkbox/createCheckboxRoot.web.js +8 -2
- package/lib/module/checkbox/createCheckboxRoot.web.js.map +1 -1
- package/lib/module/chip/createChipRoot.js +126 -0
- package/lib/module/chip/createChipRoot.js.map +1 -0
- package/lib/module/chip/index.js +12 -0
- package/lib/module/chip/index.js.map +1 -0
- package/lib/module/chip/types.js +4 -0
- package/lib/module/chip/types.js.map +1 -0
- package/lib/module/field/createFieldLabel.js.map +1 -1
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/input/createInputField.js +5 -0
- package/lib/module/input/createInputField.js.map +1 -1
- package/lib/module/link/context.js +5 -0
- package/lib/module/link/context.js.map +1 -0
- package/lib/module/link/createLink.js +29 -15
- package/lib/module/link/createLink.js.map +1 -1
- package/lib/module/link/index.js +1 -0
- package/lib/module/link/index.js.map +1 -1
- package/lib/module/list-item/createListItemRoot.js +36 -21
- package/lib/module/list-item/createListItemRoot.js.map +1 -1
- package/lib/module/radio/context.js +7 -0
- package/lib/module/radio/context.js.map +1 -0
- package/lib/module/radio/createRadioGroup.js +61 -0
- package/lib/module/radio/createRadioGroup.js.map +1 -0
- package/lib/module/radio/createRadioIndicator.js +38 -0
- package/lib/module/radio/createRadioIndicator.js.map +1 -0
- package/lib/module/radio/createRadioLabel.js +33 -0
- package/lib/module/radio/createRadioLabel.js.map +1 -0
- package/lib/module/radio/createRadioRoot.js +90 -0
- package/lib/module/radio/createRadioRoot.js.map +1 -0
- package/lib/module/radio/createRadioRoot.web.js +82 -0
- package/lib/module/radio/createRadioRoot.web.js.map +1 -0
- package/lib/module/radio/index.js +22 -0
- package/lib/module/radio/index.js.map +1 -0
- package/lib/module/radio/types.js +4 -0
- package/lib/module/radio/types.js.map +1 -0
- package/lib/module/radio/useRadioRoot.js +60 -0
- package/lib/module/radio/useRadioRoot.js.map +1 -0
- package/lib/module/select/createSelectIcon.js +3 -1
- package/lib/module/select/createSelectIcon.js.map +1 -1
- package/lib/module/select/createSelectTrigger.js +19 -6
- package/lib/module/select/createSelectTrigger.js.map +1 -1
- package/lib/module/tile/context.js +21 -0
- package/lib/module/tile/context.js.map +1 -0
- package/lib/module/tile/createTileContent.js +24 -0
- package/lib/module/tile/createTileContent.js.map +1 -0
- package/lib/module/tile/createTileDescription.js +22 -0
- package/lib/module/tile/createTileDescription.js.map +1 -0
- package/lib/module/tile/createTileGroup.js +106 -0
- package/lib/module/tile/createTileGroup.js.map +1 -0
- package/lib/module/tile/createTileIndicator.js +40 -0
- package/lib/module/tile/createTileIndicator.js.map +1 -0
- package/lib/module/tile/createTileLeadingSlot.js +28 -0
- package/lib/module/tile/createTileLeadingSlot.js.map +1 -0
- package/lib/module/tile/createTileRoot.js +127 -0
- package/lib/module/tile/createTileRoot.js.map +1 -0
- package/lib/module/tile/createTileTitle.js +22 -0
- package/lib/module/tile/createTileTitle.js.map +1 -0
- package/lib/module/tile/createTileTrailingSlot.js +29 -0
- package/lib/module/tile/createTileTrailingSlot.js.map +1 -0
- package/lib/module/tile/index.js +39 -0
- package/lib/module/tile/index.js.map +1 -0
- package/lib/module/tile/types.js +4 -0
- package/lib/module/tile/types.js.map +1 -0
- package/lib/module/utils/dataAttributes.js +4 -22
- package/lib/module/utils/dataAttributes.js.map +1 -1
- package/lib/module/utils/domDataAttributes.js +30 -0
- package/lib/module/utils/domDataAttributes.js.map +1 -0
- package/lib/typescript/avatar/createAvatarText.d.ts.map +1 -1
- package/lib/typescript/button/createButtonText.d.ts.map +1 -1
- package/lib/typescript/checkbox/createCheckboxRoot.web.d.ts +4 -0
- package/lib/typescript/checkbox/createCheckboxRoot.web.d.ts.map +1 -1
- package/lib/typescript/checkbox/useCheckboxRoot.d.ts +2 -0
- package/lib/typescript/checkbox/useCheckboxRoot.d.ts.map +1 -1
- package/lib/typescript/chip/createChipRoot.d.ts +4 -0
- package/lib/typescript/chip/createChipRoot.d.ts.map +1 -0
- package/lib/typescript/chip/index.d.ts +9 -0
- package/lib/typescript/chip/index.d.ts.map +1 -0
- package/lib/typescript/chip/types.d.ts +17 -0
- package/lib/typescript/chip/types.d.ts.map +1 -0
- package/lib/typescript/field/createFieldLabel.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +4 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/input/createInputField.d.ts.map +1 -1
- package/lib/typescript/link/context.d.ts +10 -0
- package/lib/typescript/link/context.d.ts.map +1 -0
- package/lib/typescript/link/createLink.d.ts.map +1 -1
- package/lib/typescript/link/index.d.ts +2 -0
- package/lib/typescript/link/index.d.ts.map +1 -1
- package/lib/typescript/link/types.d.ts +1 -0
- package/lib/typescript/link/types.d.ts.map +1 -1
- package/lib/typescript/list-item/createListItemRoot.d.ts.map +1 -1
- package/lib/typescript/radio/context.d.ts +21 -0
- package/lib/typescript/radio/context.d.ts.map +1 -0
- package/lib/typescript/radio/createRadioGroup.d.ts +3 -0
- package/lib/typescript/radio/createRadioGroup.d.ts.map +1 -0
- package/lib/typescript/radio/createRadioIndicator.d.ts +5 -0
- package/lib/typescript/radio/createRadioIndicator.d.ts.map +1 -0
- package/lib/typescript/radio/createRadioLabel.d.ts +5 -0
- package/lib/typescript/radio/createRadioLabel.d.ts.map +1 -0
- package/lib/typescript/radio/createRadioRoot.d.ts +3 -0
- package/lib/typescript/radio/createRadioRoot.d.ts.map +1 -0
- package/lib/typescript/radio/createRadioRoot.web.d.ts +3 -0
- package/lib/typescript/radio/createRadioRoot.web.d.ts.map +1 -0
- package/lib/typescript/radio/index.d.ts +10 -0
- package/lib/typescript/radio/index.d.ts.map +1 -0
- package/lib/typescript/radio/types.d.ts +54 -0
- package/lib/typescript/radio/types.d.ts.map +1 -0
- package/lib/typescript/radio/useRadioRoot.d.ts +151 -0
- package/lib/typescript/radio/useRadioRoot.d.ts.map +1 -0
- package/lib/typescript/select/createSelectIcon.d.ts.map +1 -1
- package/lib/typescript/select/createSelectTrigger.d.ts.map +1 -1
- package/lib/typescript/tile/context.d.ts +9 -0
- package/lib/typescript/tile/context.d.ts.map +1 -0
- package/lib/typescript/tile/createTileContent.d.ts +3 -0
- package/lib/typescript/tile/createTileContent.d.ts.map +1 -0
- package/lib/typescript/tile/createTileDescription.d.ts +3 -0
- package/lib/typescript/tile/createTileDescription.d.ts.map +1 -0
- package/lib/typescript/tile/createTileGroup.d.ts +4 -0
- package/lib/typescript/tile/createTileGroup.d.ts.map +1 -0
- package/lib/typescript/tile/createTileIndicator.d.ts +4 -0
- package/lib/typescript/tile/createTileIndicator.d.ts.map +1 -0
- package/lib/typescript/tile/createTileLeadingSlot.d.ts +4 -0
- package/lib/typescript/tile/createTileLeadingSlot.d.ts.map +1 -0
- package/lib/typescript/tile/createTileRoot.d.ts +4 -0
- package/lib/typescript/tile/createTileRoot.d.ts.map +1 -0
- package/lib/typescript/tile/createTileTitle.d.ts +3 -0
- package/lib/typescript/tile/createTileTitle.d.ts.map +1 -0
- package/lib/typescript/tile/createTileTrailingSlot.d.ts +9 -0
- package/lib/typescript/tile/createTileTrailingSlot.d.ts.map +1 -0
- package/lib/typescript/tile/index.d.ts +15 -0
- package/lib/typescript/tile/index.d.ts.map +1 -0
- package/lib/typescript/tile/types.d.ts +119 -0
- package/lib/typescript/tile/types.d.ts.map +1 -0
- package/lib/typescript/utils/dataAttributes.d.ts +4 -10
- package/lib/typescript/utils/dataAttributes.d.ts.map +1 -1
- package/lib/typescript/utils/domDataAttributes.d.ts +15 -0
- package/lib/typescript/utils/domDataAttributes.d.ts.map +1 -0
- package/package.json +5 -2
- package/src/CLAUDE.md +32 -0
- package/src/avatar/createAvatarText.tsx +10 -1
- package/src/button/createButtonText.tsx +1 -0
- package/src/checkbox/createCheckboxRoot.web.tsx +6 -2
- package/src/chip/createChipRoot.tsx +144 -0
- package/src/chip/index.ts +18 -0
- package/src/chip/types.ts +23 -0
- package/src/field/createFieldLabel.tsx +4 -1
- package/src/index.ts +4 -0
- package/src/input/createInputField.tsx +6 -0
- package/src/link/context.tsx +10 -0
- package/src/link/createLink.tsx +41 -23
- package/src/link/index.tsx +2 -0
- package/src/link/types.ts +1 -0
- package/src/list-item/createListItemRoot.tsx +37 -22
- package/src/radio/context.tsx +21 -0
- package/src/radio/createRadioGroup.tsx +67 -0
- package/src/radio/createRadioIndicator.tsx +32 -0
- package/src/radio/createRadioLabel.tsx +28 -0
- package/src/radio/createRadioRoot.tsx +100 -0
- package/src/radio/createRadioRoot.web.tsx +81 -0
- package/src/radio/index.ts +37 -0
- package/src/radio/types.ts +67 -0
- package/src/radio/useRadioRoot.ts +69 -0
- package/src/select/createSelectIcon.tsx +2 -1
- package/src/select/createSelectTrigger.tsx +26 -3
- package/src/tile/context.tsx +23 -0
- package/src/tile/createTileContent.tsx +23 -0
- package/src/tile/createTileDescription.tsx +19 -0
- package/src/tile/createTileGroup.tsx +134 -0
- package/src/tile/createTileIndicator.tsx +38 -0
- package/src/tile/createTileLeadingSlot.tsx +30 -0
- package/src/tile/createTileRoot.tsx +124 -0
- package/src/tile/createTileTitle.tsx +19 -0
- package/src/tile/createTileTrailingSlot.tsx +25 -0
- package/src/tile/index.ts +88 -0
- package/src/tile/types.ts +153 -0
- package/src/utils/dataAttributes.ts +4 -25
- package/src/utils/domDataAttributes.ts +32 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createTileRoot = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _utils = require("@cdx-ui/utils");
|
|
9
|
+
var _focus = require("@react-native-aria/focus");
|
|
10
|
+
var _interactions = require("@react-native-aria/interactions");
|
|
11
|
+
var _dataAttributes = require("../utils/dataAttributes");
|
|
12
|
+
var _context = require("./context");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
|
+
const rowStyle = {
|
|
16
|
+
flexDirection: 'row',
|
|
17
|
+
alignSelf: 'stretch',
|
|
18
|
+
alignItems: 'center'
|
|
19
|
+
};
|
|
20
|
+
const createTileRoot = BasePressable => /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
21
|
+
const {
|
|
22
|
+
value,
|
|
23
|
+
disabled: disabledProp = false,
|
|
24
|
+
isSelected: controlledSelected,
|
|
25
|
+
defaultSelected,
|
|
26
|
+
onSelectedChange,
|
|
27
|
+
children,
|
|
28
|
+
onPress,
|
|
29
|
+
onFocus,
|
|
30
|
+
onBlur,
|
|
31
|
+
style,
|
|
32
|
+
/** Consumed by styled `withStyleContext` root. */
|
|
33
|
+
context: _styleContext,
|
|
34
|
+
...rest
|
|
35
|
+
} = props;
|
|
36
|
+
const group = (0, _context.useOptionalTileGroupContext)();
|
|
37
|
+
|
|
38
|
+
// Standalone selection state — only meaningful when no group owns selection.
|
|
39
|
+
const [standaloneSelected = false, setStandaloneSelected] = (0, _utils.useControllableState)({
|
|
40
|
+
prop: controlledSelected,
|
|
41
|
+
defaultProp: defaultSelected ?? false,
|
|
42
|
+
onChange: next => {
|
|
43
|
+
onSelectedChange?.(next);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const isSelected = group ? group.isSelected(value) : standaloneSelected;
|
|
47
|
+
const disabledByGroup = group ? group.isTileDisabledByGroup(value) : false;
|
|
48
|
+
const isDisabled = disabledByGroup || disabledProp;
|
|
49
|
+
const cannotToggle = isDisabled;
|
|
50
|
+
const {
|
|
51
|
+
focusProps,
|
|
52
|
+
isFocused
|
|
53
|
+
} = (0, _focus.useFocus)();
|
|
54
|
+
const {
|
|
55
|
+
pressProps,
|
|
56
|
+
isPressed
|
|
57
|
+
} = (0, _interactions.usePress)({
|
|
58
|
+
isDisabled: cannotToggle
|
|
59
|
+
});
|
|
60
|
+
const {
|
|
61
|
+
hoverProps,
|
|
62
|
+
isHovered
|
|
63
|
+
} = (0, _interactions.useHover)();
|
|
64
|
+
|
|
65
|
+
// Standalone tiles use checkbox semantics (independent on/off toggle).
|
|
66
|
+
const selectionType = group ? group.type : 'multiple';
|
|
67
|
+
const accessibilityState = (0, _react.useMemo)(() => ({
|
|
68
|
+
disabled: isDisabled,
|
|
69
|
+
...(selectionType === 'single' ? {
|
|
70
|
+
selected: isSelected
|
|
71
|
+
} : {
|
|
72
|
+
checked: isSelected
|
|
73
|
+
})
|
|
74
|
+
}), [isDisabled, isSelected, selectionType]);
|
|
75
|
+
const tileContext = (0, _react.useMemo)(() => ({
|
|
76
|
+
value,
|
|
77
|
+
isSelected,
|
|
78
|
+
isDisabled,
|
|
79
|
+
selectionType
|
|
80
|
+
}), [value, isSelected, isDisabled, selectionType]);
|
|
81
|
+
const passthrough = rest;
|
|
82
|
+
const composedOnPress = (0, _utils.composeEventHandlers)(onPress, () => {
|
|
83
|
+
if (cannotToggle) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (group) {
|
|
87
|
+
group.toggleValue(value);
|
|
88
|
+
} else {
|
|
89
|
+
setStandaloneSelected(!standaloneSelected);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const sharedHandlers = {
|
|
93
|
+
onPress: isDisabled ? undefined : composedOnPress,
|
|
94
|
+
onPressIn: (0, _utils.composeEventHandlers)(passthrough.onPressIn, pressProps.onPressIn),
|
|
95
|
+
onPressOut: (0, _utils.composeEventHandlers)(passthrough.onPressOut, pressProps.onPressOut),
|
|
96
|
+
onHoverIn: (0, _utils.composeEventHandlers)(passthrough.onHoverIn, hoverProps.onHoverIn),
|
|
97
|
+
onHoverOut: (0, _utils.composeEventHandlers)(passthrough.onHoverOut, hoverProps.onHoverOut),
|
|
98
|
+
onFocus: (0, _utils.composeEventHandlers)(onFocus, focusProps.onFocus),
|
|
99
|
+
onBlur: (0, _utils.composeEventHandlers)(onBlur, focusProps.onBlur)
|
|
100
|
+
};
|
|
101
|
+
const role = selectionType === 'single' ? 'radio' : 'checkbox';
|
|
102
|
+
const sharedAttrs = {
|
|
103
|
+
accessibilityRole: role,
|
|
104
|
+
role,
|
|
105
|
+
accessibilityState,
|
|
106
|
+
'aria-checked': isSelected,
|
|
107
|
+
...(isDisabled ? {
|
|
108
|
+
'aria-disabled': true
|
|
109
|
+
} : {}),
|
|
110
|
+
...(0, _dataAttributes.dataAttributes)({
|
|
111
|
+
slot: 'tile',
|
|
112
|
+
state: isSelected ? 'selected' : 'unselected',
|
|
113
|
+
disabled: isDisabled,
|
|
114
|
+
active: isPressed,
|
|
115
|
+
hover: isHovered,
|
|
116
|
+
focused: isFocused
|
|
117
|
+
})
|
|
118
|
+
};
|
|
119
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.TileProvider, {
|
|
120
|
+
value: tileContext,
|
|
121
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BasePressable, {
|
|
122
|
+
...rest,
|
|
123
|
+
context: _styleContext,
|
|
124
|
+
ref: (0, _utils.mergeRefs)(ref),
|
|
125
|
+
...sharedAttrs,
|
|
126
|
+
...sharedHandlers,
|
|
127
|
+
style: [rowStyle, style],
|
|
128
|
+
children: children
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
exports.createTileRoot = createTileRoot;
|
|
133
|
+
//# sourceMappingURL=createTileRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_utils","_focus","_interactions","_dataAttributes","_context","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","rowStyle","flexDirection","alignSelf","alignItems","createTileRoot","BasePressable","forwardRef","props","ref","value","disabled","disabledProp","isSelected","controlledSelected","defaultSelected","onSelectedChange","children","onPress","onFocus","onBlur","style","context","_styleContext","rest","group","useOptionalTileGroupContext","standaloneSelected","setStandaloneSelected","useControllableState","prop","defaultProp","onChange","next","disabledByGroup","isTileDisabledByGroup","isDisabled","cannotToggle","focusProps","isFocused","useFocus","pressProps","isPressed","usePress","hoverProps","isHovered","useHover","selectionType","type","accessibilityState","useMemo","selected","checked","tileContext","passthrough","composedOnPress","composeEventHandlers","toggleValue","sharedHandlers","undefined","onPressIn","onPressOut","onHoverIn","onHoverOut","role","sharedAttrs","accessibilityRole","dataAttributes","slot","state","active","hover","focused","jsx","TileProvider","mergeRefs","exports"],"sourceRoot":"../../../src","sources":["tile/createTileRoot.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAAsE,IAAAM,WAAA,GAAAN,OAAA;AAAA,SAAAD,wBAAAQ,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA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AO,GAAG,UAAU;EAE9D,MAAMkB,WAAW,GAAG;IAClBC,iBAAiB,EAAEF,IAAI;IACvBA,IAAI;IACJf,kBAAkB;IAClB,cAAc,EAAEpC,UAAU;IAC1B,IAAIuB,UAAU,GAAG;MAAE,eAAe,EAAE;IAAc,CAAC,GAAG,CAAC,CAAC,CAAC;IACzD,GAAG,IAAA+B,8BAAc,EAAC;MAChBC,IAAI,EAAE,MAAM;MACZC,KAAK,EAAExD,UAAU,GAAG,UAAU,GAAG,YAAY;MAC7CF,QAAQ,EAAEyB,UAAU;MACpBkC,MAAM,EAAE5B,SAAS;MACjB6B,KAAK,EAAE1B,SAAS;MAChB2B,OAAO,EAAEjC;IACX,CAAC;EACH,CAAC;EAED,oBACE,IAAA1D,WAAA,CAAA4F,GAAA,EAAC7F,QAAA,CAAA8F,YAAY;IAAChE,KAAK,EAAE2C,WAAY;IAAApC,QAAA,eAC/B,IAAApC,WAAA,CAAA4F,GAAA,EAACnE,aAAa;MAAA,GACPkB,IAAI;MACTF,OAAO,EAAEC,aAAc;MACvBd,GAAG,EAAE,IAAAkE,gBAAS,EAAClE,GAAG,CAAkB;MAAA,GAChCwD,WAAW;MAAA,GACXP,cAAc;MAClBrC,KAAK,EAAE,CAACpB,QAAQ,EAAEoB,KAAK,CAAE;MAAAJ,QAAA,EAExBA;IAAQ,CACI;EAAC,CACJ,CAAC;AAEnB,CAAC,CAAC;AAAC2D,OAAA,CAAAvE,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createTileTitle = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _dataAttributes = require("../utils/dataAttributes");
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
|
+
const noUnderline = {
|
|
12
|
+
textDecorationLine: 'none'
|
|
13
|
+
};
|
|
14
|
+
const createTileTitle = Base => /*#__PURE__*/(0, _react.forwardRef)(({
|
|
15
|
+
children,
|
|
16
|
+
style,
|
|
17
|
+
...props
|
|
18
|
+
}, ref) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Base, {
|
|
19
|
+
...props,
|
|
20
|
+
...(0, _dataAttributes.dataAttributes)({
|
|
21
|
+
slot: 'tile-title'
|
|
22
|
+
}),
|
|
23
|
+
ref: ref,
|
|
24
|
+
style: [noUnderline, style],
|
|
25
|
+
children: children
|
|
26
|
+
}));
|
|
27
|
+
exports.createTileTitle = createTileTitle;
|
|
28
|
+
//# sourceMappingURL=createTileTitle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_dataAttributes","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","noUnderline","textDecorationLine","createTileTitle","Base","forwardRef","children","style","props","ref","jsx","dataAttributes","slot","exports"],"sourceRoot":"../../../src","sources":["tile/createTileTitle.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAAyD,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,wBAAAI,CAAA,E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EAAE;EACR,CAAC,CAAC;EACFH,GAAG,EAAEA,GAAoB;EACzBF,KAAK,EAAE,CAACN,WAAW,EAAEM,KAAK,CAAE;EAAAD,QAAA,EAE3BA;AAAQ,CACL,CACP,CAAC;AAACO,OAAA,CAAAV,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createTileTrailingSlot = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _dataAttributes = require("../utils/dataAttributes");
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
|
+
const shrinkZero = {
|
|
12
|
+
flexShrink: 0
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Generic trailing content (chevron, amount, chip, status). Distinct from `Tile.Indicator`,
|
|
17
|
+
* which is purpose-built for the radio/checkbox selection affordance.
|
|
18
|
+
*
|
|
19
|
+
* Trailing content is meaningful by default (`aria-hidden` falsy), unlike the indicator.
|
|
20
|
+
*/
|
|
21
|
+
const createTileTrailingSlot = Base => /*#__PURE__*/(0, _react.forwardRef)(({
|
|
22
|
+
children,
|
|
23
|
+
style,
|
|
24
|
+
...props
|
|
25
|
+
}, ref) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Base, {
|
|
26
|
+
...props,
|
|
27
|
+
...(0, _dataAttributes.dataAttributes)({
|
|
28
|
+
slot: 'tile-trailing'
|
|
29
|
+
}),
|
|
30
|
+
ref: ref,
|
|
31
|
+
style: [shrinkZero, style],
|
|
32
|
+
children: children
|
|
33
|
+
}));
|
|
34
|
+
exports.createTileTrailingSlot = createTileTrailingSlot;
|
|
35
|
+
//# sourceMappingURL=createTileTrailingSlot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_dataAttributes","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","shrinkZero","flexShrink","createTileTrailingSlot","Base","forwardRef","children","style","props","ref","jsx","dataAttributes","slot","exports"],"sourceRoot":"../../../src","sources":["tile/createTileTrailingSlot.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAAyD,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAGzD,MAAMkB,UAAU,GAAG;EAAEC,UAAU,EAAE;AAAW,CAAC;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,sBAAsB,GAAQC,IAA4B,iBACrE,IAAAC,iBAAU,EAAC,CAAC;EAAEC,QAAQ;EAAEC,KAAK;EAAE,GAAGC;AAA8B,CAAC,EAAEC,GAAuB,kBACxF,IAAA5B,WAAA,CAAA6B,GAAA,EAACN,IAAI;EAAA,GACEI,KAAK;EAAA,GACN,IAAAG,8BAAc,EAAC;IACjBC,IAAI,EAAE;EACR,CAAC,CAAC;EACFH,GAAG,EAAEA,GAAoB;EACzBF,KAAK,EAAE,CAACN,UAAU,EAAEM,KAAK,CAAE;EAAAD,QAAA,EAE1BA;AAAQ,CACL,CACP,CAAC;AAACO,OAAA,CAAAV,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "TileProvider", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _context.TileProvider;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.createTile = createTile;
|
|
13
|
+
Object.defineProperty(exports, "useTileContext", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _context.useTileContext;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
var _createTileContent = require("./createTileContent");
|
|
20
|
+
var _createTileDescription = require("./createTileDescription");
|
|
21
|
+
var _createTileGroup = require("./createTileGroup");
|
|
22
|
+
var _createTileIndicator = require("./createTileIndicator");
|
|
23
|
+
var _createTileLeadingSlot = require("./createTileLeadingSlot");
|
|
24
|
+
var _createTileRoot = require("./createTileRoot");
|
|
25
|
+
var _createTileTitle = require("./createTileTitle");
|
|
26
|
+
var _createTileTrailingSlot = require("./createTileTrailingSlot");
|
|
27
|
+
var _context = require("./context");
|
|
28
|
+
function createTile(BaseComponents) {
|
|
29
|
+
const Tile = (0, _createTileRoot.createTileRoot)(BaseComponents.Pressable);
|
|
30
|
+
const Group = (0, _createTileGroup.createTileGroup)(BaseComponents.Group);
|
|
31
|
+
const LeadingSlot = (0, _createTileLeadingSlot.createTileLeadingSlot)(BaseComponents.LeadingSlot);
|
|
32
|
+
const Content = (0, _createTileContent.createTileContent)(BaseComponents.Content);
|
|
33
|
+
const Title = (0, _createTileTitle.createTileTitle)(BaseComponents.Title);
|
|
34
|
+
const Description = (0, _createTileDescription.createTileDescription)(BaseComponents.Description);
|
|
35
|
+
const Indicator = (0, _createTileIndicator.createTileIndicator)(BaseComponents.Indicator);
|
|
36
|
+
const TrailingSlot = (0, _createTileTrailingSlot.createTileTrailingSlot)(BaseComponents.TrailingSlot);
|
|
37
|
+
Tile.displayName = 'TilePrimitive';
|
|
38
|
+
Group.displayName = 'TilePrimitive.Group';
|
|
39
|
+
LeadingSlot.displayName = 'TilePrimitive.LeadingSlot';
|
|
40
|
+
Content.displayName = 'TilePrimitive.Content';
|
|
41
|
+
Title.displayName = 'TilePrimitive.Title';
|
|
42
|
+
Description.displayName = 'TilePrimitive.Description';
|
|
43
|
+
Indicator.displayName = 'TilePrimitive.Indicator';
|
|
44
|
+
TrailingSlot.displayName = 'TilePrimitive.TrailingSlot';
|
|
45
|
+
return Object.assign(Tile, {
|
|
46
|
+
Group,
|
|
47
|
+
LeadingSlot,
|
|
48
|
+
Content,
|
|
49
|
+
Title,
|
|
50
|
+
Description,
|
|
51
|
+
Indicator,
|
|
52
|
+
TrailingSlot
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_createTileContent","require","_createTileDescription","_createTileGroup","_createTileIndicator","_createTileLeadingSlot","_createTileRoot","_createTileTitle","_createTileTrailingSlot","_context","createTile","BaseComponents","Tile","createTileRoot","Pressable","Group","createTileGroup","LeadingSlot","createTileLeadingSlot","Content","createTileContent","Title","createTileTitle","Description","createTileDescription","Indicator","createTileIndicator","TrailingSlot","createTileTrailingSlot","displayName","Object","assign"],"sourceRoot":"../../../src","sources":["tile/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AACA,IAAAO,uBAAA,GAAAP,OAAA;AAsBA,IAAAQ,QAAA,GAAAR,OAAA;AAEO,SAASS,UAAUA,CASxBC,cASD,EAAE;EACD,MAAMC,IAAI,GAAG,IAAAC,8BAAc,EAACF,cAAc,CAACG,SAAS,CAAC;EACrD,MAAMC,KAAK,GAAG,IAAAC,gCAAe,EAACL,cAAc,CAACI,KAAK,CAAC;EACnD,MAAME,WAAW,GAAG,IAAAC,4CAAqB,EAACP,cAAc,CAACM,WAAW,CAAC;EACrE,MAAME,OAAO,GAAG,IAAAC,oCAAiB,EAACT,cAAc,CAACQ,OAAO,CAAC;EACzD,MAAME,KAAK,GAAG,IAAAC,gCAAe,EAACX,cAAc,CAACU,KAAK,CAAC;EACnD,MAAME,WAAW,GAAG,IAAAC,4CAAqB,EAACb,cAAc,CAACY,WAAW,CAAC;EACrE,MAAME,SAAS,GAAG,IAAAC,wCAAmB,EAACf,cAAc,CAACc,SAAS,CAAC;EAC/D,MAAME,YAAY,GAAG,IAAAC,8CAAsB,EAACjB,cAAc,CAACgB,YAAY,CAAC;EAExEf,IAAI,CAACiB,WAAW,GAAG,eAAe;EAClCd,KAAK,CAACc,WAAW,GAAG,qBAAqB;EACzCZ,WAAW,CAACY,WAAW,GAAG,2BAA2B;EACrDV,OAAO,CAACU,WAAW,GAAG,uBAAuB;EAC7CR,KAAK,CAACQ,WAAW,GAAG,qBAAqB;EACzCN,WAAW,CAACM,WAAW,GAAG,2BAA2B;EACrDJ,SAAS,CAACI,WAAW,GAAG,yBAAyB;EACjDF,YAAY,CAACE,WAAW,GAAG,4BAA4B;EAEvD,OAAOC,MAAM,CAACC,MAAM,CAACnB,IAAI,EAAE;IACzBG,KAAK;IACLE,WAAW;IACXE,OAAO;IACPE,KAAK;IACLE,WAAW;IACXE,SAAS;IACTE;EACF,CAAC,CAAC;AAUJ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["tile/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -3,30 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Native: individual `data-*` props consumed by Uniwind.
|
|
11
|
-
* Web (.web.ts): a `dataSet` object consumed by React Native Web.
|
|
12
|
-
*
|
|
13
|
-
* Boolean values serialize to `"true"` / `"false"` strings.
|
|
14
|
-
* String values pass through as-is.
|
|
15
|
-
* Undefined values are omitted.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
function camelToKebab(str) {
|
|
19
|
-
return str.replaceAll(/[A-Z]/g, ch => `-${ch.toLowerCase()}`);
|
|
20
|
-
}
|
|
21
|
-
function dataAttributes(attrs) {
|
|
22
|
-
const result = {};
|
|
23
|
-
for (const key in attrs) {
|
|
24
|
-
const value = attrs[key];
|
|
25
|
-
if (value === undefined) {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
result[`data-${camelToKebab(key)}`] = typeof value === 'boolean' ? String(value) : value;
|
|
6
|
+
Object.defineProperty(exports, "dataAttributes", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _domDataAttributes.domDataAttributes;
|
|
29
10
|
}
|
|
30
|
-
|
|
31
|
-
|
|
11
|
+
});
|
|
12
|
+
var _domDataAttributes = require("./domDataAttributes");
|
|
32
13
|
//# sourceMappingURL=dataAttributes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_domDataAttributes","require"],"sourceRoot":"../../../src","sources":["utils/dataAttributes.ts"],"mappings":";;;;;;;;;;;AAMA,IAAAA,kBAAA,GAAAC,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.domDataAttributes = domDataAttributes;
|
|
7
|
+
/**
|
|
8
|
+
* Produces `data-*` DOM attribute props for use on raw HTML elements (e.g. `<button>`).
|
|
9
|
+
*
|
|
10
|
+
* Unlike `dataAttributes`, which has a platform-specific `.web.ts` sibling that returns a
|
|
11
|
+
* `dataSet` object for React Native Web components, this file has no platform variant.
|
|
12
|
+
* The bundler therefore always resolves to this single implementation, making it safe to
|
|
13
|
+
* import from `.web.tsx` host components that render native DOM elements directly.
|
|
14
|
+
*
|
|
15
|
+
* Boolean values serialize to `"true"` / `"false"` strings.
|
|
16
|
+
* String values pass through as-is.
|
|
17
|
+
* Undefined values are omitted.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function camelToKebab(str) {
|
|
21
|
+
return str.replaceAll(/[A-Z]/g, ch => `-${ch.toLowerCase()}`);
|
|
22
|
+
}
|
|
23
|
+
function domDataAttributes(attrs) {
|
|
24
|
+
const result = {};
|
|
25
|
+
for (const key in attrs) {
|
|
26
|
+
const value = attrs[key];
|
|
27
|
+
if (value === undefined) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
result[`data-${camelToKebab(key)}`] = typeof value === 'boolean' ? String(value) : value;
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=domDataAttributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["camelToKebab","str","replaceAll","ch","toLowerCase","domDataAttributes","attrs","result","key","value","undefined","String"],"sourceRoot":"../../../src","sources":["utils/domDataAttributes.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,YAAYA,CAACC,GAAW,EAAU;EACzC,OAAOA,GAAG,CAACC,UAAU,CAAC,QAAQ,EAAGC,EAAE,IAAK,IAAIA,EAAE,CAACC,WAAW,CAAC,CAAC,EAAE,CAAC;AACjE;AAEO,SAASC,iBAAiBA,CAC/BC,KAA4C,EACpB;EACxB,MAAMC,MAA8B,GAAG,CAAC,CAAC;EACzC,KAAK,MAAMC,GAAG,IAAIF,KAAK,EAAE;IACvB,MAAMG,KAAK,GAAGH,KAAK,CAACE,GAAG,CAAC;IACxB,IAAIC,KAAK,KAAKC,SAAS,EAAE;MACvB;IACF;IACAH,MAAM,CAAC,QAAQP,YAAY,CAACQ,GAAG,CAAC,EAAE,CAAC,GAAG,OAAOC,KAAK,KAAK,SAAS,GAAGE,MAAM,CAACF,KAAK,CAAC,GAAGA,KAAK;EAC1F;EACA,OAAOF,MAAM;AACf","ignoreList":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Primitive Authoring
|
|
2
|
+
|
|
3
|
+
Auto-loaded when working in `packages/primitives/src/**`.
|
|
4
|
+
|
|
5
|
+
Primitives in `@cdx-ui/primitives` are unstyled behavioral components that handle accessibility and interactions. Read the full guides before making changes:
|
|
6
|
+
|
|
7
|
+
- `docs/internal/practices/composition.md` — compound component structure
|
|
8
|
+
- `docs/internal/practices/types.md` — `I*Props` convention, extending RN base types
|
|
9
|
+
- `docs/internal/practices/accessibility.md` — ARIA roles, keyboard nav, screen reader support
|
|
10
|
+
- `docs/internal/practices/as-child.md` — `asChild` prop pattern
|
|
11
|
+
|
|
12
|
+
## Pattern summary
|
|
13
|
+
|
|
14
|
+
Each primitive follows the factory function pattern (see `createButtonRoot.tsx` as the canonical example):
|
|
15
|
+
|
|
16
|
+
1. **Factory function** — `export const createComponentPart = <T,>(BaseComponent: ComponentType<T>) => forwardRef(...)` — accepts a host element type, returns a wrapped component with behavior
|
|
17
|
+
2. **Interaction hooks** — `useFocus`, `useFocusRing`, `useHover`, `usePress` from `@react-native-aria/*`
|
|
18
|
+
3. **Data attributes** — `dataAttributes({ hover, focus, active, disabled, focusVisible })` emitted on the rendered element for Uniwind `data-[state]` selectors
|
|
19
|
+
4. **Context provider** — interaction state exposed via context so child primitives can react to parent state
|
|
20
|
+
5. **Barrel export** — `index.tsx` re-exports the factory, context, and types
|
|
21
|
+
|
|
22
|
+
## Key rules
|
|
23
|
+
|
|
24
|
+
- **Unstyled** — no visual styling (no `className`, no color/spacing classes). Only behavioral and a11y concerns.
|
|
25
|
+
- **`I*Props` convention** — public prop types are aliased with `I` prefix (e.g., `IButtonProps`, `ICheckboxProps`), exported from `types.ts`
|
|
26
|
+
- **`Interface*Props` pattern** — the full interface (e.g., `InterfaceButtonProps`, `InterfaceCheckbox`) extends the appropriate RN base type (`PressableProps`, `ViewProps`, etc.) with interaction state booleans (`isHovered`, `isActive`, `isFocused`, `isFocusVisible`, `isDisabled`); re-exported as `I*Props` (e.g., `export type IButtonProps = InterfaceButtonProps`)
|
|
27
|
+
- **`dataAttributes()` helper** — always use the helper from `../utils/dataAttributes` to emit `data-*` props; it handles platform differences (native vs web)
|
|
28
|
+
- **`composeEventHandlers`** from `@cdx-ui/utils` — merge consumer handlers with internal handlers; never silently override
|
|
29
|
+
- **`forwardRef`** on every component — refs forwarded to the underlying host element
|
|
30
|
+
- **ARIA roles** — set `role` with a sensible default (e.g., `role={props?.role || 'button'}`)
|
|
31
|
+
- **Render children as function** — support `children` as `(state: InteractionState) => ReactNode` for state-driven rendering
|
|
32
|
+
- **Consumable independently** of `@cdx-ui/components` — no imports from the styled layer
|
|
@@ -4,7 +4,15 @@ import { forwardRef } from 'react';
|
|
|
4
4
|
import { useAvatarContext } from './context';
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
function getInitials(name) {
|
|
7
|
-
const
|
|
7
|
+
const trimmed = name.trim();
|
|
8
|
+
const words = trimmed.split(/\s+/);
|
|
9
|
+
|
|
10
|
+
// Pre-composed initials (e.g. "JD", "AB") — single token, at most 2 chars.
|
|
11
|
+
// Figma Code Connect surfaces the raw text property which is already initials;
|
|
12
|
+
// passing them through a derivation step would truncate to the first letter.
|
|
13
|
+
if (words.length === 1 && trimmed.length <= 2) {
|
|
14
|
+
return trimmed.toUpperCase();
|
|
15
|
+
}
|
|
8
16
|
let result = '';
|
|
9
17
|
for (const word of words) {
|
|
10
18
|
if (word.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","useAvatarContext","jsx","_jsx","getInitials","name","
|
|
1
|
+
{"version":3,"names":["forwardRef","useAvatarContext","jsx","_jsx","getInitials","name","trimmed","trim","words","split","length","toUpperCase","result","word","charAt","createAvatarText","BaseText","children","style","props","ref","imageLoaded","imageError","visible","text","opacity"],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AI;MAAEE,OAAO,EAAE;IAAE,CAAC,CAAE;IAAA,GAAMN,KAAK;IAAAF,QAAA,EACvEO;EAAI,CACG,CAAC;AAEf,CAAC,CAAC","ignoreList":[]}
|
|
@@ -5,6 +5,7 @@ import { dataAttributes } from '../utils/dataAttributes';
|
|
|
5
5
|
import { useButtonContext } from './context';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
// TODO: Rename to ButtonLabel
|
|
8
|
+
// TODO: Can we remove the dataAttributes here?
|
|
8
9
|
|
|
9
10
|
export const createButtonText = BaseButtonText => /*#__PURE__*/forwardRef(({
|
|
10
11
|
children,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","dataAttributes","useButtonContext","jsx","_jsx","createButtonText","BaseButtonText","children","props","ref","hover","focus","active","disabled","focusVisible"],"sourceRoot":"../../../src","sources":["button/createButtonText.tsx"],"mappings":";;AACA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,gBAAgB,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG7C;;AAEA,OAAO,MAAMC,gBAAgB,GAAQC,cAAsC,iBACzEN,UAAU,CAA4B,CAAC;EAAEO,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EACrE,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,MAAM;IAAEC,QAAQ;IAAEC;EAAa,CAAC,GAAGZ,gBAAgB,CAAC,CAAC;EAE3E,oBACEE,IAAA,CAACE,cAAc;IACbG,GAAG,EAAEA,GAAI;IAAA,GACJD,KAAK;IAAA,GACNP,cAAc,CAAC;MAAES,KAAK;MAAEC,KAAK;MAAEC,MAAM;MAAEC,QAAQ;MAAEC;IAAa,CAAC,CAAC;IAAAP,QAAA,EAEnEA;EAAQ,CACK,CAAC;AAErB,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["forwardRef","dataAttributes","useButtonContext","jsx","_jsx","createButtonText","BaseButtonText","children","props","ref","hover","focus","active","disabled","focusVisible"],"sourceRoot":"../../../src","sources":["button/createButtonText.tsx"],"mappings":";;AACA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,gBAAgB,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG7C;AACA;;AAEA,OAAO,MAAMC,gBAAgB,GAAQC,cAAsC,iBACzEN,UAAU,CAA4B,CAAC;EAAEO,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EACrE,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,MAAM;IAAEC,QAAQ;IAAEC;EAAa,CAAC,GAAGZ,gBAAgB,CAAC,CAAC;EAE3E,oBACEE,IAAA,CAACE,cAAc;IACbG,GAAG,EAAEA,GAAI;IAAA,GACJD,KAAK;IAAA,GACNP,cAAc,CAAC;MAAES,KAAK;MAAEC,KAAK;MAAEC,MAAM;MAAEC,QAAQ;MAAEC;IAAa,CAAC,CAAC;IAAAP,QAAA,EAEnEA;EAAQ,CACK,CAAC;AAErB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -7,7 +7,10 @@ import { dataAttributes } from '../utils/dataAttributes';
|
|
|
7
7
|
import { CheckboxProvider } from './context';
|
|
8
8
|
import { useCheckboxRoot } from './useCheckboxRoot';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Web uses a native checkbox input (VisuallyHidden) for ARIA + focus management. The outer
|
|
12
|
+
* `Pressable` must not be in the tab order or each control consumes two Tab stops (wrapper + input).
|
|
13
|
+
*/
|
|
11
14
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
15
|
export const createCheckboxRoot = BaseCheckbox => /*#__PURE__*/forwardRef(({
|
|
13
16
|
children,
|
|
@@ -44,7 +47,10 @@ export const createCheckboxRoot = BaseCheckbox => /*#__PURE__*/forwardRef(({
|
|
|
44
47
|
} = useFocusRing();
|
|
45
48
|
return /*#__PURE__*/_jsx(BaseCheckbox, {
|
|
46
49
|
...combinedProps,
|
|
47
|
-
ref: mergedRef
|
|
50
|
+
ref: mergedRef
|
|
51
|
+
// Native input is the only tab stop; Pressable is still clickable (mouse / screen reader).
|
|
52
|
+
,
|
|
53
|
+
tabIndex: -1,
|
|
48
54
|
role: "label"
|
|
49
55
|
// eslint-disable-next-line react-native-a11y/has-valid-accessibility-role
|
|
50
56
|
,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","VisuallyHidden","useFocusRing","dataAttributes","CheckboxProvider","useCheckboxRoot","jsx","_jsx","jsxs","_jsxs","createCheckboxRoot","BaseCheckbox","children","props","ref","isHovered","isHoveredProp","isFocusVisible","isFocusVisibleProp","isChecked","isCheckedProp","isDisabled","isDisabledProp","isInvalid","isInvalidProp","isReadOnly","isReadOnlyProp","isIndeterminate","isIndeterminateProp","isFocused","isPressed","combinedProps","groupItemInputProps","mergedRef","inputRef","useInputRefForAria","focusProps","role","accessibilityRole","checked","disabled","hover","invalid","readonly","active","focus","indeterminate","focusVisible","value"],"sourceRoot":"../../../src","sources":["checkbox/createCheckboxRoot.web.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,cAAc,QAAQ,6BAA6B;AAC5D,SAASC,YAAY,QAAQ,0BAA0B;AACvD,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,gBAAgB,QAAQ,WAAW;AAE5C,SAASC,eAAe,QAAQ,mBAAmB;;AAEnD;
|
|
1
|
+
{"version":3,"names":["forwardRef","VisuallyHidden","useFocusRing","dataAttributes","CheckboxProvider","useCheckboxRoot","jsx","_jsx","jsxs","_jsxs","createCheckboxRoot","BaseCheckbox","children","props","ref","isHovered","isHoveredProp","isFocusVisible","isFocusVisibleProp","isChecked","isCheckedProp","isDisabled","isDisabledProp","isInvalid","isInvalidProp","isReadOnly","isReadOnlyProp","isIndeterminate","isIndeterminateProp","isFocused","isPressed","combinedProps","groupItemInputProps","mergedRef","inputRef","useInputRefForAria","focusProps","tabIndex","role","accessibilityRole","checked","disabled","hover","invalid","readonly","active","focus","indeterminate","focusVisible","value"],"sourceRoot":"../../../src","sources":["checkbox/createCheckboxRoot.web.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,cAAc,QAAQ,6BAA6B;AAC5D,SAASC,YAAY,QAAQ,0BAA0B;AACvD,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,gBAAgB,QAAQ,WAAW;AAE5C,SAASC,eAAe,QAAQ,mBAAmB;;AAEnD;AACA;AACA;AACA;AAHA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAIA,OAAO,MAAMC,kBAAkB,GAAQC,YAAoC,iBACzEX,UAAU,CAAC,CAAC;EAAEY,QAAQ;EAAE,GAAGC;AAAsB,CAAC,EAAEC,GAAkB,KAAK;EACzE,MAAM;IACJC,SAAS,EAAEC,aAAa;IACxBC,cAAc,EAAEC,kBAAkB;IAClCC,SAAS,EAAEC,aAAa;IACxBC,UAAU,EAAEC,cAAc;IAC1BC,SAAS,EAAEC,aAAa;IACxBC,UAAU,EAAEC,cAAc;IAC1BC,eAAe,EAAEC,mBAAmB;IACpCC,SAAS;IACTC;EACF,CAAC,GAAGjB,KAAK;EAET,MAAM;IACJkB,aAAa;IACbR,SAAS;IACTE,UAAU;IACVE,eAAe;IACfK,mBAAmB;IACnBb,SAAS;IACTE,UAAU;IACVN,SAAS;IACTkB,SAAS;IACTC;EACF,CAAC,GAAG7B,eAAe,CAACQ,KAAK,EAAEC,GAAG,EAAE;IAAEqB,kBAAkB,EAAE;EAAK,CAAC,CAAC;EAE7D,MAAM;IAAEC,UAAU;IAAEnB;EAAe,CAAC,GAAGf,YAAY,CAAC,CAAC;EAErD,oBACEK,IAAA,CAACI,YAAY;IAAA,GACNoB,a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Refs } from '@cdx-ui/utils';
|
|
5
|
+
import { useFocus, useFocusRing } from '@react-native-aria/focus';
|
|
6
|
+
import { useHover, usePress } from '@react-native-aria/interactions';
|
|
7
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
const rowStyle = {
|
|
10
|
+
flexDirection: 'row',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
alignSelf: 'flex-start'
|
|
13
|
+
};
|
|
14
|
+
const chipSlotAttrs = dataAttributes({
|
|
15
|
+
slot: 'chip'
|
|
16
|
+
});
|
|
17
|
+
export const createChipRoot = (BaseView, BasePressable) => /*#__PURE__*/forwardRef(({
|
|
18
|
+
asChild = false,
|
|
19
|
+
children,
|
|
20
|
+
onPress,
|
|
21
|
+
disabled = false,
|
|
22
|
+
accessibilityRole,
|
|
23
|
+
style,
|
|
24
|
+
...restProps
|
|
25
|
+
}, ref) => {
|
|
26
|
+
const childOnPress = /*#__PURE__*/React.isValidElement(children) ? children.props.onPress : undefined;
|
|
27
|
+
const asChildInteractive = asChild && /*#__PURE__*/React.isValidElement(children);
|
|
28
|
+
const isPressableRoot = !!onPress && !asChildInteractive;
|
|
29
|
+
const pressState = usePress({
|
|
30
|
+
isDisabled: !isPressableRoot || disabled
|
|
31
|
+
});
|
|
32
|
+
const isPressed = pressState.isPressed;
|
|
33
|
+
const pressProps = pressState.pressProps;
|
|
34
|
+
const {
|
|
35
|
+
hoverProps,
|
|
36
|
+
isHovered
|
|
37
|
+
} = useHover();
|
|
38
|
+
const {
|
|
39
|
+
isFocused,
|
|
40
|
+
focusProps
|
|
41
|
+
} = useFocus();
|
|
42
|
+
const {
|
|
43
|
+
isFocusVisible,
|
|
44
|
+
focusProps: focusRingProps
|
|
45
|
+
} = useFocusRing();
|
|
46
|
+
if (asChildInteractive) {
|
|
47
|
+
const child = children;
|
|
48
|
+
const childDisabled = !!child.props.disabled;
|
|
49
|
+
const resolvedDisabled = disabled || childDisabled;
|
|
50
|
+
const cloneProps = {
|
|
51
|
+
...restProps,
|
|
52
|
+
...chipSlotAttrs,
|
|
53
|
+
...dataAttributes({
|
|
54
|
+
active: false,
|
|
55
|
+
hover: false,
|
|
56
|
+
disabled: resolvedDisabled,
|
|
57
|
+
focused: false,
|
|
58
|
+
focusVisible: false
|
|
59
|
+
}),
|
|
60
|
+
...(resolvedDisabled && {
|
|
61
|
+
accessibilityState: {
|
|
62
|
+
disabled: true
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
65
|
+
disabled: resolvedDisabled,
|
|
66
|
+
ref: mergeRefs(ref, child.props.ref),
|
|
67
|
+
style: [rowStyle, style, child.props.style]
|
|
68
|
+
};
|
|
69
|
+
if (resolvedDisabled) {
|
|
70
|
+
cloneProps.onPress = undefined;
|
|
71
|
+
} else if (onPress) {
|
|
72
|
+
cloneProps.onPress = composeEventHandlers(childOnPress, onPress);
|
|
73
|
+
}
|
|
74
|
+
return /*#__PURE__*/React.cloneElement(child, cloneProps);
|
|
75
|
+
}
|
|
76
|
+
if (isPressableRoot) {
|
|
77
|
+
const interactionAttrs = dataAttributes({
|
|
78
|
+
active: isPressed,
|
|
79
|
+
hover: isHovered,
|
|
80
|
+
disabled,
|
|
81
|
+
focused: isFocused,
|
|
82
|
+
focusVisible: isFocusVisible
|
|
83
|
+
});
|
|
84
|
+
const {
|
|
85
|
+
onPressIn: onPressInProp,
|
|
86
|
+
onPressOut: onPressOutProp,
|
|
87
|
+
onHoverIn: onHoverInProp,
|
|
88
|
+
onHoverOut: onHoverOutProp,
|
|
89
|
+
onFocus: onFocusProp,
|
|
90
|
+
onBlur: onBlurProp
|
|
91
|
+
} = restProps;
|
|
92
|
+
return /*#__PURE__*/_jsx(BasePressable, {
|
|
93
|
+
...restProps,
|
|
94
|
+
...chipSlotAttrs,
|
|
95
|
+
...interactionAttrs,
|
|
96
|
+
accessibilityRole: accessibilityRole ?? 'button',
|
|
97
|
+
...(disabled && {
|
|
98
|
+
accessibilityState: {
|
|
99
|
+
disabled: true
|
|
100
|
+
}
|
|
101
|
+
}),
|
|
102
|
+
disabled: disabled,
|
|
103
|
+
ref: ref,
|
|
104
|
+
style: [rowStyle, style],
|
|
105
|
+
onPress: disabled ? undefined : onPress,
|
|
106
|
+
onPressIn: composeEventHandlers(onPressInProp, pressProps.onPressIn),
|
|
107
|
+
onPressOut: composeEventHandlers(onPressOutProp, pressProps.onPressOut),
|
|
108
|
+
onHoverIn: composeEventHandlers(onHoverInProp, hoverProps.onHoverIn),
|
|
109
|
+
onHoverOut: composeEventHandlers(onHoverOutProp, hoverProps.onHoverOut),
|
|
110
|
+
onFocus: composeEventHandlers(composeEventHandlers(onFocusProp, focusProps.onFocus), focusRingProps.onFocus),
|
|
111
|
+
onBlur: composeEventHandlers(composeEventHandlers(onBlurProp, focusProps.onBlur), focusRingProps.onBlur),
|
|
112
|
+
children: children
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return /*#__PURE__*/_jsx(BaseView, {
|
|
116
|
+
...restProps,
|
|
117
|
+
...chipSlotAttrs,
|
|
118
|
+
...(disabled ? dataAttributes({
|
|
119
|
+
disabled: true
|
|
120
|
+
}) : undefined),
|
|
121
|
+
ref: ref,
|
|
122
|
+
style: [rowStyle, style],
|
|
123
|
+
children: children
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
//# sourceMappingURL=createChipRoot.js.map
|