@plasmicapp/react-web 0.2.114 → 0.2.116
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/all.d.ts +24 -24
- package/dist/index-common.d.ts +2 -0
- package/dist/react-web.cjs.development.js +1607 -1605
- package/dist/react-web.cjs.development.js.map +1 -1
- package/dist/react-web.cjs.production.min.js +1 -1
- package/dist/react-web.cjs.production.min.js.map +1 -1
- package/dist/react-web.esm.js +1607 -1605
- package/dist/react-web.esm.js.map +1 -1
- package/package.json +2 -2
- package/skinny/dist/index-common.d.ts +2 -0
- package/skinny/dist/index.js +408 -2
- package/skinny/dist/index.js.map +1 -1
|
@@ -13,6 +13,9 @@ var ReactDOM__default = _interopDefault(ReactDOM);
|
|
|
13
13
|
var dataSourcesContext = require('@plasmicapp/data-sources-context');
|
|
14
14
|
var ssr = require('@react-aria/ssr');
|
|
15
15
|
var focus = require('@react-aria/focus');
|
|
16
|
+
var deepEqual = _interopDefault(require('fast-deep-equal'));
|
|
17
|
+
var valtio = require('valtio');
|
|
18
|
+
var utils = require('valtio/utils');
|
|
16
19
|
var checkbox = require('@react-aria/checkbox');
|
|
17
20
|
var visuallyHidden = require('@react-aria/visually-hidden');
|
|
18
21
|
var toggle = require('@react-stately/toggle');
|
|
@@ -27,9 +30,6 @@ var listbox = require('@react-aria/listbox');
|
|
|
27
30
|
var select$1 = require('@react-stately/select');
|
|
28
31
|
var _switch = require('@react-aria/switch');
|
|
29
32
|
var overlays = require('@react-aria/overlays');
|
|
30
|
-
var deepEqual = _interopDefault(require('fast-deep-equal'));
|
|
31
|
-
var valtio = require('valtio');
|
|
32
|
-
var utils = require('valtio/utils');
|
|
33
33
|
|
|
34
34
|
function _extends() {
|
|
35
35
|
_extends = Object.assign || function (target) {
|
|
@@ -1282,7 +1282,9 @@ var PlasmicLink = /*#__PURE__*/React__default.forwardRef(function PlasmicLink(pr
|
|
|
1282
1282
|
// then we just render the default anchor element
|
|
1283
1283
|
if (props.platform === "nextjs" && props.href) {
|
|
1284
1284
|
var nextjsProps = ["href", "replace", "scroll", "shallow", "passHref", "prefetch", "locale"];
|
|
1285
|
-
return React__default.createElement(props.component,
|
|
1285
|
+
return React__default.createElement(props.component, _extends({}, pick.apply(void 0, [props].concat(nextjsProps)), {
|
|
1286
|
+
legacyBehavior: true
|
|
1287
|
+
}), React__default.createElement("a", Object.assign({}, omit.apply(void 0, [props, "component", "platform"].concat(nextjsProps)), {
|
|
1286
1288
|
ref: ref
|
|
1287
1289
|
})));
|
|
1288
1290
|
}
|
|
@@ -1687,649 +1689,556 @@ function useTrigger(trigger, opts) {
|
|
|
1687
1689
|
return TRIGGER_TO_HOOK[trigger](opts);
|
|
1688
1690
|
}
|
|
1689
1691
|
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
var PLUME_STRICT_MODE = true;
|
|
1694
|
-
function setPlumeStrictMode(mode) {
|
|
1695
|
-
PLUME_STRICT_MODE = mode;
|
|
1696
|
-
}
|
|
1697
|
-
function mergeVariantToggles() {
|
|
1698
|
-
for (var _len = arguments.length, toggles = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1699
|
-
toggles[_key] = arguments[_key];
|
|
1700
|
-
}
|
|
1701
|
-
|
|
1702
|
-
var definedToggles = toggles.filter(function (x) {
|
|
1703
|
-
return !!x.def;
|
|
1704
|
-
});
|
|
1705
|
-
var grouped = groupBy(definedToggles, function (_ref) {
|
|
1706
|
-
var def = _ref.def;
|
|
1707
|
-
return def.group;
|
|
1708
|
-
});
|
|
1709
|
-
return mapValues(grouped, function (subToggles) {
|
|
1710
|
-
return Object.fromEntries(subToggles.map(function (_ref2) {
|
|
1711
|
-
var def = _ref2.def,
|
|
1712
|
-
active = _ref2.active;
|
|
1713
|
-
return [def.variant, !!active];
|
|
1714
|
-
}));
|
|
1715
|
-
});
|
|
1716
|
-
}
|
|
1717
|
-
function noOutline() {
|
|
1718
|
-
return {
|
|
1719
|
-
outline: "none"
|
|
1692
|
+
function generateStateOnChangeProp($state, stateName, dataReps) {
|
|
1693
|
+
return function (val, path) {
|
|
1694
|
+
return set($state, [stateName].concat(dataReps, path), val);
|
|
1720
1695
|
};
|
|
1721
1696
|
}
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1697
|
+
/**
|
|
1698
|
+
* This function generate the state value prop for repeated states
|
|
1699
|
+
* Example:
|
|
1700
|
+
* - parent[][].counter[].count
|
|
1701
|
+
* We need to pass `parent[index1][index2].counter to the child component
|
|
1702
|
+
*/
|
|
1726
1703
|
|
|
1727
|
-
|
|
1728
|
-
|
|
1704
|
+
function generateStateValueProp($state, path // ["parent", 0, 1, "counter"]
|
|
1705
|
+
) {
|
|
1706
|
+
return _get($state, path);
|
|
1729
1707
|
}
|
|
1708
|
+
/**
|
|
1709
|
+
* Forked from https://github.com/lukeed/dset
|
|
1710
|
+
* Changes: fixed setting a deep value to a proxy object
|
|
1711
|
+
*/
|
|
1730
1712
|
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
var
|
|
1713
|
+
function set(obj, keys, val) {
|
|
1714
|
+
keys = keys.split ? keys.split(".") : keys;
|
|
1715
|
+
var i = 0,
|
|
1716
|
+
l = keys.length,
|
|
1717
|
+
t = obj,
|
|
1718
|
+
x,
|
|
1719
|
+
k;
|
|
1734
1720
|
|
|
1735
|
-
|
|
1736
|
-
|
|
1721
|
+
while (i < l) {
|
|
1722
|
+
k = keys[i++];
|
|
1723
|
+
if (k === "__proto__" || k === "constructor" || k === "prototype") break;
|
|
1724
|
+
|
|
1725
|
+
if (i === l) {
|
|
1726
|
+
t[k] = val;
|
|
1727
|
+
t = t[k];
|
|
1728
|
+
} else {
|
|
1729
|
+
if (typeof (x = t[k]) === typeof keys) {
|
|
1730
|
+
t = t[k] = x;
|
|
1731
|
+
} else if (keys[i] * 0 !== 0 || !!~("" + keys[i]).indexOf(".")) {
|
|
1732
|
+
t[k] = {};
|
|
1733
|
+
t = t[k];
|
|
1734
|
+
} else {
|
|
1735
|
+
t[k] = [];
|
|
1736
|
+
t = t[k];
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1737
1739
|
}
|
|
1740
|
+
}
|
|
1738
1741
|
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
endIcon = props.endIcon,
|
|
1743
|
-
showStartIcon = props.showStartIcon,
|
|
1744
|
-
showEndIcon = props.showEndIcon,
|
|
1745
|
-
children = props.children,
|
|
1746
|
-
rest = _objectWithoutPropertiesLoose(props, _excluded$4);
|
|
1742
|
+
var mkUntrackedValue = function mkUntrackedValue(o) {
|
|
1743
|
+
return typeof o === "object" ? valtio.ref(o) : o;
|
|
1744
|
+
};
|
|
1747
1745
|
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
}
|
|
1752
|
-
def: config.showEndIconVariant,
|
|
1753
|
-
active: showEndIcon
|
|
1754
|
-
}, {
|
|
1755
|
-
def: config.isDisabledVariant,
|
|
1756
|
-
active: isDisabled
|
|
1757
|
-
}));
|
|
1746
|
+
var transformPathStringToObj = function transformPathStringToObj(str) {
|
|
1747
|
+
var splitStatePathPart = function splitStatePathPart(state) {
|
|
1748
|
+
return state.endsWith("[]") ? [].concat(splitStatePathPart(state.slice(0, -2)), ["[]"]) : [state];
|
|
1749
|
+
};
|
|
1758
1750
|
|
|
1759
|
-
|
|
1751
|
+
return str.split(".").flatMap(splitStatePathPart);
|
|
1752
|
+
};
|
|
1760
1753
|
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
disabled: isDisabled
|
|
1766
|
-
}, !!link && {
|
|
1767
|
-
href: link
|
|
1768
|
-
})
|
|
1769
|
-
}, _overrides);
|
|
1770
|
-
return {
|
|
1771
|
-
plasmicProps: {
|
|
1772
|
-
variants: variants,
|
|
1773
|
-
args: args,
|
|
1774
|
-
overrides: overrides
|
|
1775
|
-
}
|
|
1776
|
-
};
|
|
1777
|
-
}
|
|
1754
|
+
function shallowEqual(a1, a2) {
|
|
1755
|
+
if (a1.length !== a2.length) {
|
|
1756
|
+
return false;
|
|
1757
|
+
}
|
|
1778
1758
|
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
function getDefaultPlasmicProps(plasmicClass, props) {
|
|
1783
|
-
return {
|
|
1784
|
-
plasmicProps: {
|
|
1785
|
-
variants: pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)),
|
|
1786
|
-
args: pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)),
|
|
1787
|
-
overrides: {}
|
|
1759
|
+
for (var i = 0; i < a1.length; i++) {
|
|
1760
|
+
if (a1[i] !== a2[i]) {
|
|
1761
|
+
return false;
|
|
1788
1762
|
}
|
|
1789
|
-
}
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
return true;
|
|
1790
1766
|
}
|
|
1791
|
-
|
|
1792
|
-
function
|
|
1793
|
-
return
|
|
1794
|
-
return RE_DATA_PROP.test(k);
|
|
1795
|
-
});
|
|
1767
|
+
|
|
1768
|
+
function isNum(value) {
|
|
1769
|
+
return typeof value === "symbol" ? false : !isNaN(+value);
|
|
1796
1770
|
}
|
|
1797
1771
|
|
|
1798
|
-
function
|
|
1799
|
-
var
|
|
1800
|
-
|
|
1801
|
-
|
|
1772
|
+
function saveNewState($$state, path, spec) {
|
|
1773
|
+
var key = JSON.stringify(path);
|
|
1774
|
+
$$state.existingStates.set(key, {
|
|
1775
|
+
path: path,
|
|
1776
|
+
specKey: spec.path
|
|
1802
1777
|
});
|
|
1803
1778
|
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
}
|
|
1779
|
+
if (!$$state.statesInstanceBySpec.has(spec.path)) {
|
|
1780
|
+
$$state.statesInstanceBySpec.set(spec.path, []);
|
|
1781
|
+
}
|
|
1808
1782
|
|
|
1809
|
-
|
|
1810
|
-
|
|
1783
|
+
$$state.statesInstanceBySpec.get(spec.path).push({
|
|
1784
|
+
path: path,
|
|
1785
|
+
specKey: spec.path
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
1811
1788
|
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1789
|
+
function create$StateProxy($$state, handlers) {
|
|
1790
|
+
var getNextKeyToSpecMap = function getNextKeyToSpecMap(currPath) {
|
|
1791
|
+
return new Map(Object.entries(Object.values($$state.specsByKey).filter(function (spec) {
|
|
1792
|
+
return shallowEqual(currPath.map(function (p) {
|
|
1793
|
+
return isNum(p) ? "[]" : p;
|
|
1794
|
+
}), spec.pathObj.slice(0, currPath.length));
|
|
1795
|
+
}).reduce(function (agg, spec) {
|
|
1796
|
+
var nextKey = spec.pathObj[currPath.length];
|
|
1815
1797
|
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
useEnsureSSRProvider();
|
|
1820
|
-
var inputRef = React.useRef(null);
|
|
1821
|
-
var rootRef = React.useRef(null);
|
|
1822
|
-
var ariaProps = asAriaCheckboxProps(props);
|
|
1823
|
-
var state = toggle.useToggleState(ariaProps);
|
|
1798
|
+
if (!(nextKey in agg)) {
|
|
1799
|
+
agg[nextKey] = [];
|
|
1800
|
+
}
|
|
1824
1801
|
|
|
1825
|
-
|
|
1826
|
-
|
|
1802
|
+
agg[nextKey].push(spec);
|
|
1803
|
+
return agg;
|
|
1804
|
+
}, {})));
|
|
1805
|
+
};
|
|
1827
1806
|
|
|
1828
|
-
var
|
|
1829
|
-
|
|
1830
|
-
active: isDisabled
|
|
1831
|
-
}, {
|
|
1832
|
-
def: config.isCheckedVariant,
|
|
1833
|
-
active: state.isSelected
|
|
1834
|
-
}, {
|
|
1835
|
-
def: config.isIndeterminateVariant,
|
|
1836
|
-
active: isIndeterminate
|
|
1837
|
-
}, {
|
|
1838
|
-
def: config.noLabelVariant,
|
|
1839
|
-
active: !children
|
|
1840
|
-
}));
|
|
1807
|
+
var rec = function rec(currPath) {
|
|
1808
|
+
var nextKeyToSpecs = getNextKeyToSpecMap(currPath);
|
|
1841
1809
|
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
props: mergeProps(getStyleProps(props), {
|
|
1845
|
-
ref: rootRef
|
|
1846
|
-
}),
|
|
1847
|
-
wrapChildren: function wrapChildren(children) {
|
|
1848
|
-
return React.createElement(React.Fragment, null, React.createElement(visuallyHidden.VisuallyHidden, {
|
|
1849
|
-
isFocusable: true
|
|
1850
|
-
}, React.createElement("input", Object.assign({}, inputProps, {
|
|
1851
|
-
ref: inputRef
|
|
1852
|
-
}))), children);
|
|
1853
|
-
}
|
|
1854
|
-
}, _overrides);
|
|
1810
|
+
var getSpecForProperty = function getSpecForProperty(property) {
|
|
1811
|
+
var _nextKeyToSpecs$get, _nextKeyToSpecs$get2;
|
|
1855
1812
|
|
|
1856
|
-
|
|
1813
|
+
return nextKeyToSpecs.has("[]") && isNum(property) ? (_nextKeyToSpecs$get = nextKeyToSpecs.get("[]")) == null ? void 0 : _nextKeyToSpecs$get[0] : typeof property === "string" && nextKeyToSpecs.has(property) ? (_nextKeyToSpecs$get2 = nextKeyToSpecs.get(property)) == null ? void 0 : _nextKeyToSpecs$get2[0] : undefined;
|
|
1814
|
+
};
|
|
1857
1815
|
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
setChecked: function setChecked(checked) {
|
|
1861
|
-
return state.setSelected(checked);
|
|
1862
|
-
}
|
|
1816
|
+
var getNextPath = function getNextPath(property) {
|
|
1817
|
+
return [].concat(currPath, [isNum(property) ? +property : property]);
|
|
1863
1818
|
};
|
|
1864
|
-
}, [state]);
|
|
1865
|
-
React.useImperativeHandle(ref, function () {
|
|
1866
|
-
return {
|
|
1867
|
-
getRoot: function getRoot() {
|
|
1868
|
-
return rootRef.current;
|
|
1869
|
-
},
|
|
1870
|
-
focus: function focus() {
|
|
1871
|
-
var _inputRef$current;
|
|
1872
1819
|
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
var
|
|
1820
|
+
return new Proxy(nextKeyToSpecs.has("[]") ? [] : {}, {
|
|
1821
|
+
deleteProperty: function deleteProperty(target, property) {
|
|
1822
|
+
var prefixPath = getNextPath(property);
|
|
1823
|
+
var specKeysToUpdate = new Set();
|
|
1824
|
+
$$state.existingStates.forEach(function (_ref) {
|
|
1825
|
+
var path = _ref.path,
|
|
1826
|
+
specKey = _ref.specKey;
|
|
1877
1827
|
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
return {
|
|
1886
|
-
plasmicProps: {
|
|
1887
|
-
variants: variants,
|
|
1888
|
-
overrides: overrides,
|
|
1889
|
-
args: args
|
|
1890
|
-
},
|
|
1891
|
-
state: plumeState
|
|
1892
|
-
};
|
|
1893
|
-
}
|
|
1828
|
+
if (path.length >= prefixPath.length && shallowEqual(path.slice(0, prefixPath.length), prefixPath)) {
|
|
1829
|
+
deleteState($$state, path);
|
|
1830
|
+
specKeysToUpdate.add(specKey);
|
|
1831
|
+
}
|
|
1832
|
+
});
|
|
1833
|
+
specKeysToUpdate.forEach(function (specKey) {
|
|
1834
|
+
var spec = $$state.specsByKey[specKey];
|
|
1894
1835
|
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
* that we will pass into the Collections API. These will be
|
|
1898
|
-
* ReactElement<ItemLikeProps|SectionLikeProps>[].
|
|
1899
|
-
*
|
|
1900
|
-
* Will also assign keys to items by their index in the collection,
|
|
1901
|
-
* and collect the keys of disabled items.
|
|
1902
|
-
*/
|
|
1836
|
+
if (spec.onChangeProp) {
|
|
1837
|
+
var _$$state$props$spec$o, _$$state$props;
|
|
1903
1838
|
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1839
|
+
(_$$state$props$spec$o = (_$$state$props = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o.call(_$$state$props, _get($$state.stateValues, currPath), currPath);
|
|
1840
|
+
}
|
|
1841
|
+
});
|
|
1842
|
+
return Reflect.deleteProperty(target, property);
|
|
1843
|
+
},
|
|
1844
|
+
get: function get(target, property, receiver) {
|
|
1845
|
+
var spec = getSpecForProperty(property);
|
|
1911
1846
|
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
invalidChildError = opts.invalidChildError; // For Plume items without an explicit key, we assign a key as the index
|
|
1915
|
-
// of the collection.
|
|
1847
|
+
if (spec && typeof property !== "symbol") {
|
|
1848
|
+
var nextPath = getNextPath(property);
|
|
1916
1849
|
|
|
1917
|
-
|
|
1918
|
-
|
|
1850
|
+
if (spec.pathObj.length === currPath.length + 1) {
|
|
1851
|
+
var _handlers$get, _handlers;
|
|
1919
1852
|
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
value: "" + itemCount++
|
|
1927
|
-
});
|
|
1928
|
-
}
|
|
1929
|
-
} else {
|
|
1930
|
-
// Still increment count even if key is present, so that the
|
|
1931
|
-
// auto-assigned key really reflects the index
|
|
1932
|
-
itemCount++;
|
|
1933
|
-
return element;
|
|
1934
|
-
}
|
|
1935
|
-
};
|
|
1853
|
+
// reached the end of the spec
|
|
1854
|
+
target[property] = (_handlers$get = (_handlers = handlers(nextPath, spec)).get) == null ? void 0 : _handlers$get.call(_handlers, target, property, receiver);
|
|
1855
|
+
} else if (!(property in target)) {
|
|
1856
|
+
target[property] = rec(nextPath);
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1936
1859
|
|
|
1937
|
-
|
|
1860
|
+
return Reflect.get(target, property, receiver);
|
|
1861
|
+
},
|
|
1862
|
+
set: function set$1(target, property, value, receiver) {
|
|
1863
|
+
var spec = getSpecForProperty(property);
|
|
1864
|
+
var nextPath = getNextPath(property);
|
|
1938
1865
|
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
if (child.type === React__default.Fragment) {
|
|
1943
|
-
return flattenedChildren(child.props.children);
|
|
1944
|
-
}
|
|
1866
|
+
if (spec && typeof property !== "symbol") {
|
|
1867
|
+
if (spec.pathObj.length === currPath.length + 1) {
|
|
1868
|
+
var _handlers$set, _handlers2;
|
|
1945
1869
|
|
|
1946
|
-
|
|
1870
|
+
// reached the end of the spec
|
|
1871
|
+
target[property] = (_handlers$set = (_handlers2 = handlers(nextPath, spec)).set) == null ? void 0 : _handlers$set.call(_handlers2, target, property, value, receiver);
|
|
1872
|
+
return Reflect.set(target, property, value, receiver);
|
|
1873
|
+
} else if (typeof value === "object") {
|
|
1874
|
+
target[property] = rec(nextPath);
|
|
1947
1875
|
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1876
|
+
for (var _i = 0, _Object$keys = Object.keys(value); _i < _Object$keys.length; _i++) {
|
|
1877
|
+
var key = _Object$keys[_i];
|
|
1878
|
+
target[property][key] = value[key];
|
|
1879
|
+
}
|
|
1951
1880
|
|
|
1952
|
-
|
|
1953
|
-
disabledKeys.push(childKey);
|
|
1881
|
+
return true;
|
|
1954
1882
|
}
|
|
1883
|
+
}
|
|
1955
1884
|
|
|
1956
|
-
|
|
1885
|
+
if (property === "registerInitFunc" && currPath.length === 0) {
|
|
1886
|
+
return Reflect.set(target, property, value, receiver);
|
|
1957
1887
|
}
|
|
1958
1888
|
|
|
1959
|
-
if (
|
|
1960
|
-
var
|
|
1889
|
+
if (nextKeyToSpecs.has("[]")) {
|
|
1890
|
+
var _nextKeyToSpecs$get3;
|
|
1961
1891
|
|
|
1962
|
-
|
|
1963
|
-
// key of section doesn't actually matter, just needs
|
|
1964
|
-
// to be unique
|
|
1965
|
-
key: (_child$key = child.key) != null ? _child$key : "section-" + sectionCount++,
|
|
1966
|
-
children: flattenedChildren(getChildProp(child, "children"))
|
|
1967
|
-
})];
|
|
1968
|
-
}
|
|
1969
|
-
}
|
|
1892
|
+
set($$state.stateValues, nextPath, value);
|
|
1970
1893
|
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1894
|
+
(_nextKeyToSpecs$get3 = nextKeyToSpecs.get("[]")) == null ? void 0 : _nextKeyToSpecs$get3.forEach(function (spec) {
|
|
1895
|
+
if (spec != null && spec.onChangeProp) {
|
|
1896
|
+
var _$$state$props$spec$o2, _$$state$props2;
|
|
1897
|
+
|
|
1898
|
+
(_$$state$props$spec$o2 = (_$$state$props2 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o2.call(_$$state$props2, value, nextPath);
|
|
1899
|
+
}
|
|
1900
|
+
});
|
|
1901
|
+
return Reflect.set(target, property, value, receiver);
|
|
1902
|
+
} // invalid setting a value that doesn't make part of the spec
|
|
1903
|
+
|
|
1904
|
+
|
|
1905
|
+
return false;
|
|
1975
1906
|
}
|
|
1976
1907
|
});
|
|
1977
1908
|
};
|
|
1978
1909
|
|
|
1979
|
-
return
|
|
1980
|
-
items: flattenedChildren(children),
|
|
1981
|
-
disabledKeys: disabledKeys
|
|
1982
|
-
};
|
|
1983
|
-
}
|
|
1984
|
-
function useDerivedItemsFromChildren(children, opts) {
|
|
1985
|
-
var itemPlumeType = opts.itemPlumeType,
|
|
1986
|
-
sectionPlumeType = opts.sectionPlumeType,
|
|
1987
|
-
invalidChildError = opts.invalidChildError,
|
|
1988
|
-
requireItemValue = opts.requireItemValue;
|
|
1989
|
-
return React__default.useMemo(function () {
|
|
1990
|
-
return deriveItemsFromChildren(children, {
|
|
1991
|
-
itemPlumeType: itemPlumeType,
|
|
1992
|
-
sectionPlumeType: sectionPlumeType,
|
|
1993
|
-
invalidChildError: invalidChildError,
|
|
1994
|
-
requireItemValue: requireItemValue
|
|
1995
|
-
});
|
|
1996
|
-
}, [children, itemPlumeType, sectionPlumeType, invalidChildError, requireItemValue]);
|
|
1997
|
-
}
|
|
1998
|
-
/**
|
|
1999
|
-
* Given a Collection node, create the React element that we should use
|
|
2000
|
-
* to render it.
|
|
2001
|
-
*/
|
|
2002
|
-
|
|
2003
|
-
function renderCollectionNode(node) {
|
|
2004
|
-
// node.rendered should already have our item-like or section-like Plume
|
|
2005
|
-
// component elements, so we just need to clone them with a secret
|
|
2006
|
-
// _node prop that we use to render.
|
|
2007
|
-
return cloneChild(node.rendered, {
|
|
2008
|
-
_node: node,
|
|
2009
|
-
key: node.key
|
|
2010
|
-
});
|
|
1910
|
+
return rec([]);
|
|
2011
1911
|
}
|
|
2012
|
-
/**
|
|
2013
|
-
* Renders a item-like or section-like Plume component element into an
|
|
2014
|
-
* Item or a Section element.
|
|
2015
|
-
*/
|
|
2016
1912
|
|
|
2017
|
-
function
|
|
2018
|
-
var
|
|
1913
|
+
var deleteState = function deleteState($$state, path) {
|
|
1914
|
+
var _$$state$unsubscripti;
|
|
2019
1915
|
|
|
2020
|
-
|
|
2021
|
-
|
|
1916
|
+
var key = JSON.stringify(path);
|
|
1917
|
+
(_$$state$unsubscripti = $$state.unsubscriptionsByState[key]) == null ? void 0 : _$$state$unsubscripti.forEach(function (f) {
|
|
1918
|
+
return f();
|
|
1919
|
+
});
|
|
1920
|
+
delete $$state.unsubscriptionsByState[key];
|
|
1921
|
+
$$state.existingStates["delete"](key); // delete get($$state.stateValues, path.slice(-1))[path.slice(-1)[0]];
|
|
1922
|
+
// delete get($$state.initStateValues, path.slice(-1))[path.slice(-1)[0]];
|
|
1923
|
+
};
|
|
2022
1924
|
|
|
2023
|
-
|
|
2024
|
-
|
|
1925
|
+
var getIndexes = function getIndexes(path, spec) {
|
|
1926
|
+
var indexes = [];
|
|
2025
1927
|
|
|
2026
|
-
|
|
1928
|
+
if (path.length !== spec.pathObj.length) {
|
|
1929
|
+
throw new Error("Unexpected error: state path and spec path have different lengths");
|
|
1930
|
+
}
|
|
2027
1931
|
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
// We use ItemLike.value if the user explicitly specified a value,
|
|
2033
|
-
// and we fallback to key. If the user specified neither, then
|
|
2034
|
-
// the Collections API will generate a unique key for this item.
|
|
2035
|
-
key: getItemLikeKey(option),
|
|
2036
|
-
// textValue is either explicitly specified by the user, or we
|
|
2037
|
-
// try to derive it if `content` is a string.
|
|
2038
|
-
textValue: (_getChildProp = getChildProp(option, "textValue")) != null ? _getChildProp : isString(content) ? content : propInChild(option, "value") ? getChildProp(option, "value") : option.key,
|
|
2039
|
-
"aria-label": getChildProp(option, "aria-label")
|
|
2040
|
-
}, option);
|
|
2041
|
-
} else {
|
|
2042
|
-
var group = child;
|
|
2043
|
-
return React__default.createElement(collections.Section // Note that we are using the whole section-like element as the title
|
|
2044
|
-
// here, and not group.props.title; we want the entire section-like
|
|
2045
|
-
// Plume element to end up as Node.rendered.
|
|
2046
|
-
, {
|
|
2047
|
-
// Note that we are using the whole section-like element as the title
|
|
2048
|
-
// here, and not group.props.title; we want the entire section-like
|
|
2049
|
-
// Plume element to end up as Node.rendered.
|
|
2050
|
-
title: group,
|
|
2051
|
-
"aria-label": getChildProp(group, "aria-label"),
|
|
2052
|
-
// We are flattening and deriving the descendant Options as items here.
|
|
2053
|
-
// group.props.children should've already been cleaned up by
|
|
2054
|
-
// deriveItemsFromChildren()
|
|
2055
|
-
items: getChildProp(group, "children")
|
|
2056
|
-
}, function (c) {
|
|
2057
|
-
return renderAsCollectionChild(c, opts);
|
|
2058
|
-
});
|
|
1932
|
+
for (var i = 0; i < spec.pathObj.length; i++) {
|
|
1933
|
+
if (spec.pathObj[i] === "[]") {
|
|
1934
|
+
indexes.push(path[i]);
|
|
1935
|
+
}
|
|
2059
1936
|
}
|
|
2060
|
-
}
|
|
2061
|
-
|
|
2062
|
-
function getItemLikeKey(element) {
|
|
2063
|
-
var _getChildProp2;
|
|
2064
|
-
|
|
2065
|
-
return (_getChildProp2 = getChildProp(element, "value")) != null ? _getChildProp2 : element.key;
|
|
2066
|
-
} // PlasmicLoader-aware function to get prop from child.
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
function getChildProp(child, prop) {
|
|
2070
|
-
return "componentProps" in child.props ? child.props.componentProps[prop] : child.props[prop];
|
|
2071
|
-
} // PlasmicLoader-aware function to check `if (prop in element.props)`.
|
|
2072
|
-
|
|
2073
|
-
function propInChild(child, prop) {
|
|
2074
|
-
return "componentProps" in child.props ? prop in child.props.componentProps : prop in child.props;
|
|
2075
|
-
} // PlasmicLoader-aware function to clone React element.
|
|
2076
1937
|
|
|
1938
|
+
return indexes;
|
|
1939
|
+
};
|
|
2077
1940
|
|
|
2078
|
-
function
|
|
2079
|
-
|
|
2080
|
-
// If React element has getPlumeType(), assume that it is PlasmicLoader,
|
|
2081
|
-
// so add nodeProps to componentProps instead of element props.
|
|
2082
|
-
return React__default.cloneElement(child, _extends({
|
|
2083
|
-
componentProps: _extends({}, child.props.componentProps, props)
|
|
2084
|
-
}, props.key ? {
|
|
2085
|
-
key: props.key
|
|
2086
|
-
} : {}));
|
|
2087
|
-
}
|
|
1941
|
+
function initializeStateValue($$state, initialStatePath, initialSpec) {
|
|
1942
|
+
var _$$state$unsubscripti2;
|
|
2088
1943
|
|
|
2089
|
-
|
|
2090
|
-
|
|
1944
|
+
var initialStateKey = JSON.stringify(initialStatePath);
|
|
1945
|
+
var stateAccess = new Set();
|
|
1946
|
+
var $state = create$StateProxy($$state, function (path, spec) {
|
|
1947
|
+
return {
|
|
1948
|
+
get: function get() {
|
|
1949
|
+
var key = JSON.stringify(path);
|
|
1950
|
+
stateAccess.add({
|
|
1951
|
+
path: path,
|
|
1952
|
+
spec: spec
|
|
1953
|
+
});
|
|
2091
1954
|
|
|
2092
|
-
|
|
1955
|
+
if (spec.valueProp) {
|
|
1956
|
+
return !spec.isRepeated ? $$state.props[spec.valueProp] : _get($$state.props[spec.valueProp], path.slice(1));
|
|
1957
|
+
}
|
|
2093
1958
|
|
|
2094
|
-
|
|
1959
|
+
if ($$state.existingStates.has(key)) {
|
|
1960
|
+
// is already initialized
|
|
1961
|
+
return _get($$state.stateValues, path);
|
|
1962
|
+
} else if (spec.initFunc) {
|
|
1963
|
+
initializeStateValue($$state, path, spec);
|
|
1964
|
+
}
|
|
2095
1965
|
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
}
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
1966
|
+
return _get($$state.stateValues, path);
|
|
1967
|
+
},
|
|
1968
|
+
set: function set() {
|
|
1969
|
+
throw new Error("Cannot update state values during initialization");
|
|
1970
|
+
}
|
|
1971
|
+
};
|
|
1972
|
+
});
|
|
1973
|
+
(_$$state$unsubscripti2 = $$state.unsubscriptionsByState[initialStateKey]) == null ? void 0 : _$$state$unsubscripti2.forEach(function (f) {
|
|
1974
|
+
return f();
|
|
1975
|
+
});
|
|
1976
|
+
$$state.unsubscriptionsByState[initialStateKey] = [];
|
|
1977
|
+
stateAccess.forEach(function (_ref2) {
|
|
1978
|
+
var path = _ref2.path,
|
|
1979
|
+
spec = _ref2.spec;
|
|
1980
|
+
var unsubscribe = utils.subscribeKey(_get($$state.stateValues, path.slice(-1)), path.slice(-1)[0], function () {
|
|
1981
|
+
return set($$state.stateValues, initialStatePath, mkUntrackedValue(initialSpec.initFunc($$state.props, $state, getIndexes(path, spec))));
|
|
1982
|
+
});
|
|
1983
|
+
$$state.unsubscriptionsByState[initialStateKey].push(unsubscribe);
|
|
1984
|
+
});
|
|
1985
|
+
var untrackedInitialValue = mkUntrackedValue(initialSpec.initFunc($$state.props, $state, getIndexes(initialStatePath, initialSpec)));
|
|
2104
1986
|
|
|
2105
|
-
|
|
2106
|
-
var children = props.children,
|
|
2107
|
-
rest = _objectWithoutPropertiesLoose(props, _excluded$5);
|
|
1987
|
+
set($$state.initStateValues, initialStatePath, untrackedInitialValue);
|
|
2108
1988
|
|
|
2109
|
-
|
|
2110
|
-
invalidChildError: "Can only use Menu.Item and Menu.Group as children to Menu",
|
|
2111
|
-
requireItemValue: false
|
|
2112
|
-
})),
|
|
2113
|
-
items = _useDerivedItemsFromC.items,
|
|
2114
|
-
disabledKeys = _useDerivedItemsFromC.disabledKeys;
|
|
1989
|
+
set($$state.stateValues, initialStatePath, untrackedInitialValue);
|
|
2115
1990
|
|
|
2116
|
-
|
|
2117
|
-
return renderAsCollectionChild(child, COLLECTION_OPTS);
|
|
2118
|
-
}, []);
|
|
2119
|
-
return {
|
|
2120
|
-
ariaProps: _extends({}, rest, {
|
|
2121
|
-
children: collectionChildRenderer,
|
|
2122
|
-
items: items,
|
|
2123
|
-
disabledKeys: disabledKeys
|
|
2124
|
-
})
|
|
2125
|
-
};
|
|
1991
|
+
return untrackedInitialValue;
|
|
2126
1992
|
}
|
|
2127
1993
|
|
|
2128
|
-
function
|
|
2129
|
-
var
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
1994
|
+
function useDollarState(specs, props) {
|
|
1995
|
+
var $$state = React__default.useRef(valtio.proxy({
|
|
1996
|
+
stateValues: {},
|
|
1997
|
+
initStateValues: {},
|
|
1998
|
+
specsByKey: Object.fromEntries(specs.map(function (spec) {
|
|
1999
|
+
return [spec.path, _extends({}, spec, {
|
|
2000
|
+
pathObj: transformPathStringToObj(spec.path),
|
|
2001
|
+
isRepeated: spec.path.split(".").some(function (part) {
|
|
2002
|
+
return part.endsWith("[]");
|
|
2003
|
+
})
|
|
2004
|
+
})];
|
|
2005
|
+
})),
|
|
2006
|
+
statesInstanceBySpec: new Map(),
|
|
2007
|
+
existingStates: new Map(),
|
|
2008
|
+
unsubscriptionsByState: {},
|
|
2009
|
+
props: undefined,
|
|
2010
|
+
registrationsQueue: []
|
|
2011
|
+
})).current;
|
|
2012
|
+
$$state.props = mkUntrackedValue(props);
|
|
2013
|
+
var $state = React__default.useRef(Object.assign(create$StateProxy($$state, function (path, spec) {
|
|
2014
|
+
var key = JSON.stringify(path);
|
|
2134
2015
|
|
|
2135
|
-
|
|
2016
|
+
if (!$$state.existingStates.has(key)) {
|
|
2017
|
+
var _spec$initVal;
|
|
2136
2018
|
|
|
2137
|
-
|
|
2138
|
-
|
|
2019
|
+
saveNewState($$state, path, spec);
|
|
2020
|
+
var untrackedValue = !spec.initFunc ? mkUntrackedValue((_spec$initVal = spec.initVal) != null ? _spec$initVal : undefined) : initializeStateValue($$state, path, spec);
|
|
2139
2021
|
|
|
2140
|
-
|
|
2141
|
-
var rootRef = React.useRef(null);
|
|
2142
|
-
var state = tree.useTreeState(ariaProps);
|
|
2143
|
-
var menuListRef = React.useRef(null);
|
|
2022
|
+
set($$state.stateValues, path, untrackedValue);
|
|
2144
2023
|
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
}), state, menuListRef),
|
|
2148
|
-
menuProps = _useAriaMenu.menuProps;
|
|
2024
|
+
set($$state.initStateValues, path, untrackedValue);
|
|
2025
|
+
}
|
|
2149
2026
|
|
|
2150
|
-
var contextValue = React.useMemo(function () {
|
|
2151
2027
|
return {
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2028
|
+
get: function get() {
|
|
2029
|
+
if (spec.valueProp) {
|
|
2030
|
+
var value = !spec.isRepeated ? $$state.props[spec.valueProp] : _get($$state.props[spec.valueProp], path.slice(1));
|
|
2031
|
+
return value;
|
|
2032
|
+
} else {
|
|
2033
|
+
return _get($$state.stateValues, path);
|
|
2034
|
+
}
|
|
2035
|
+
},
|
|
2036
|
+
set: function set$1(_t, _p, value) {
|
|
2037
|
+
set($$state.stateValues, path, mkUntrackedValue(value));
|
|
2158
2038
|
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
ref: rootRef
|
|
2162
|
-
})
|
|
2163
|
-
}, _overrides[config.itemsContainer] = {
|
|
2164
|
-
as: "ul",
|
|
2165
|
-
props: mergeProps(menuProps, {
|
|
2166
|
-
ref: menuListRef,
|
|
2167
|
-
style: _extends({}, noOutline())
|
|
2168
|
-
})
|
|
2169
|
-
}, _overrides);
|
|
2039
|
+
if (spec.onChangeProp) {
|
|
2040
|
+
var _$$state$props$spec$o3, _$$state$props3;
|
|
2170
2041
|
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
}, Array.from(state.collection).map(function (node) {
|
|
2174
|
-
return renderCollectionNode(node);
|
|
2175
|
-
})), _extends2));
|
|
2042
|
+
(_$$state$props$spec$o3 = (_$$state$props3 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o3.call(_$$state$props3, value, path);
|
|
2043
|
+
}
|
|
2176
2044
|
|
|
2177
|
-
|
|
2178
|
-
return {
|
|
2179
|
-
getFocusedValue: function getFocusedValue() {
|
|
2180
|
-
return state.selectionManager.focusedKey;
|
|
2181
|
-
},
|
|
2182
|
-
setFocusedValue: function setFocusedValue(value) {
|
|
2183
|
-
return state.selectionManager.setFocusedKey(value);
|
|
2045
|
+
return true;
|
|
2184
2046
|
}
|
|
2185
2047
|
};
|
|
2186
|
-
},
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
return
|
|
2194
|
-
}
|
|
2195
|
-
|
|
2196
|
-
|
|
2048
|
+
}), {
|
|
2049
|
+
registerInitFunc: function registerInitFunc(pathStr, f) {
|
|
2050
|
+
var _$$state$statesInstan;
|
|
2051
|
+
|
|
2052
|
+
if ((_$$state$statesInstan = $$state.statesInstanceBySpec.get(pathStr)) != null && _$$state$statesInstan.some(function (_ref3) {
|
|
2053
|
+
var path = _ref3.path,
|
|
2054
|
+
specKey = _ref3.specKey;
|
|
2055
|
+
return !deepEqual(_get($$state.initStateValues, path), f(props, $state, getIndexes(path, $$state.specsByKey[specKey])));
|
|
2056
|
+
})) {
|
|
2057
|
+
$$state.registrationsQueue.push({
|
|
2058
|
+
pathStr: pathStr,
|
|
2059
|
+
f: f
|
|
2060
|
+
});
|
|
2197
2061
|
}
|
|
2198
|
-
}
|
|
2199
|
-
}
|
|
2200
|
-
|
|
2201
|
-
plasmicProps: {
|
|
2202
|
-
variants: variants,
|
|
2203
|
-
args: args,
|
|
2204
|
-
overrides: overrides
|
|
2205
|
-
},
|
|
2206
|
-
state: plumeState
|
|
2207
|
-
};
|
|
2208
|
-
}
|
|
2062
|
+
}
|
|
2063
|
+
})).current; // For each spec with an initFunc, evaluate it and see if
|
|
2064
|
+
// the init value has changed. If so, reset its state.
|
|
2209
2065
|
|
|
2210
|
-
|
|
2211
|
-
|
|
2066
|
+
var resetSpecs = [];
|
|
2067
|
+
$$state.existingStates.forEach(function (_ref4) {
|
|
2068
|
+
var path = _ref4.path,
|
|
2069
|
+
specKey = _ref4.specKey;
|
|
2070
|
+
var spec = $$state.specsByKey[specKey];
|
|
2212
2071
|
|
|
2213
|
-
|
|
2214
|
-
|
|
2072
|
+
if (spec.initFunc) {
|
|
2073
|
+
var newInit = spec.initFunc(props, $state, getIndexes(path, spec));
|
|
2215
2074
|
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2075
|
+
if (!deepEqual(newInit, _get($$state.initStateValues, path))) {
|
|
2076
|
+
resetSpecs.push({
|
|
2077
|
+
path: path,
|
|
2078
|
+
spec: spec
|
|
2079
|
+
});
|
|
2080
|
+
}
|
|
2219
2081
|
}
|
|
2082
|
+
});
|
|
2083
|
+
React__default.useLayoutEffect(function () {
|
|
2084
|
+
resetSpecs.forEach(function (_ref5) {
|
|
2085
|
+
var path = _ref5.path,
|
|
2086
|
+
spec = _ref5.spec;
|
|
2087
|
+
var newInit = initializeStateValue($$state, path, spec);
|
|
2220
2088
|
|
|
2221
|
-
|
|
2222
|
-
|
|
2089
|
+
if (spec.onChangeProp) {
|
|
2090
|
+
var _$$state$props$spec$o4, _$$state$props4;
|
|
2223
2091
|
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
})
|
|
2228
|
-
|
|
2229
|
-
|
|
2092
|
+
(_$$state$props$spec$o4 = (_$$state$props4 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o4.call(_$$state$props4, newInit, path);
|
|
2093
|
+
}
|
|
2094
|
+
});
|
|
2095
|
+
}, [props, resetSpecs]);
|
|
2096
|
+
React__default.useLayoutEffect(function () {
|
|
2097
|
+
$$state.registrationsQueue.forEach(function (_ref6) {
|
|
2098
|
+
var f = _ref6.f,
|
|
2099
|
+
pathStr = _ref6.pathStr;
|
|
2100
|
+
$$state.specsByKey[pathStr].initFunc = f;
|
|
2101
|
+
});
|
|
2102
|
+
$$state.registrationsQueue = [];
|
|
2103
|
+
}, [$$state.registrationsQueue]); // Re-render if any value changed in one of these objects
|
|
2230
2104
|
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
})
|
|
2234
|
-
|
|
2105
|
+
valtio.useSnapshot($$state.stateValues, {
|
|
2106
|
+
sync: true
|
|
2107
|
+
});
|
|
2108
|
+
valtio.useSnapshot($$state.specsByKey, {
|
|
2109
|
+
sync: true
|
|
2110
|
+
});
|
|
2111
|
+
return $state;
|
|
2112
|
+
}
|
|
2235
2113
|
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2114
|
+
function useCanvasDollarState(specs, props) {
|
|
2115
|
+
var $$state = valtio.proxy({
|
|
2116
|
+
stateValues: {},
|
|
2117
|
+
initStateValues: {},
|
|
2118
|
+
specsByKey: Object.fromEntries(specs.map(function (spec) {
|
|
2119
|
+
return [spec.path, _extends({}, spec, {
|
|
2120
|
+
pathObj: transformPathStringToObj(spec.path),
|
|
2121
|
+
isRepeated: spec.path.split(".").some(function (part) {
|
|
2122
|
+
return part.endsWith("[]");
|
|
2123
|
+
})
|
|
2124
|
+
})];
|
|
2125
|
+
})),
|
|
2126
|
+
statesInstanceBySpec: new Map(),
|
|
2127
|
+
existingStates: new Map(),
|
|
2128
|
+
unsubscriptionsByState: {},
|
|
2129
|
+
props: undefined,
|
|
2130
|
+
registrationsQueue: []
|
|
2131
|
+
});
|
|
2132
|
+
$$state.props = mkUntrackedValue(props);
|
|
2133
|
+
var $state = create$StateProxy($$state, function (path, spec) {
|
|
2134
|
+
return {
|
|
2135
|
+
get: function get() {
|
|
2136
|
+
return _get($$state.stateValues, path);
|
|
2137
|
+
},
|
|
2138
|
+
set: function set$1(_t, _p, value) {
|
|
2139
|
+
set($$state.stateValues, path, mkUntrackedValue(value));
|
|
2243
2140
|
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
}), _extends2));
|
|
2141
|
+
if (spec.onChangeProp) {
|
|
2142
|
+
var _$$state$props$spec$o5, _$$state$props5;
|
|
2247
2143
|
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2144
|
+
(_$$state$props$spec$o5 = (_$$state$props5 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o5.call(_$$state$props5, value, path);
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
return true;
|
|
2148
|
+
}
|
|
2149
|
+
};
|
|
2150
|
+
});
|
|
2151
|
+
|
|
2152
|
+
for (var _iterator = _createForOfIteratorHelperLoose(specs), _step; !(_step = _iterator()).done;) {
|
|
2153
|
+
var spec = _step.value;
|
|
2154
|
+
var path = transformPathStringToObj(spec.path);
|
|
2155
|
+
var init = spec.valueProp ? $$state.props[spec.valueProp] : spec.initVal ? spec.initVal : spec.initFunc ? initializeStateValue($$state, path, $$state.specsByKey[spec.path]) : undefined;
|
|
2156
|
+
|
|
2157
|
+
set($state, path, init);
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
return $state;
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
// Utilities used by generated code
|
|
2164
|
+
var classNames = classNames$1;
|
|
2165
|
+
|
|
2166
|
+
var PLUME_STRICT_MODE = true;
|
|
2167
|
+
function setPlumeStrictMode(mode) {
|
|
2168
|
+
PLUME_STRICT_MODE = mode;
|
|
2169
|
+
}
|
|
2170
|
+
function mergeVariantToggles() {
|
|
2171
|
+
for (var _len = arguments.length, toggles = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2172
|
+
toggles[_key] = arguments[_key];
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
var definedToggles = toggles.filter(function (x) {
|
|
2176
|
+
return !!x.def;
|
|
2177
|
+
});
|
|
2178
|
+
var grouped = groupBy(definedToggles, function (_ref) {
|
|
2179
|
+
var def = _ref.def;
|
|
2180
|
+
return def.group;
|
|
2181
|
+
});
|
|
2182
|
+
return mapValues(grouped, function (subToggles) {
|
|
2183
|
+
return Object.fromEntries(subToggles.map(function (_ref2) {
|
|
2184
|
+
var def = _ref2.def,
|
|
2185
|
+
active = _ref2.active;
|
|
2186
|
+
return [def.variant, !!active];
|
|
2187
|
+
}));
|
|
2188
|
+
});
|
|
2189
|
+
}
|
|
2190
|
+
function noOutline() {
|
|
2265
2191
|
return {
|
|
2266
|
-
|
|
2267
|
-
variants: variants,
|
|
2268
|
-
args: args,
|
|
2269
|
-
overrides: overrides
|
|
2270
|
-
}
|
|
2192
|
+
outline: "none"
|
|
2271
2193
|
};
|
|
2272
2194
|
}
|
|
2195
|
+
function getPlumeType(child) {
|
|
2196
|
+
if (!React.isValidElement(child)) {
|
|
2197
|
+
return undefined;
|
|
2198
|
+
}
|
|
2273
2199
|
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
var menuContext = React.useContext(MenuContext);
|
|
2278
|
-
var triggerContext = React.useContext(TriggeredOverlayContext);
|
|
2200
|
+
var childType = child.type;
|
|
2201
|
+
return childType.__plumeType || (childType.getPlumeType == null ? void 0 : childType.getPlumeType(child.props));
|
|
2202
|
+
}
|
|
2279
2203
|
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
}
|
|
2204
|
+
var _excluded$4 = ["link", "isDisabled", "startIcon", "endIcon", "showStartIcon", "showEndIcon", "children"];
|
|
2205
|
+
function useButton(plasmicClass, props, config, ref) {
|
|
2206
|
+
var _ref, _ref2, _extends2, _overrides;
|
|
2284
2207
|
|
|
2285
|
-
|
|
2208
|
+
if (ref === void 0) {
|
|
2209
|
+
ref = null;
|
|
2286
2210
|
}
|
|
2287
2211
|
|
|
2288
|
-
var
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
var ref = React.useRef(null);
|
|
2212
|
+
var link = props.link,
|
|
2213
|
+
isDisabled = props.isDisabled,
|
|
2214
|
+
startIcon = props.startIcon,
|
|
2215
|
+
endIcon = props.endIcon,
|
|
2216
|
+
showStartIcon = props.showStartIcon,
|
|
2217
|
+
showEndIcon = props.showEndIcon,
|
|
2218
|
+
children = props.children,
|
|
2219
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded$4);
|
|
2297
2220
|
|
|
2298
|
-
var
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
onAction: onAction
|
|
2221
|
+
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
2222
|
+
def: config.showStartIconVariant,
|
|
2223
|
+
active: showStartIcon
|
|
2302
2224
|
}, {
|
|
2303
|
-
|
|
2304
|
-
|
|
2225
|
+
def: config.showEndIconVariant,
|
|
2226
|
+
active: showEndIcon
|
|
2305
2227
|
}, {
|
|
2306
|
-
isDisabled: isDisabled,
|
|
2307
|
-
"aria-label": node && node["aria-label"],
|
|
2308
|
-
key: node.key,
|
|
2309
|
-
isVirtualized: false,
|
|
2310
|
-
closeOnSelect: true
|
|
2311
|
-
}), state, ref),
|
|
2312
|
-
menuItemProps = _useAriaMenuItem.menuItemProps,
|
|
2313
|
-
labelProps = _useAriaMenuItem.labelProps;
|
|
2314
|
-
|
|
2315
|
-
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
2316
2228
|
def: config.isDisabledVariant,
|
|
2317
2229
|
active: isDisabled
|
|
2318
|
-
}, {
|
|
2319
|
-
def: config.isHighlightedVariant,
|
|
2320
|
-
active: isHighlighted
|
|
2321
2230
|
}));
|
|
2322
2231
|
|
|
2323
|
-
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.
|
|
2232
|
+
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), config.startIconSlot && (_ref = {}, _ref[config.startIconSlot] = startIcon, _ref), config.endIconSlot && (_ref2 = {}, _ref2[config.endIconSlot] = endIcon, _ref2), (_extends2 = {}, _extends2[config.contentSlot] = children, _extends2));
|
|
2324
2233
|
|
|
2325
2234
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
2326
|
-
as: "
|
|
2327
|
-
props:
|
|
2235
|
+
as: !!link ? "a" : "button",
|
|
2236
|
+
props: _extends({}, omit.apply(void 0, [rest].concat(plasmicClass.internalArgProps, plasmicClass.internalVariantProps)), {
|
|
2328
2237
|
ref: ref,
|
|
2329
|
-
|
|
2238
|
+
disabled: isDisabled
|
|
2239
|
+
}, !!link && {
|
|
2240
|
+
href: link
|
|
2330
2241
|
})
|
|
2331
|
-
}, _overrides[config.labelContainer] = {
|
|
2332
|
-
props: _extends({}, labelProps)
|
|
2333
2242
|
}, _overrides);
|
|
2334
2243
|
return {
|
|
2335
2244
|
plasmicProps: {
|
|
@@ -2340,294 +2249,356 @@ function useMenuItem(plasmicClass, props, config) {
|
|
|
2340
2249
|
};
|
|
2341
2250
|
}
|
|
2342
2251
|
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2252
|
+
function getStyleProps(props) {
|
|
2253
|
+
return pick(props, "className", "style");
|
|
2254
|
+
}
|
|
2255
|
+
function getDefaultPlasmicProps(plasmicClass, props) {
|
|
2256
|
+
return {
|
|
2257
|
+
plasmicProps: {
|
|
2258
|
+
variants: pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)),
|
|
2259
|
+
args: pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)),
|
|
2260
|
+
overrides: {}
|
|
2261
|
+
}
|
|
2262
|
+
};
|
|
2263
|
+
}
|
|
2264
|
+
var RE_DATA_PROP = /^(data-.*)$/;
|
|
2265
|
+
function getDataProps(props) {
|
|
2266
|
+
return pickBy(props, function (k) {
|
|
2267
|
+
return RE_DATA_PROP.test(k);
|
|
2268
|
+
});
|
|
2269
|
+
}
|
|
2355
2270
|
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
menuProps = _useAriaMenuTrigger.menuProps;
|
|
2271
|
+
function asAriaCheckboxProps(props) {
|
|
2272
|
+
var ariaProps = _extends({}, props, {
|
|
2273
|
+
isSelected: props.isChecked,
|
|
2274
|
+
defaultSelected: props.defaultChecked
|
|
2275
|
+
});
|
|
2362
2276
|
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
triggerProps = _usePress.pressProps;
|
|
2367
|
-
|
|
2368
|
-
var makeMenu = function makeMenu() {
|
|
2369
|
-
var realMenu = typeof menu$1 === "function" ? menu$1() : menu$1;
|
|
2370
|
-
|
|
2371
|
-
if (!realMenu) {
|
|
2372
|
-
return null;
|
|
2373
|
-
}
|
|
2374
|
-
|
|
2375
|
-
if (getPlumeType(realMenu) !== "menu") {
|
|
2376
|
-
if (PLUME_STRICT_MODE) {
|
|
2377
|
-
throw new Error("Must use an instance of the Menu component.");
|
|
2378
|
-
}
|
|
2379
|
-
|
|
2380
|
-
return null;
|
|
2381
|
-
}
|
|
2382
|
-
|
|
2383
|
-
return React.cloneElement(realMenu, mergeProps(realMenu.props, menuProps));
|
|
2384
|
-
};
|
|
2385
|
-
|
|
2386
|
-
var triggerContext = React.useMemo(function () {
|
|
2387
|
-
var _state$focusStrategy;
|
|
2388
|
-
|
|
2389
|
-
return {
|
|
2390
|
-
triggerRef: triggerRef,
|
|
2391
|
-
state: state,
|
|
2392
|
-
autoFocus: (_state$focusStrategy = state.focusStrategy) != null ? _state$focusStrategy : true,
|
|
2393
|
-
placement: placement,
|
|
2394
|
-
overlayMatchTriggerWidth: menuMatchTriggerWidth,
|
|
2395
|
-
overlayMinTriggerWidth: true,
|
|
2396
|
-
overlayWidth: menuWidth
|
|
2397
|
-
};
|
|
2398
|
-
}, [triggerRef, state, placement, menuMatchTriggerWidth, menuWidth]);
|
|
2399
|
-
return {
|
|
2400
|
-
triggerProps: triggerProps,
|
|
2401
|
-
makeMenu: makeMenu,
|
|
2402
|
-
triggerContext: triggerContext
|
|
2403
|
-
};
|
|
2404
|
-
}
|
|
2405
|
-
|
|
2406
|
-
function DropdownMenu(props) {
|
|
2407
|
-
var isOpen = props.isOpen,
|
|
2408
|
-
defaultOpen = props.defaultOpen,
|
|
2409
|
-
onOpenChange = props.onOpenChange,
|
|
2410
|
-
children = props.children,
|
|
2411
|
-
placement = props.placement,
|
|
2412
|
-
menu = props.menu;
|
|
2413
|
-
var triggerRef = React.useRef(null);
|
|
2414
|
-
var state = menu$1.useMenuTriggerState({
|
|
2415
|
-
isOpen: isOpen,
|
|
2416
|
-
defaultOpen: defaultOpen,
|
|
2417
|
-
onOpenChange: onOpenChange,
|
|
2418
|
-
shouldFlip: true
|
|
2419
|
-
});
|
|
2420
|
-
|
|
2421
|
-
var _useMenuTrigger = useMenuTrigger({
|
|
2422
|
-
triggerRef: triggerRef,
|
|
2423
|
-
placement: placement,
|
|
2424
|
-
menu: menu
|
|
2425
|
-
}, state),
|
|
2426
|
-
triggerProps = _useMenuTrigger.triggerProps,
|
|
2427
|
-
makeMenu = _useMenuTrigger.makeMenu,
|
|
2428
|
-
triggerContext = _useMenuTrigger.triggerContext;
|
|
2429
|
-
|
|
2430
|
-
return React.createElement(TriggeredOverlayContext.Provider, {
|
|
2431
|
-
value: triggerContext
|
|
2432
|
-
}, React.cloneElement(children, mergeProps(children.props, triggerProps, {
|
|
2433
|
-
ref: triggerRef
|
|
2434
|
-
})), state.isOpen && makeMenu());
|
|
2277
|
+
delete ariaProps["isChecked"];
|
|
2278
|
+
delete ariaProps["defaultChecked"];
|
|
2279
|
+
return ariaProps;
|
|
2435
2280
|
}
|
|
2436
2281
|
|
|
2437
|
-
function
|
|
2438
|
-
var
|
|
2282
|
+
function useCheckbox(plasmicClass, props, config, ref) {
|
|
2283
|
+
var _overrides, _ref;
|
|
2439
2284
|
|
|
2440
|
-
if (
|
|
2441
|
-
|
|
2285
|
+
if (ref === void 0) {
|
|
2286
|
+
ref = null;
|
|
2442
2287
|
}
|
|
2443
2288
|
|
|
2444
|
-
var
|
|
2445
|
-
isOpen = props.isOpen,
|
|
2446
|
-
defaultOpen = props.defaultOpen,
|
|
2447
|
-
onOpenChange = props.onOpenChange,
|
|
2289
|
+
var children = props.children,
|
|
2448
2290
|
isDisabled = props.isDisabled,
|
|
2449
|
-
|
|
2450
|
-
autoFocus = props.autoFocus,
|
|
2451
|
-
menuMatchTriggerWidth = props.menuMatchTriggerWidth,
|
|
2452
|
-
menuWidth = props.menuWidth;
|
|
2291
|
+
isIndeterminate = props.isIndeterminate;
|
|
2453
2292
|
useEnsureSSRProvider();
|
|
2293
|
+
var inputRef = React.useRef(null);
|
|
2454
2294
|
var rootRef = React.useRef(null);
|
|
2455
|
-
var
|
|
2456
|
-
var state =
|
|
2457
|
-
isOpen: isOpen,
|
|
2458
|
-
defaultOpen: defaultOpen,
|
|
2459
|
-
onOpenChange: onOpenChange,
|
|
2460
|
-
shouldFlip: true
|
|
2461
|
-
});
|
|
2462
|
-
|
|
2463
|
-
var _useMenuTrigger = useMenuTrigger({
|
|
2464
|
-
isDisabled: isDisabled,
|
|
2465
|
-
triggerRef: triggerRef,
|
|
2466
|
-
placement: placement,
|
|
2467
|
-
menuMatchTriggerWidth: menuMatchTriggerWidth,
|
|
2468
|
-
menuWidth: menuWidth,
|
|
2469
|
-
menu: menu
|
|
2470
|
-
}, state),
|
|
2471
|
-
triggerProps = _useMenuTrigger.triggerProps,
|
|
2472
|
-
makeMenu = _useMenuTrigger.makeMenu,
|
|
2473
|
-
triggerContext = _useMenuTrigger.triggerContext;
|
|
2295
|
+
var ariaProps = asAriaCheckboxProps(props);
|
|
2296
|
+
var state = toggle.useToggleState(ariaProps);
|
|
2474
2297
|
|
|
2475
|
-
var
|
|
2476
|
-
|
|
2298
|
+
var _useAriaCheckbox = checkbox.useCheckbox(ariaProps, state, inputRef),
|
|
2299
|
+
inputProps = _useAriaCheckbox.inputProps;
|
|
2477
2300
|
|
|
2478
2301
|
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
2479
|
-
def: config.isOpenVariant,
|
|
2480
|
-
active: state.isOpen
|
|
2481
|
-
}, {
|
|
2482
2302
|
def: config.isDisabledVariant,
|
|
2483
2303
|
active: isDisabled
|
|
2304
|
+
}, {
|
|
2305
|
+
def: config.isCheckedVariant,
|
|
2306
|
+
active: state.isSelected
|
|
2307
|
+
}, {
|
|
2308
|
+
def: config.isIndeterminateVariant,
|
|
2309
|
+
active: isIndeterminate
|
|
2310
|
+
}, {
|
|
2311
|
+
def: config.noLabelVariant,
|
|
2312
|
+
active: !children
|
|
2484
2313
|
}));
|
|
2485
2314
|
|
|
2486
|
-
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.menuSlot] = state.isOpen ? makeMenu() : undefined, _extends2));
|
|
2487
|
-
|
|
2488
2315
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
value: triggerContext
|
|
2492
|
-
}, children);
|
|
2493
|
-
},
|
|
2494
|
-
props: {
|
|
2316
|
+
as: "label",
|
|
2317
|
+
props: mergeProps(getStyleProps(props), {
|
|
2495
2318
|
ref: rootRef
|
|
2319
|
+
}),
|
|
2320
|
+
wrapChildren: function wrapChildren(children) {
|
|
2321
|
+
return React.createElement(React.Fragment, null, React.createElement(visuallyHidden.VisuallyHidden, {
|
|
2322
|
+
isFocusable: true
|
|
2323
|
+
}, React.createElement("input", Object.assign({}, inputProps, {
|
|
2324
|
+
ref: inputRef
|
|
2325
|
+
}))), children);
|
|
2496
2326
|
}
|
|
2497
|
-
}, _overrides[config.trigger] = {
|
|
2498
|
-
props: mergeProps(triggerProps, triggerFocusProps, getStyleProps(props), pick(props, "title"), {
|
|
2499
|
-
ref: triggerRef,
|
|
2500
|
-
autoFocus: autoFocus,
|
|
2501
|
-
disabled: !!isDisabled,
|
|
2502
|
-
// Make sure this button is not interpreted as submit
|
|
2503
|
-
type: "button"
|
|
2504
|
-
})
|
|
2505
2327
|
}, _overrides);
|
|
2328
|
+
|
|
2329
|
+
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), config.labelSlot ? (_ref = {}, _ref[config.labelSlot] = children, _ref) : {});
|
|
2330
|
+
|
|
2506
2331
|
var plumeState = React.useMemo(function () {
|
|
2507
2332
|
return {
|
|
2508
|
-
|
|
2509
|
-
return state.
|
|
2510
|
-
},
|
|
2511
|
-
close: function close() {
|
|
2512
|
-
return state.close();
|
|
2513
|
-
},
|
|
2514
|
-
isOpen: function isOpen() {
|
|
2515
|
-
return state.isOpen;
|
|
2333
|
+
setChecked: function setChecked(checked) {
|
|
2334
|
+
return state.setSelected(checked);
|
|
2516
2335
|
}
|
|
2517
2336
|
};
|
|
2518
2337
|
}, [state]);
|
|
2519
|
-
React.useImperativeHandle(
|
|
2338
|
+
React.useImperativeHandle(ref, function () {
|
|
2520
2339
|
return {
|
|
2521
2340
|
getRoot: function getRoot() {
|
|
2522
2341
|
return rootRef.current;
|
|
2523
2342
|
},
|
|
2524
|
-
getTrigger: function getTrigger() {
|
|
2525
|
-
return triggerRef.current;
|
|
2526
|
-
},
|
|
2527
2343
|
focus: function focus() {
|
|
2528
|
-
|
|
2344
|
+
var _inputRef$current;
|
|
2345
|
+
|
|
2346
|
+
return (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
|
|
2529
2347
|
},
|
|
2530
2348
|
blur: function blur() {
|
|
2531
|
-
|
|
2349
|
+
var _inputRef$current2;
|
|
2350
|
+
|
|
2351
|
+
return (_inputRef$current2 = inputRef.current) == null ? void 0 : _inputRef$current2.blur();
|
|
2532
2352
|
},
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2353
|
+
setChecked: function setChecked(checked) {
|
|
2354
|
+
return plumeState.setChecked(checked);
|
|
2355
|
+
}
|
|
2536
2356
|
};
|
|
2537
|
-
}, [rootRef,
|
|
2357
|
+
}, [rootRef, inputRef, plumeState]);
|
|
2538
2358
|
return {
|
|
2539
2359
|
plasmicProps: {
|
|
2540
2360
|
variants: variants,
|
|
2541
|
-
|
|
2542
|
-
|
|
2361
|
+
overrides: overrides,
|
|
2362
|
+
args: args
|
|
2543
2363
|
},
|
|
2544
2364
|
state: plumeState
|
|
2545
2365
|
};
|
|
2546
2366
|
}
|
|
2547
2367
|
|
|
2548
|
-
var SelectContext = /*#__PURE__*/React.createContext(undefined);
|
|
2549
|
-
|
|
2550
|
-
var _excluded$6 = ["value", "defaultValue", "children", "onChange", "placement", "menuMatchTriggerWidth", "menuWidth"];
|
|
2551
|
-
var COLLECTION_OPTS$1 = {
|
|
2552
|
-
itemPlumeType: "select-option",
|
|
2553
|
-
sectionPlumeType: "select-option-group"
|
|
2554
|
-
};
|
|
2555
2368
|
/**
|
|
2556
|
-
*
|
|
2557
|
-
*
|
|
2558
|
-
*
|
|
2559
|
-
* Because we're not exposing the Collections API (see ./index.tsx),
|
|
2560
|
-
* we are converting our own API into props for useSelect.
|
|
2561
|
-
*
|
|
2562
|
-
* Specifically, in Plume's API,
|
|
2563
|
-
* - `children` flattens to a list of ReactElements of type Select.Option
|
|
2564
|
-
* or Select.OptionGroup
|
|
2565
|
-
*
|
|
2566
|
-
* and we map it this way to the Collections API:
|
|
2567
|
-
* - `items` is a list of those flattened ReactElements from `children`!
|
|
2568
|
-
* - `children`, as a render prop, is supposed to take one of the `items`
|
|
2569
|
-
* and return a `Section` or `Item` element. We take an Option/OptionGroup
|
|
2570
|
-
* element, and use its props to render the appropriate `Section` or
|
|
2571
|
-
* `Item`. The "trick" here is that we then stuff the Option element as
|
|
2572
|
-
* `Item.children`, and the OptionGroup element as `Section.title`.
|
|
2573
|
-
*
|
|
2574
|
-
* When the Collections API does its work deriving `Node`s, the corresponding
|
|
2575
|
-
* Option/OptionGroup ReactElements will end up as `Node.rendered`.
|
|
2576
|
-
*
|
|
2577
|
-
* Then, when we are actually rendering the content of the dropdown, we
|
|
2578
|
-
* iterate through each collected `Node`, and renders
|
|
2579
|
-
* React.cloneElement(Node.rendered, {_node: node}). This "secretly" passes
|
|
2580
|
-
* the derived collection `Node` as a prop to Option and OptionGroup, and they
|
|
2581
|
-
* can make use of the derived `Node.key` etc in their rendering functions.
|
|
2369
|
+
* Given children of a component like Select or Menu, derive the items
|
|
2370
|
+
* that we will pass into the Collections API. These will be
|
|
2371
|
+
* ReactElement<ItemLikeProps|SectionLikeProps>[].
|
|
2582
2372
|
*
|
|
2583
|
-
*
|
|
2584
|
-
*
|
|
2585
|
-
* props used on those elements, and passed those onto the Collections API.
|
|
2586
|
-
* What gets rendered to the screen is the cloned version of these elements
|
|
2587
|
-
* with the secret derived `_node` prop. That means Option and OptionGroup
|
|
2588
|
-
* render functions can assume that _node is passed in.
|
|
2373
|
+
* Will also assign keys to items by their index in the collection,
|
|
2374
|
+
* and collect the keys of disabled items.
|
|
2589
2375
|
*/
|
|
2590
2376
|
|
|
2591
|
-
function
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2377
|
+
function deriveItemsFromChildren(children, opts) {
|
|
2378
|
+
if (!children) {
|
|
2379
|
+
return {
|
|
2380
|
+
items: [],
|
|
2381
|
+
disabledKeys: []
|
|
2382
|
+
};
|
|
2383
|
+
}
|
|
2597
2384
|
|
|
2598
|
-
var
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2385
|
+
var itemPlumeType = opts.itemPlumeType,
|
|
2386
|
+
sectionPlumeType = opts.sectionPlumeType,
|
|
2387
|
+
invalidChildError = opts.invalidChildError; // For Plume items without an explicit key, we assign a key as the index
|
|
2388
|
+
// of the collection.
|
|
2389
|
+
|
|
2390
|
+
var itemCount = 0;
|
|
2391
|
+
var sectionCount = 0;
|
|
2392
|
+
|
|
2393
|
+
var ensureValue = function ensureValue(element) {
|
|
2394
|
+
if (!propInChild(element, "value")) {
|
|
2395
|
+
if (opts.requireItemValue && PLUME_STRICT_MODE) {
|
|
2396
|
+
throw new Error("Must specify a \"value\" prop for " + getElementTypeName(element));
|
|
2397
|
+
} else {
|
|
2398
|
+
return cloneChild(element, {
|
|
2399
|
+
value: "" + itemCount++
|
|
2400
|
+
});
|
|
2401
|
+
}
|
|
2402
|
+
} else {
|
|
2403
|
+
// Still increment count even if key is present, so that the
|
|
2404
|
+
// auto-assigned key really reflects the index
|
|
2405
|
+
itemCount++;
|
|
2406
|
+
return element;
|
|
2407
|
+
}
|
|
2408
|
+
};
|
|
2409
|
+
|
|
2410
|
+
var disabledKeys = [];
|
|
2411
|
+
|
|
2412
|
+
var flattenedChildren = function flattenedChildren(children) {
|
|
2413
|
+
return toChildArray(children).flatMap(function (child) {
|
|
2414
|
+
if (React__default.isValidElement(child)) {
|
|
2415
|
+
if (child.type === React__default.Fragment) {
|
|
2416
|
+
return flattenedChildren(child.props.children);
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
var type = getPlumeType(child);
|
|
2420
|
+
|
|
2421
|
+
if (type === itemPlumeType) {
|
|
2422
|
+
child = ensureValue(child);
|
|
2423
|
+
var childKey = getItemLikeKey(child);
|
|
2424
|
+
|
|
2425
|
+
if (getChildProp(child, "isDisabled") && !!childKey) {
|
|
2426
|
+
disabledKeys.push(childKey);
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
return [child];
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2432
|
+
if (type === sectionPlumeType) {
|
|
2433
|
+
var _child$key;
|
|
2434
|
+
|
|
2435
|
+
return [cloneChild(child, {
|
|
2436
|
+
// key of section doesn't actually matter, just needs
|
|
2437
|
+
// to be unique
|
|
2438
|
+
key: (_child$key = child.key) != null ? _child$key : "section-" + sectionCount++,
|
|
2439
|
+
children: flattenedChildren(getChildProp(child, "children"))
|
|
2440
|
+
})];
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
if (PLUME_STRICT_MODE) {
|
|
2445
|
+
throw new Error(invalidChildError != null ? invalidChildError : "Unexpected child");
|
|
2446
|
+
} else {
|
|
2447
|
+
return [];
|
|
2448
|
+
}
|
|
2449
|
+
});
|
|
2450
|
+
};
|
|
2451
|
+
|
|
2452
|
+
return {
|
|
2453
|
+
items: flattenedChildren(children),
|
|
2454
|
+
disabledKeys: disabledKeys
|
|
2455
|
+
};
|
|
2456
|
+
}
|
|
2457
|
+
function useDerivedItemsFromChildren(children, opts) {
|
|
2458
|
+
var itemPlumeType = opts.itemPlumeType,
|
|
2459
|
+
sectionPlumeType = opts.sectionPlumeType,
|
|
2460
|
+
invalidChildError = opts.invalidChildError,
|
|
2461
|
+
requireItemValue = opts.requireItemValue;
|
|
2462
|
+
return React__default.useMemo(function () {
|
|
2463
|
+
return deriveItemsFromChildren(children, {
|
|
2464
|
+
itemPlumeType: itemPlumeType,
|
|
2465
|
+
sectionPlumeType: sectionPlumeType,
|
|
2466
|
+
invalidChildError: invalidChildError,
|
|
2467
|
+
requireItemValue: requireItemValue
|
|
2468
|
+
});
|
|
2469
|
+
}, [children, itemPlumeType, sectionPlumeType, invalidChildError, requireItemValue]);
|
|
2470
|
+
}
|
|
2471
|
+
/**
|
|
2472
|
+
* Given a Collection node, create the React element that we should use
|
|
2473
|
+
* to render it.
|
|
2474
|
+
*/
|
|
2475
|
+
|
|
2476
|
+
function renderCollectionNode(node) {
|
|
2477
|
+
// node.rendered should already have our item-like or section-like Plume
|
|
2478
|
+
// component elements, so we just need to clone them with a secret
|
|
2479
|
+
// _node prop that we use to render.
|
|
2480
|
+
return cloneChild(node.rendered, {
|
|
2481
|
+
_node: node,
|
|
2482
|
+
key: node.key
|
|
2483
|
+
});
|
|
2484
|
+
}
|
|
2485
|
+
/**
|
|
2486
|
+
* Renders a item-like or section-like Plume component element into an
|
|
2487
|
+
* Item or a Section element.
|
|
2488
|
+
*/
|
|
2489
|
+
|
|
2490
|
+
function renderAsCollectionChild(child, opts) {
|
|
2491
|
+
var plumeType = getPlumeType(child);
|
|
2492
|
+
|
|
2493
|
+
if (plumeType === opts.itemPlumeType) {
|
|
2494
|
+
var _getChildProp;
|
|
2495
|
+
|
|
2496
|
+
var option = child; // We look at the children passed to the item-like element, and derive key
|
|
2497
|
+
// or textValue from it if it is a string
|
|
2498
|
+
|
|
2499
|
+
var content = getChildProp(option, "children"); // The children render prop needs to return an <Item/>
|
|
2500
|
+
|
|
2501
|
+
return React__default.createElement(collections.Item // We use ItemLike.value if the user explicitly specified a value,
|
|
2502
|
+
// and we fallback to key. If the user specified neither, then
|
|
2503
|
+
// the Collections API will generate a unique key for this item.
|
|
2504
|
+
, {
|
|
2505
|
+
// We use ItemLike.value if the user explicitly specified a value,
|
|
2506
|
+
// and we fallback to key. If the user specified neither, then
|
|
2507
|
+
// the Collections API will generate a unique key for this item.
|
|
2508
|
+
key: getItemLikeKey(option),
|
|
2509
|
+
// textValue is either explicitly specified by the user, or we
|
|
2510
|
+
// try to derive it if `content` is a string.
|
|
2511
|
+
textValue: (_getChildProp = getChildProp(option, "textValue")) != null ? _getChildProp : isString(content) ? content : propInChild(option, "value") ? getChildProp(option, "value") : option.key,
|
|
2512
|
+
"aria-label": getChildProp(option, "aria-label")
|
|
2513
|
+
}, option);
|
|
2514
|
+
} else {
|
|
2515
|
+
var group = child;
|
|
2516
|
+
return React__default.createElement(collections.Section // Note that we are using the whole section-like element as the title
|
|
2517
|
+
// here, and not group.props.title; we want the entire section-like
|
|
2518
|
+
// Plume element to end up as Node.rendered.
|
|
2519
|
+
, {
|
|
2520
|
+
// Note that we are using the whole section-like element as the title
|
|
2521
|
+
// here, and not group.props.title; we want the entire section-like
|
|
2522
|
+
// Plume element to end up as Node.rendered.
|
|
2523
|
+
title: group,
|
|
2524
|
+
"aria-label": getChildProp(group, "aria-label"),
|
|
2525
|
+
// We are flattening and deriving the descendant Options as items here.
|
|
2526
|
+
// group.props.children should've already been cleaned up by
|
|
2527
|
+
// deriveItemsFromChildren()
|
|
2528
|
+
items: getChildProp(group, "children")
|
|
2529
|
+
}, function (c) {
|
|
2530
|
+
return renderAsCollectionChild(c, opts);
|
|
2531
|
+
});
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
function getItemLikeKey(element) {
|
|
2536
|
+
var _getChildProp2;
|
|
2537
|
+
|
|
2538
|
+
return (_getChildProp2 = getChildProp(element, "value")) != null ? _getChildProp2 : element.key;
|
|
2539
|
+
} // PlasmicLoader-aware function to get prop from child.
|
|
2540
|
+
|
|
2541
|
+
|
|
2542
|
+
function getChildProp(child, prop) {
|
|
2543
|
+
return "componentProps" in child.props ? child.props.componentProps[prop] : child.props[prop];
|
|
2544
|
+
} // PlasmicLoader-aware function to check `if (prop in element.props)`.
|
|
2545
|
+
|
|
2546
|
+
function propInChild(child, prop) {
|
|
2547
|
+
return "componentProps" in child.props ? prop in child.props.componentProps : prop in child.props;
|
|
2548
|
+
} // PlasmicLoader-aware function to clone React element.
|
|
2549
|
+
|
|
2550
|
+
|
|
2551
|
+
function cloneChild(child, props) {
|
|
2552
|
+
if (child.type.getPlumeType) {
|
|
2553
|
+
// If React element has getPlumeType(), assume that it is PlasmicLoader,
|
|
2554
|
+
// so add nodeProps to componentProps instead of element props.
|
|
2555
|
+
return React__default.cloneElement(child, _extends({
|
|
2556
|
+
componentProps: _extends({}, child.props.componentProps, props)
|
|
2557
|
+
}, props.key ? {
|
|
2558
|
+
key: props.key
|
|
2559
|
+
} : {}));
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
return React__default.cloneElement(child, props);
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
var TriggeredOverlayContext = /*#__PURE__*/React.createContext(undefined);
|
|
2566
|
+
|
|
2567
|
+
var MenuContext = /*#__PURE__*/React.createContext(undefined);
|
|
2568
|
+
|
|
2569
|
+
var _excluded$5 = ["children"];
|
|
2570
|
+
var COLLECTION_OPTS = {
|
|
2571
|
+
itemPlumeType: "menu-item",
|
|
2572
|
+
sectionPlumeType: "menu-group"
|
|
2573
|
+
};
|
|
2574
|
+
/**
|
|
2575
|
+
* Converts props from BaseMenuProps to react-aria's useMenu() props.
|
|
2576
|
+
*/
|
|
2577
|
+
|
|
2578
|
+
function asAriaMenuProps(props) {
|
|
2579
|
+
var children = props.children,
|
|
2580
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded$5);
|
|
2581
|
+
|
|
2582
|
+
var _useDerivedItemsFromC = useDerivedItemsFromChildren(children, _extends({}, COLLECTION_OPTS, {
|
|
2583
|
+
invalidChildError: "Can only use Menu.Item and Menu.Group as children to Menu",
|
|
2584
|
+
requireItemValue: false
|
|
2585
|
+
})),
|
|
2586
|
+
items = _useDerivedItemsFromC.items,
|
|
2603
2587
|
disabledKeys = _useDerivedItemsFromC.disabledKeys;
|
|
2604
2588
|
|
|
2605
2589
|
var collectionChildRenderer = React.useCallback(function (child) {
|
|
2606
|
-
return renderAsCollectionChild(child, COLLECTION_OPTS
|
|
2590
|
+
return renderAsCollectionChild(child, COLLECTION_OPTS);
|
|
2607
2591
|
}, []);
|
|
2608
|
-
var onSelectionChange = React.useMemo(function () {
|
|
2609
|
-
if (onChange) {
|
|
2610
|
-
return function (val) {
|
|
2611
|
-
return onChange(val == null || val === "null" ? null : val);
|
|
2612
|
-
};
|
|
2613
|
-
} else {
|
|
2614
|
-
return undefined;
|
|
2615
|
-
}
|
|
2616
|
-
}, [onChange]);
|
|
2617
2592
|
return {
|
|
2618
2593
|
ariaProps: _extends({}, rest, {
|
|
2619
2594
|
children: collectionChildRenderer,
|
|
2620
|
-
onSelectionChange: onSelectionChange,
|
|
2621
2595
|
items: items,
|
|
2622
|
-
disabledKeys: disabledKeys
|
|
2623
|
-
defaultSelectedKey: defaultValue
|
|
2624
|
-
}, "value" in props && {
|
|
2625
|
-
selectedKey: value != null ? value : null
|
|
2596
|
+
disabledKeys: disabledKeys
|
|
2626
2597
|
})
|
|
2627
2598
|
};
|
|
2628
2599
|
}
|
|
2629
2600
|
|
|
2630
|
-
function
|
|
2601
|
+
function useMenu(plasmicClass, props, config, ref) {
|
|
2631
2602
|
var _overrides, _extends2;
|
|
2632
2603
|
|
|
2633
2604
|
if (ref === void 0) {
|
|
@@ -2636,110 +2607,53 @@ function useSelect(plasmicClass, props, config, ref) {
|
|
|
2636
2607
|
|
|
2637
2608
|
useEnsureSSRProvider();
|
|
2638
2609
|
|
|
2639
|
-
var
|
|
2640
|
-
ariaProps =
|
|
2610
|
+
var _asAriaMenuProps = asAriaMenuProps(props),
|
|
2611
|
+
ariaProps = _asAriaMenuProps.ariaProps;
|
|
2641
2612
|
|
|
2642
|
-
var
|
|
2643
|
-
var state = select$1.useSelectState(ariaProps);
|
|
2644
|
-
var triggerRef = React.useRef(null);
|
|
2613
|
+
var triggerContext = React.useContext(TriggeredOverlayContext);
|
|
2645
2614
|
var rootRef = React.useRef(null);
|
|
2646
|
-
var
|
|
2647
|
-
|
|
2648
|
-
menuWidth = props.menuWidth,
|
|
2649
|
-
menuMatchTriggerWidth = props.menuMatchTriggerWidth,
|
|
2650
|
-
autoFocus = props.autoFocus,
|
|
2651
|
-
placeholder = props.placeholder,
|
|
2652
|
-
selectedContent = props.selectedContent;
|
|
2615
|
+
var state = tree.useTreeState(ariaProps);
|
|
2616
|
+
var menuListRef = React.useRef(null);
|
|
2653
2617
|
|
|
2654
|
-
var
|
|
2655
|
-
|
|
2656
|
-
|
|
2618
|
+
var _useAriaMenu = menu.useMenu(_extends({}, ariaProps, {
|
|
2619
|
+
autoFocus: triggerContext == null ? void 0 : triggerContext.autoFocus
|
|
2620
|
+
}), state, menuListRef),
|
|
2621
|
+
menuProps = _useAriaMenu.menuProps;
|
|
2657
2622
|
|
|
2658
|
-
var
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2623
|
+
var contextValue = React.useMemo(function () {
|
|
2624
|
+
return {
|
|
2625
|
+
state: state,
|
|
2626
|
+
menuProps: props
|
|
2627
|
+
};
|
|
2628
|
+
}, [state, props]);
|
|
2662
2629
|
|
|
2663
|
-
var
|
|
2664
|
-
|
|
2665
|
-
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
2666
|
-
def: config.isOpenVariant,
|
|
2667
|
-
active: state.isOpen
|
|
2668
|
-
}, {
|
|
2669
|
-
def: config.placeholderVariant,
|
|
2670
|
-
active: !state.selectedItem
|
|
2671
|
-
}, {
|
|
2672
|
-
def: config.isDisabledVariant,
|
|
2673
|
-
active: isDisabled
|
|
2674
|
-
}));
|
|
2630
|
+
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)));
|
|
2675
2631
|
|
|
2676
|
-
var triggerContext = React.useMemo(function () {
|
|
2677
|
-
return {
|
|
2678
|
-
triggerRef: triggerRef,
|
|
2679
|
-
state: state,
|
|
2680
|
-
placement: placement,
|
|
2681
|
-
overlayMatchTriggerWidth: menuMatchTriggerWidth,
|
|
2682
|
-
overlayMinTriggerWidth: true,
|
|
2683
|
-
overlayWidth: menuWidth
|
|
2684
|
-
};
|
|
2685
|
-
}, [triggerRef, state, placement, menuMatchTriggerWidth, menuWidth]);
|
|
2686
2632
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
2687
2633
|
props: mergeProps(getStyleProps(props), {
|
|
2688
2634
|
ref: rootRef
|
|
2689
|
-
}),
|
|
2690
|
-
wrapChildren: function wrapChildren(children) {
|
|
2691
|
-
return React.createElement(React.Fragment, null, React.createElement(select.HiddenSelect, {
|
|
2692
|
-
state: state,
|
|
2693
|
-
triggerRef: triggerRef,
|
|
2694
|
-
name: name,
|
|
2695
|
-
isDisabled: isDisabled
|
|
2696
|
-
}), children);
|
|
2697
|
-
}
|
|
2698
|
-
}, _overrides[config.trigger] = {
|
|
2699
|
-
props: mergeProps(triggerProps, {
|
|
2700
|
-
ref: triggerRef,
|
|
2701
|
-
autoFocus: autoFocus,
|
|
2702
|
-
disabled: !!isDisabled,
|
|
2703
|
-
// Don't trigger form submission!
|
|
2704
|
-
type: "button"
|
|
2705
2635
|
})
|
|
2706
|
-
}, _overrides[config.
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
},
|
|
2711
|
-
}
|
|
2712
|
-
}, _overrides[config.optionsContainer] = {
|
|
2713
|
-
wrap: function wrap(content) {
|
|
2714
|
-
return React.createElement(ListBoxWrapper, {
|
|
2715
|
-
state: state,
|
|
2716
|
-
menuProps: menuProps
|
|
2717
|
-
}, content);
|
|
2718
|
-
}
|
|
2636
|
+
}, _overrides[config.itemsContainer] = {
|
|
2637
|
+
as: "ul",
|
|
2638
|
+
props: mergeProps(menuProps, {
|
|
2639
|
+
ref: menuListRef,
|
|
2640
|
+
style: _extends({}, noOutline())
|
|
2641
|
+
})
|
|
2719
2642
|
}, _overrides);
|
|
2720
2643
|
|
|
2721
|
-
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.
|
|
2722
|
-
value:
|
|
2644
|
+
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.itemsSlot] = React.createElement(MenuContext.Provider, {
|
|
2645
|
+
value: contextValue
|
|
2723
2646
|
}, Array.from(state.collection).map(function (node) {
|
|
2724
2647
|
return renderCollectionNode(node);
|
|
2725
2648
|
})), _extends2));
|
|
2726
2649
|
|
|
2727
2650
|
var plumeState = React.useMemo(function () {
|
|
2728
2651
|
return {
|
|
2729
|
-
|
|
2730
|
-
return state.
|
|
2731
|
-
},
|
|
2732
|
-
close: function close() {
|
|
2733
|
-
return state.close();
|
|
2734
|
-
},
|
|
2735
|
-
isOpen: function isOpen() {
|
|
2736
|
-
return state.isOpen;
|
|
2737
|
-
},
|
|
2738
|
-
getSelectedValue: function getSelectedValue() {
|
|
2739
|
-
return state.selectedKey ? "" + state.selectedKey : null;
|
|
2652
|
+
getFocusedValue: function getFocusedValue() {
|
|
2653
|
+
return state.selectionManager.focusedKey;
|
|
2740
2654
|
},
|
|
2741
|
-
|
|
2742
|
-
return state.
|
|
2655
|
+
setFocusedValue: function setFocusedValue(value) {
|
|
2656
|
+
return state.selectionManager.setFocusedKey(value);
|
|
2743
2657
|
}
|
|
2744
2658
|
};
|
|
2745
2659
|
}, [state]);
|
|
@@ -2748,36 +2662,14 @@ function useSelect(plasmicClass, props, config, ref) {
|
|
|
2748
2662
|
getRoot: function getRoot() {
|
|
2749
2663
|
return rootRef.current;
|
|
2750
2664
|
},
|
|
2751
|
-
|
|
2752
|
-
return
|
|
2753
|
-
},
|
|
2754
|
-
focus: function focus() {
|
|
2755
|
-
var _triggerRef$current;
|
|
2756
|
-
|
|
2757
|
-
return (_triggerRef$current = triggerRef.current) == null ? void 0 : _triggerRef$current.focus();
|
|
2758
|
-
},
|
|
2759
|
-
blur: function blur() {
|
|
2760
|
-
var _triggerRef$current2;
|
|
2761
|
-
|
|
2762
|
-
return (_triggerRef$current2 = triggerRef.current) == null ? void 0 : _triggerRef$current2.blur();
|
|
2763
|
-
},
|
|
2764
|
-
open: function open() {
|
|
2765
|
-
return plumeState.open();
|
|
2766
|
-
},
|
|
2767
|
-
close: function close() {
|
|
2768
|
-
return plumeState.close();
|
|
2769
|
-
},
|
|
2770
|
-
isOpen: function isOpen() {
|
|
2771
|
-
return plumeState.isOpen();
|
|
2772
|
-
},
|
|
2773
|
-
getSelectedValue: function getSelectedValue() {
|
|
2774
|
-
return plumeState.getSelectedValue();
|
|
2665
|
+
getFocusedValue: function getFocusedValue() {
|
|
2666
|
+
return plumeState.getFocusedValue();
|
|
2775
2667
|
},
|
|
2776
|
-
|
|
2777
|
-
return plumeState.
|
|
2668
|
+
setFocusedValue: function setFocusedValue(key) {
|
|
2669
|
+
return plumeState.setFocusedValue(key);
|
|
2778
2670
|
}
|
|
2779
2671
|
};
|
|
2780
|
-
}, [rootRef,
|
|
2672
|
+
}, [rootRef, plumeState]);
|
|
2781
2673
|
return {
|
|
2782
2674
|
plasmicProps: {
|
|
2783
2675
|
variants: variants,
|
|
@@ -2788,118 +2680,26 @@ function useSelect(plasmicClass, props, config, ref) {
|
|
|
2788
2680
|
};
|
|
2789
2681
|
}
|
|
2790
2682
|
|
|
2791
|
-
function
|
|
2792
|
-
var state = props.state,
|
|
2793
|
-
menuProps = props.menuProps,
|
|
2794
|
-
children = props.children;
|
|
2795
|
-
var ref = React.useRef(null);
|
|
2796
|
-
|
|
2797
|
-
var _useListBox = listbox.useListBox(_extends({}, menuProps, {
|
|
2798
|
-
isVirtualized: false,
|
|
2799
|
-
autoFocus: state.focusStrategy || true,
|
|
2800
|
-
disallowEmptySelection: true
|
|
2801
|
-
}), state, ref),
|
|
2802
|
-
listBoxProps = _useListBox.listBoxProps;
|
|
2803
|
-
|
|
2804
|
-
return React.cloneElement(children, mergeProps(children.props, listBoxProps, {
|
|
2805
|
-
style: noOutline(),
|
|
2806
|
-
ref: ref
|
|
2807
|
-
}));
|
|
2808
|
-
}
|
|
2809
|
-
|
|
2810
|
-
function useSelectOption(plasmicClass, props, config, outerRef) {
|
|
2811
|
-
var _extends2, _overrides;
|
|
2812
|
-
|
|
2813
|
-
if (outerRef === void 0) {
|
|
2814
|
-
outerRef = null;
|
|
2815
|
-
}
|
|
2816
|
-
|
|
2817
|
-
var state = React.useContext(SelectContext);
|
|
2818
|
-
|
|
2819
|
-
if (!state) {
|
|
2820
|
-
// If no context, then we are being incorrectly used. Complain or just don't
|
|
2821
|
-
// bother installing any hooks. It's okay to violate rules of hooks here
|
|
2822
|
-
// because this instance won't suddenly be used correctly in another render.
|
|
2823
|
-
if (PLUME_STRICT_MODE) {
|
|
2824
|
-
throw new Error("You can only use a Select.Option within a Select component.");
|
|
2825
|
-
}
|
|
2826
|
-
|
|
2827
|
-
return getDefaultPlasmicProps(plasmicClass, props);
|
|
2828
|
-
}
|
|
2829
|
-
|
|
2830
|
-
var children = props.children;
|
|
2831
|
-
var rootRef = React.useRef(null);
|
|
2832
|
-
var onRef = mergeRefs(rootRef, outerRef); // We pass in the Node secretly as an undocumented prop from <Select />
|
|
2833
|
-
|
|
2834
|
-
var node = props._node;
|
|
2835
|
-
var isSelected = state.selectionManager.isSelected(node.key);
|
|
2836
|
-
var isDisabled = state.disabledKeys.has(node.key);
|
|
2837
|
-
var isHighlighted = state.selectionManager.isFocused && state.selectionManager.focusedKey === node.key;
|
|
2838
|
-
|
|
2839
|
-
var _useAriaOption = listbox.useOption({
|
|
2840
|
-
isSelected: isSelected,
|
|
2841
|
-
isDisabled: isDisabled,
|
|
2842
|
-
"aria-label": node && node["aria-label"],
|
|
2843
|
-
key: node.key,
|
|
2844
|
-
shouldSelectOnPressUp: true,
|
|
2845
|
-
shouldFocusOnHover: true,
|
|
2846
|
-
isVirtualized: false
|
|
2847
|
-
}, state, rootRef),
|
|
2848
|
-
optionProps = _useAriaOption.optionProps,
|
|
2849
|
-
labelProps = _useAriaOption.labelProps;
|
|
2850
|
-
|
|
2851
|
-
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
2852
|
-
def: config.isSelectedVariant,
|
|
2853
|
-
active: isSelected
|
|
2854
|
-
}, {
|
|
2855
|
-
def: config.isDisabledVariant,
|
|
2856
|
-
active: isDisabled
|
|
2857
|
-
}, {
|
|
2858
|
-
def: config.isHighlightedVariant,
|
|
2859
|
-
active: isHighlighted
|
|
2860
|
-
}));
|
|
2861
|
-
|
|
2862
|
-
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.labelSlot] = children, _extends2));
|
|
2863
|
-
|
|
2864
|
-
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
2865
|
-
props: mergeProps(optionProps, getStyleProps(props), {
|
|
2866
|
-
ref: onRef,
|
|
2867
|
-
style: noOutline()
|
|
2868
|
-
})
|
|
2869
|
-
}, _overrides[config.labelContainer] = {
|
|
2870
|
-
props: labelProps
|
|
2871
|
-
}, _overrides);
|
|
2872
|
-
return {
|
|
2873
|
-
plasmicProps: {
|
|
2874
|
-
variants: variants,
|
|
2875
|
-
args: args,
|
|
2876
|
-
overrides: overrides
|
|
2877
|
-
}
|
|
2878
|
-
};
|
|
2879
|
-
}
|
|
2880
|
-
|
|
2881
|
-
function useSelectOptionGroup(plasmicClass, props, config) {
|
|
2683
|
+
function useMenuGroup(plasmicClass, props, config) {
|
|
2882
2684
|
var _extends2, _overrides;
|
|
2883
2685
|
|
|
2884
|
-
var
|
|
2885
|
-
// within a Select
|
|
2886
|
-
|
|
2686
|
+
var context = React.useContext(MenuContext);
|
|
2887
2687
|
var node = props._node;
|
|
2888
2688
|
|
|
2889
|
-
if (!
|
|
2689
|
+
if (!context || !node) {
|
|
2890
2690
|
if (PLUME_STRICT_MODE) {
|
|
2891
|
-
throw new Error("You can only use a
|
|
2691
|
+
throw new Error("You can only use a Menu.Group within a Menu component.");
|
|
2892
2692
|
}
|
|
2893
2693
|
|
|
2894
2694
|
return getDefaultPlasmicProps(plasmicClass, props);
|
|
2895
2695
|
}
|
|
2896
2696
|
|
|
2897
|
-
var
|
|
2697
|
+
var _useMenuSection = menu.useMenuSection({
|
|
2898
2698
|
heading: props.title,
|
|
2899
2699
|
"aria-label": props["aria-label"]
|
|
2900
2700
|
}),
|
|
2901
|
-
headingProps =
|
|
2902
|
-
groupProps =
|
|
2701
|
+
headingProps = _useMenuSection.headingProps,
|
|
2702
|
+
groupProps = _useMenuSection.groupProps;
|
|
2903
2703
|
|
|
2904
2704
|
var _useSeparator = separator.useSeparator({
|
|
2905
2705
|
elementType: "li"
|
|
@@ -2911,17 +2711,18 @@ function useSelectOptionGroup(plasmicClass, props, config) {
|
|
|
2911
2711
|
active: !props.title
|
|
2912
2712
|
}, {
|
|
2913
2713
|
def: config.isFirstVariant,
|
|
2914
|
-
active: state.collection.getFirstKey() === node.key
|
|
2714
|
+
active: context.state.collection.getFirstKey() === node.key
|
|
2915
2715
|
}));
|
|
2916
2716
|
|
|
2917
|
-
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.titleSlot] = props.title, _extends2[config.
|
|
2717
|
+
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.titleSlot] = props.title, _extends2[config.itemsSlot] = Array.from(node.childNodes).map(function (childNode) {
|
|
2918
2718
|
return renderCollectionNode(childNode);
|
|
2919
2719
|
}), _extends2));
|
|
2920
2720
|
|
|
2921
2721
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
2922
2722
|
props: getStyleProps(props)
|
|
2923
2723
|
}, _overrides[config.separator] = {
|
|
2924
|
-
props: _extends({}, separatorProps)
|
|
2724
|
+
props: _extends({}, separatorProps),
|
|
2725
|
+
as: "li"
|
|
2925
2726
|
}, _overrides[config.titleContainer] = _extends({
|
|
2926
2727
|
props: _extends({
|
|
2927
2728
|
role: "presentation"
|
|
@@ -2930,8 +2731,9 @@ function useSelectOptionGroup(plasmicClass, props, config) {
|
|
|
2930
2731
|
render: function render() {
|
|
2931
2732
|
return null;
|
|
2932
2733
|
}
|
|
2933
|
-
}), _overrides[config.
|
|
2934
|
-
props: _extends({}, groupProps)
|
|
2734
|
+
}), _overrides[config.itemsContainer] = {
|
|
2735
|
+
props: _extends({}, groupProps),
|
|
2736
|
+
as: "ul"
|
|
2935
2737
|
}, _overrides);
|
|
2936
2738
|
return {
|
|
2937
2739
|
plasmicProps: {
|
|
@@ -2942,776 +2744,976 @@ function useSelectOptionGroup(plasmicClass, props, config) {
|
|
|
2942
2744
|
};
|
|
2943
2745
|
}
|
|
2944
2746
|
|
|
2945
|
-
function
|
|
2946
|
-
var
|
|
2947
|
-
isSelected: props.isChecked,
|
|
2948
|
-
defaultSelected: props.defaultChecked
|
|
2949
|
-
});
|
|
2747
|
+
function useMenuItem(plasmicClass, props, config) {
|
|
2748
|
+
var _extends2, _overrides;
|
|
2950
2749
|
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
return ariaProps;
|
|
2954
|
-
}
|
|
2750
|
+
var menuContext = React.useContext(MenuContext);
|
|
2751
|
+
var triggerContext = React.useContext(TriggeredOverlayContext);
|
|
2955
2752
|
|
|
2956
|
-
|
|
2957
|
-
|
|
2753
|
+
if (!menuContext) {
|
|
2754
|
+
if (PLUME_STRICT_MODE) {
|
|
2755
|
+
throw new Error("You can only use a Menu.Item within a Menu component.");
|
|
2756
|
+
}
|
|
2958
2757
|
|
|
2959
|
-
|
|
2960
|
-
ref = null;
|
|
2758
|
+
return getDefaultPlasmicProps(plasmicClass, props);
|
|
2961
2759
|
}
|
|
2962
2760
|
|
|
2963
2761
|
var children = props.children,
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
var rootRef = React.useRef(null);
|
|
2968
|
-
var ariaProps = asAriaSwitchProps(props);
|
|
2969
|
-
var state = toggle.useToggleState(ariaProps);
|
|
2762
|
+
onAction = props.onAction;
|
|
2763
|
+
var state = menuContext.state,
|
|
2764
|
+
menuProps = menuContext.menuProps; // We pass in the Node secretly as an undocumented prop from <Select />
|
|
2970
2765
|
|
|
2971
|
-
var
|
|
2972
|
-
|
|
2766
|
+
var node = props._node;
|
|
2767
|
+
var isDisabled = state.disabledKeys.has(node.key);
|
|
2768
|
+
var isHighlighted = state.selectionManager.isFocused && state.selectionManager.focusedKey === node.key;
|
|
2769
|
+
var ref = React.useRef(null);
|
|
2770
|
+
|
|
2771
|
+
var _useAriaMenuItem = menu.useMenuItem(mergeProps({
|
|
2772
|
+
// We need to merge both the onAction on MenuItem and the onAction
|
|
2773
|
+
// on Menu
|
|
2774
|
+
onAction: onAction
|
|
2775
|
+
}, {
|
|
2776
|
+
onAction: menuProps.onAction,
|
|
2777
|
+
onClose: triggerContext == null ? void 0 : triggerContext.state.close
|
|
2778
|
+
}, {
|
|
2779
|
+
isDisabled: isDisabled,
|
|
2780
|
+
"aria-label": node && node["aria-label"],
|
|
2781
|
+
key: node.key,
|
|
2782
|
+
isVirtualized: false,
|
|
2783
|
+
closeOnSelect: true
|
|
2784
|
+
}), state, ref),
|
|
2785
|
+
menuItemProps = _useAriaMenuItem.menuItemProps,
|
|
2786
|
+
labelProps = _useAriaMenuItem.labelProps;
|
|
2973
2787
|
|
|
2974
2788
|
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
2975
2789
|
def: config.isDisabledVariant,
|
|
2976
2790
|
active: isDisabled
|
|
2977
2791
|
}, {
|
|
2978
|
-
def: config.
|
|
2979
|
-
active:
|
|
2980
|
-
}, {
|
|
2981
|
-
def: config.noLabelVariant,
|
|
2982
|
-
active: !children
|
|
2792
|
+
def: config.isHighlightedVariant,
|
|
2793
|
+
active: isHighlighted
|
|
2983
2794
|
}));
|
|
2984
2795
|
|
|
2796
|
+
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.labelSlot] = children, _extends2));
|
|
2797
|
+
|
|
2985
2798
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
2986
|
-
as: "
|
|
2987
|
-
props: mergeProps(
|
|
2988
|
-
ref:
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
}, React.createElement("input", Object.assign({}, inputProps, {
|
|
2994
|
-
ref: inputRef
|
|
2995
|
-
}))), children);
|
|
2996
|
-
}
|
|
2799
|
+
as: "li",
|
|
2800
|
+
props: mergeProps(menuItemProps, {
|
|
2801
|
+
ref: ref,
|
|
2802
|
+
style: noOutline()
|
|
2803
|
+
})
|
|
2804
|
+
}, _overrides[config.labelContainer] = {
|
|
2805
|
+
props: _extends({}, labelProps)
|
|
2997
2806
|
}, _overrides);
|
|
2998
|
-
|
|
2999
|
-
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), config.labelSlot ? (_ref = {}, _ref[config.labelSlot] = children, _ref) : {});
|
|
3000
|
-
|
|
3001
|
-
var plumeState = React.useMemo(function () {
|
|
3002
|
-
return {
|
|
3003
|
-
setChecked: function setChecked(checked) {
|
|
3004
|
-
return state.setSelected(checked);
|
|
3005
|
-
}
|
|
3006
|
-
};
|
|
3007
|
-
}, [state]);
|
|
3008
|
-
React.useImperativeHandle(ref, function () {
|
|
3009
|
-
return {
|
|
3010
|
-
getRoot: function getRoot() {
|
|
3011
|
-
return rootRef.current;
|
|
3012
|
-
},
|
|
3013
|
-
focus: function focus() {
|
|
3014
|
-
var _inputRef$current;
|
|
3015
|
-
|
|
3016
|
-
return (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
|
|
3017
|
-
},
|
|
3018
|
-
blur: function blur() {
|
|
3019
|
-
var _inputRef$current2;
|
|
3020
|
-
|
|
3021
|
-
return (_inputRef$current2 = inputRef.current) == null ? void 0 : _inputRef$current2.blur();
|
|
3022
|
-
},
|
|
3023
|
-
setChecked: function setChecked(checked) {
|
|
3024
|
-
return plumeState.setChecked(checked);
|
|
3025
|
-
}
|
|
3026
|
-
};
|
|
3027
|
-
}, [rootRef, inputRef, plumeState]);
|
|
3028
2807
|
return {
|
|
3029
2808
|
plasmicProps: {
|
|
3030
2809
|
variants: variants,
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
}
|
|
3034
|
-
state: plumeState
|
|
2810
|
+
args: args,
|
|
2811
|
+
overrides: overrides
|
|
2812
|
+
}
|
|
3035
2813
|
};
|
|
3036
2814
|
}
|
|
3037
2815
|
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
2816
|
+
/**
|
|
2817
|
+
* A menu trigger hook that combines react-aria's useMenuTrigger, useAriaMenuTrigger,
|
|
2818
|
+
* useOverlayPosition, useOverlay, and usePress
|
|
2819
|
+
*/
|
|
3041
2820
|
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
2821
|
+
function useMenuTrigger(opts, state) {
|
|
2822
|
+
var triggerRef = opts.triggerRef,
|
|
2823
|
+
isDisabled = opts.isDisabled,
|
|
2824
|
+
placement = opts.placement,
|
|
2825
|
+
menuMatchTriggerWidth = opts.menuMatchTriggerWidth,
|
|
2826
|
+
menuWidth = opts.menuWidth,
|
|
2827
|
+
menu$1 = opts.menu;
|
|
3045
2828
|
|
|
3046
|
-
var
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
style = props.style,
|
|
3053
|
-
inputClassName = props.inputClassName,
|
|
3054
|
-
inputStyle = props.inputStyle,
|
|
3055
|
-
rest = _objectWithoutPropertiesLoose(props, _excluded$7);
|
|
2829
|
+
var _useAriaMenuTrigger = menu.useMenuTrigger({
|
|
2830
|
+
type: "menu",
|
|
2831
|
+
isDisabled: isDisabled
|
|
2832
|
+
}, state, triggerRef),
|
|
2833
|
+
triggerPressProps = _useAriaMenuTrigger.menuTriggerProps,
|
|
2834
|
+
menuProps = _useAriaMenuTrigger.menuProps;
|
|
3056
2835
|
|
|
3057
|
-
var
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
focus: function focus() {
|
|
3062
|
-
var _inputRef$current;
|
|
2836
|
+
var _usePress = interactions.usePress(_extends({}, triggerPressProps, {
|
|
2837
|
+
isDisabled: isDisabled
|
|
2838
|
+
})),
|
|
2839
|
+
triggerProps = _usePress.pressProps;
|
|
3063
2840
|
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
blur: function blur() {
|
|
3067
|
-
var _inputRef$current2;
|
|
2841
|
+
var makeMenu = function makeMenu() {
|
|
2842
|
+
var realMenu = typeof menu$1 === "function" ? menu$1() : menu$1;
|
|
3068
2843
|
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
2844
|
+
if (!realMenu) {
|
|
2845
|
+
return null;
|
|
2846
|
+
}
|
|
2847
|
+
|
|
2848
|
+
if (getPlumeType(realMenu) !== "menu") {
|
|
2849
|
+
if (PLUME_STRICT_MODE) {
|
|
2850
|
+
throw new Error("Must use an instance of the Menu component.");
|
|
3076
2851
|
}
|
|
3077
|
-
};
|
|
3078
|
-
}, [rootRef, inputRef]);
|
|
3079
2852
|
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
active: showStartIcon
|
|
3083
|
-
}, {
|
|
3084
|
-
def: config.showEndIconVariant,
|
|
3085
|
-
active: showEndIcon
|
|
3086
|
-
}, {
|
|
3087
|
-
def: config.isDisabledVariant,
|
|
3088
|
-
active: isDisabled
|
|
3089
|
-
}));
|
|
2853
|
+
return null;
|
|
2854
|
+
}
|
|
3090
2855
|
|
|
3091
|
-
|
|
2856
|
+
return React.cloneElement(realMenu, mergeProps(realMenu.props, menuProps));
|
|
2857
|
+
};
|
|
3092
2858
|
|
|
3093
|
-
var
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
style: inputStyle
|
|
3107
|
-
})
|
|
3108
|
-
}, _overrides);
|
|
2859
|
+
var triggerContext = React.useMemo(function () {
|
|
2860
|
+
var _state$focusStrategy;
|
|
2861
|
+
|
|
2862
|
+
return {
|
|
2863
|
+
triggerRef: triggerRef,
|
|
2864
|
+
state: state,
|
|
2865
|
+
autoFocus: (_state$focusStrategy = state.focusStrategy) != null ? _state$focusStrategy : true,
|
|
2866
|
+
placement: placement,
|
|
2867
|
+
overlayMatchTriggerWidth: menuMatchTriggerWidth,
|
|
2868
|
+
overlayMinTriggerWidth: true,
|
|
2869
|
+
overlayWidth: menuWidth
|
|
2870
|
+
};
|
|
2871
|
+
}, [triggerRef, state, placement, menuMatchTriggerWidth, menuWidth]);
|
|
3109
2872
|
return {
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
overrides: overrides
|
|
3114
|
-
}
|
|
2873
|
+
triggerProps: triggerProps,
|
|
2874
|
+
makeMenu: makeMenu,
|
|
2875
|
+
triggerContext: triggerContext
|
|
3115
2876
|
};
|
|
3116
2877
|
}
|
|
3117
2878
|
|
|
3118
|
-
function
|
|
2879
|
+
function DropdownMenu(props) {
|
|
2880
|
+
var isOpen = props.isOpen,
|
|
2881
|
+
defaultOpen = props.defaultOpen,
|
|
2882
|
+
onOpenChange = props.onOpenChange,
|
|
2883
|
+
children = props.children,
|
|
2884
|
+
placement = props.placement,
|
|
2885
|
+
menu = props.menu;
|
|
2886
|
+
var triggerRef = React.useRef(null);
|
|
2887
|
+
var state = menu$1.useMenuTriggerState({
|
|
2888
|
+
isOpen: isOpen,
|
|
2889
|
+
defaultOpen: defaultOpen,
|
|
2890
|
+
onOpenChange: onOpenChange,
|
|
2891
|
+
shouldFlip: true
|
|
2892
|
+
});
|
|
2893
|
+
|
|
2894
|
+
var _useMenuTrigger = useMenuTrigger({
|
|
2895
|
+
triggerRef: triggerRef,
|
|
2896
|
+
placement: placement,
|
|
2897
|
+
menu: menu
|
|
2898
|
+
}, state),
|
|
2899
|
+
triggerProps = _useMenuTrigger.triggerProps,
|
|
2900
|
+
makeMenu = _useMenuTrigger.makeMenu,
|
|
2901
|
+
triggerContext = _useMenuTrigger.triggerContext;
|
|
2902
|
+
|
|
2903
|
+
return React.createElement(TriggeredOverlayContext.Provider, {
|
|
2904
|
+
value: triggerContext
|
|
2905
|
+
}, React.cloneElement(children, mergeProps(children.props, triggerProps, {
|
|
2906
|
+
ref: triggerRef
|
|
2907
|
+
})), state.isOpen && makeMenu());
|
|
2908
|
+
}
|
|
2909
|
+
|
|
2910
|
+
function useMenuButton(plasmicClass, props, config, outerRef) {
|
|
3119
2911
|
var _extends2, _overrides;
|
|
3120
2912
|
|
|
3121
2913
|
if (outerRef === void 0) {
|
|
3122
2914
|
outerRef = null;
|
|
3123
2915
|
}
|
|
3124
2916
|
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
}
|
|
3143
|
-
|
|
3144
|
-
var children = props.children;
|
|
3145
|
-
var triggerRef = context.triggerRef,
|
|
3146
|
-
placement = context.placement,
|
|
3147
|
-
overlayMatchTriggerWidth = context.overlayMatchTriggerWidth,
|
|
3148
|
-
overlayMinTriggerWidth = context.overlayMinTriggerWidth,
|
|
3149
|
-
overlayWidth = context.overlayWidth,
|
|
3150
|
-
state = context.state; // Measure the width of the trigger to inform the width of the menu (below).
|
|
3151
|
-
|
|
3152
|
-
var _React$useState = React.useState(false),
|
|
3153
|
-
isRendered = _React$useState[0],
|
|
3154
|
-
setRendered = _React$useState[1];
|
|
3155
|
-
|
|
3156
|
-
var triggerWidth = triggerRef.current && (overlayMatchTriggerWidth || overlayMinTriggerWidth) ? triggerRef.current.offsetWidth : undefined;
|
|
3157
|
-
useIsomorphicLayoutEffect(function () {
|
|
3158
|
-
if (!isRendered && triggerRef.current && (overlayMatchTriggerWidth || overlayMinTriggerWidth)) {
|
|
3159
|
-
setRendered(true);
|
|
3160
|
-
}
|
|
3161
|
-
}, [triggerRef, isRendered, overlayMatchTriggerWidth, overlayMinTriggerWidth]);
|
|
3162
|
-
|
|
3163
|
-
var _useOverlay = overlays.useOverlay({
|
|
3164
|
-
isOpen: state.isOpen,
|
|
3165
|
-
onClose: state.close,
|
|
3166
|
-
isDismissable: isDismissable,
|
|
3167
|
-
shouldCloseOnBlur: true
|
|
3168
|
-
}, overlayRef),
|
|
3169
|
-
overlayAriaProps = _useOverlay.overlayProps;
|
|
2917
|
+
var placement = props.placement,
|
|
2918
|
+
isOpen = props.isOpen,
|
|
2919
|
+
defaultOpen = props.defaultOpen,
|
|
2920
|
+
onOpenChange = props.onOpenChange,
|
|
2921
|
+
isDisabled = props.isDisabled,
|
|
2922
|
+
menu = props.menu,
|
|
2923
|
+
autoFocus = props.autoFocus,
|
|
2924
|
+
menuMatchTriggerWidth = props.menuMatchTriggerWidth,
|
|
2925
|
+
menuWidth = props.menuWidth;
|
|
2926
|
+
useEnsureSSRProvider();
|
|
2927
|
+
var rootRef = React.useRef(null);
|
|
2928
|
+
var triggerRef = React.useRef(null);
|
|
2929
|
+
var state = menu$1.useMenuTriggerState({
|
|
2930
|
+
isOpen: isOpen,
|
|
2931
|
+
defaultOpen: defaultOpen,
|
|
2932
|
+
onOpenChange: onOpenChange,
|
|
2933
|
+
shouldFlip: true
|
|
2934
|
+
});
|
|
3170
2935
|
|
|
3171
|
-
var
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
placement: placement
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
placementAxis = _useOverlayPosition.placement;
|
|
2936
|
+
var _useMenuTrigger = useMenuTrigger({
|
|
2937
|
+
isDisabled: isDisabled,
|
|
2938
|
+
triggerRef: triggerRef,
|
|
2939
|
+
placement: placement,
|
|
2940
|
+
menuMatchTriggerWidth: menuMatchTriggerWidth,
|
|
2941
|
+
menuWidth: menuWidth,
|
|
2942
|
+
menu: menu
|
|
2943
|
+
}, state),
|
|
2944
|
+
triggerProps = _useMenuTrigger.triggerProps,
|
|
2945
|
+
makeMenu = _useMenuTrigger.makeMenu,
|
|
2946
|
+
triggerContext = _useMenuTrigger.triggerContext;
|
|
3183
2947
|
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
requestAnimationFrame(function () {
|
|
3187
|
-
updatePosition();
|
|
3188
|
-
});
|
|
3189
|
-
}
|
|
3190
|
-
}, [state.isOpen, updatePosition]);
|
|
3191
|
-
var overlayProps = mergeProps({
|
|
3192
|
-
style: {
|
|
3193
|
-
left: "auto",
|
|
3194
|
-
right: "auto",
|
|
3195
|
-
top: "auto",
|
|
3196
|
-
bottom: "auto",
|
|
3197
|
-
position: "absolute",
|
|
3198
|
-
width: overlayWidth != null ? overlayWidth : overlayMatchTriggerWidth ? triggerWidth : "auto",
|
|
3199
|
-
minWidth: overlayMinTriggerWidth ? triggerWidth : "auto"
|
|
3200
|
-
}
|
|
3201
|
-
}, overlayAriaProps, overlayPositionProps);
|
|
2948
|
+
var _useFocusable = focus.useFocusable(props, triggerRef),
|
|
2949
|
+
triggerFocusProps = _useFocusable.focusableProps;
|
|
3202
2950
|
|
|
3203
2951
|
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
3204
|
-
def: config.
|
|
3205
|
-
active:
|
|
3206
|
-
}, {
|
|
3207
|
-
def: config.isPlacedBottomVariant,
|
|
3208
|
-
active: placementAxis === "bottom"
|
|
3209
|
-
}, {
|
|
3210
|
-
def: config.isPlacedLeftVariant,
|
|
3211
|
-
active: placementAxis === "left"
|
|
2952
|
+
def: config.isOpenVariant,
|
|
2953
|
+
active: state.isOpen
|
|
3212
2954
|
}, {
|
|
3213
|
-
def: config.
|
|
3214
|
-
active:
|
|
2955
|
+
def: config.isDisabledVariant,
|
|
2956
|
+
active: isDisabled
|
|
3215
2957
|
}));
|
|
3216
2958
|
|
|
3217
|
-
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.
|
|
3218
|
-
restoreFocus: true
|
|
3219
|
-
}, React.createElement(overlays.DismissButton, {
|
|
3220
|
-
onDismiss: state.close
|
|
3221
|
-
}), children), _extends2));
|
|
2959
|
+
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.menuSlot] = state.isOpen ? makeMenu() : undefined, _extends2));
|
|
3222
2960
|
|
|
3223
2961
|
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
// Possibly being invoked on the server during SSR; no need to
|
|
3232
|
-
// bother with a portal in that case.
|
|
3233
|
-
return root;
|
|
3234
|
-
}
|
|
2962
|
+
wrapChildren: function wrapChildren(children) {
|
|
2963
|
+
return React.createElement(TriggeredOverlayContext.Provider, {
|
|
2964
|
+
value: triggerContext
|
|
2965
|
+
}, children);
|
|
2966
|
+
},
|
|
2967
|
+
props: {
|
|
2968
|
+
ref: rootRef
|
|
3235
2969
|
}
|
|
2970
|
+
}, _overrides[config.trigger] = {
|
|
2971
|
+
props: mergeProps(triggerProps, triggerFocusProps, getStyleProps(props), pick(props, "title"), {
|
|
2972
|
+
ref: triggerRef,
|
|
2973
|
+
autoFocus: autoFocus,
|
|
2974
|
+
disabled: !!isDisabled,
|
|
2975
|
+
// Make sure this button is not interpreted as submit
|
|
2976
|
+
type: "button"
|
|
2977
|
+
})
|
|
3236
2978
|
}, _overrides);
|
|
2979
|
+
var plumeState = React.useMemo(function () {
|
|
2980
|
+
return {
|
|
2981
|
+
open: function open() {
|
|
2982
|
+
return state.open();
|
|
2983
|
+
},
|
|
2984
|
+
close: function close() {
|
|
2985
|
+
return state.close();
|
|
2986
|
+
},
|
|
2987
|
+
isOpen: function isOpen() {
|
|
2988
|
+
return state.isOpen;
|
|
2989
|
+
}
|
|
2990
|
+
};
|
|
2991
|
+
}, [state]);
|
|
2992
|
+
React.useImperativeHandle(outerRef, function () {
|
|
2993
|
+
return {
|
|
2994
|
+
getRoot: function getRoot() {
|
|
2995
|
+
return rootRef.current;
|
|
2996
|
+
},
|
|
2997
|
+
getTrigger: function getTrigger() {
|
|
2998
|
+
return triggerRef.current;
|
|
2999
|
+
},
|
|
3000
|
+
focus: function focus() {
|
|
3001
|
+
return triggerRef.current && triggerRef.current.focus();
|
|
3002
|
+
},
|
|
3003
|
+
blur: function blur() {
|
|
3004
|
+
return triggerRef.current && triggerRef.current.blur();
|
|
3005
|
+
},
|
|
3006
|
+
open: plumeState.open,
|
|
3007
|
+
close: plumeState.close,
|
|
3008
|
+
isOpen: plumeState.isOpen
|
|
3009
|
+
};
|
|
3010
|
+
}, [rootRef, triggerRef, plumeState]);
|
|
3237
3011
|
return {
|
|
3238
3012
|
plasmicProps: {
|
|
3239
3013
|
variants: variants,
|
|
3240
3014
|
args: args,
|
|
3241
3015
|
overrides: overrides
|
|
3242
|
-
}
|
|
3016
|
+
},
|
|
3017
|
+
state: plumeState
|
|
3243
3018
|
};
|
|
3244
3019
|
}
|
|
3245
3020
|
|
|
3246
|
-
|
|
3247
|
-
return function (val, path) {
|
|
3248
|
-
return set($state, [stateName].concat(dataReps, path), val);
|
|
3249
|
-
};
|
|
3250
|
-
}
|
|
3251
|
-
/**
|
|
3252
|
-
* This function generate the state value prop for repeated states
|
|
3253
|
-
* Example:
|
|
3254
|
-
* - parent[][].counter[].count
|
|
3255
|
-
* We need to pass `parent[index1][index2].counter to the child component
|
|
3256
|
-
*/
|
|
3021
|
+
var SelectContext = /*#__PURE__*/React.createContext(undefined);
|
|
3257
3022
|
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3023
|
+
var _excluded$6 = ["value", "defaultValue", "children", "onChange", "placement", "menuMatchTriggerWidth", "menuWidth"];
|
|
3024
|
+
var COLLECTION_OPTS$1 = {
|
|
3025
|
+
itemPlumeType: "select-option",
|
|
3026
|
+
sectionPlumeType: "select-option-group"
|
|
3027
|
+
};
|
|
3262
3028
|
/**
|
|
3263
|
-
*
|
|
3264
|
-
*
|
|
3029
|
+
* Converts props in our BaseSelectProps into props that react-aria's
|
|
3030
|
+
* useSelect() understands.
|
|
3031
|
+
*
|
|
3032
|
+
* Because we're not exposing the Collections API (see ./index.tsx),
|
|
3033
|
+
* we are converting our own API into props for useSelect.
|
|
3034
|
+
*
|
|
3035
|
+
* Specifically, in Plume's API,
|
|
3036
|
+
* - `children` flattens to a list of ReactElements of type Select.Option
|
|
3037
|
+
* or Select.OptionGroup
|
|
3038
|
+
*
|
|
3039
|
+
* and we map it this way to the Collections API:
|
|
3040
|
+
* - `items` is a list of those flattened ReactElements from `children`!
|
|
3041
|
+
* - `children`, as a render prop, is supposed to take one of the `items`
|
|
3042
|
+
* and return a `Section` or `Item` element. We take an Option/OptionGroup
|
|
3043
|
+
* element, and use its props to render the appropriate `Section` or
|
|
3044
|
+
* `Item`. The "trick" here is that we then stuff the Option element as
|
|
3045
|
+
* `Item.children`, and the OptionGroup element as `Section.title`.
|
|
3046
|
+
*
|
|
3047
|
+
* When the Collections API does its work deriving `Node`s, the corresponding
|
|
3048
|
+
* Option/OptionGroup ReactElements will end up as `Node.rendered`.
|
|
3049
|
+
*
|
|
3050
|
+
* Then, when we are actually rendering the content of the dropdown, we
|
|
3051
|
+
* iterate through each collected `Node`, and renders
|
|
3052
|
+
* React.cloneElement(Node.rendered, {_node: node}). This "secretly" passes
|
|
3053
|
+
* the derived collection `Node` as a prop to Option and OptionGroup, and they
|
|
3054
|
+
* can make use of the derived `Node.key` etc in their rendering functions.
|
|
3055
|
+
*
|
|
3056
|
+
* One thing to note here is that we never "rendered" the Option/OptionGroup
|
|
3057
|
+
* React elements that the user constructed; instead, we just looked at the
|
|
3058
|
+
* props used on those elements, and passed those onto the Collections API.
|
|
3059
|
+
* What gets rendered to the screen is the cloned version of these elements
|
|
3060
|
+
* with the secret derived `_node` prop. That means Option and OptionGroup
|
|
3061
|
+
* render functions can assume that _node is passed in.
|
|
3265
3062
|
*/
|
|
3266
3063
|
|
|
3267
|
-
function
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
k;
|
|
3064
|
+
function useAriaSelectProps(props) {
|
|
3065
|
+
var value = props.value,
|
|
3066
|
+
defaultValue = props.defaultValue,
|
|
3067
|
+
children = props.children,
|
|
3068
|
+
onChange = props.onChange,
|
|
3069
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded$6);
|
|
3274
3070
|
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3071
|
+
var _useDerivedItemsFromC = useDerivedItemsFromChildren(children, _extends({}, COLLECTION_OPTS$1, {
|
|
3072
|
+
invalidChildError: "Can only use Select.Option and Select.OptionGroup as children to Select",
|
|
3073
|
+
requireItemValue: true
|
|
3074
|
+
})),
|
|
3075
|
+
items = _useDerivedItemsFromC.items,
|
|
3076
|
+
disabledKeys = _useDerivedItemsFromC.disabledKeys;
|
|
3278
3077
|
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
t[k] = [];
|
|
3290
|
-
t = t[k];
|
|
3291
|
-
}
|
|
3078
|
+
var collectionChildRenderer = React.useCallback(function (child) {
|
|
3079
|
+
return renderAsCollectionChild(child, COLLECTION_OPTS$1);
|
|
3080
|
+
}, []);
|
|
3081
|
+
var onSelectionChange = React.useMemo(function () {
|
|
3082
|
+
if (onChange) {
|
|
3083
|
+
return function (val) {
|
|
3084
|
+
return onChange(val == null || val === "null" ? null : val);
|
|
3085
|
+
};
|
|
3086
|
+
} else {
|
|
3087
|
+
return undefined;
|
|
3292
3088
|
}
|
|
3293
|
-
}
|
|
3089
|
+
}, [onChange]);
|
|
3090
|
+
return {
|
|
3091
|
+
ariaProps: _extends({}, rest, {
|
|
3092
|
+
children: collectionChildRenderer,
|
|
3093
|
+
onSelectionChange: onSelectionChange,
|
|
3094
|
+
items: items,
|
|
3095
|
+
disabledKeys: disabledKeys,
|
|
3096
|
+
defaultSelectedKey: defaultValue
|
|
3097
|
+
}, "value" in props && {
|
|
3098
|
+
selectedKey: value != null ? value : null
|
|
3099
|
+
})
|
|
3100
|
+
};
|
|
3294
3101
|
}
|
|
3295
3102
|
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
};
|
|
3103
|
+
function useSelect(plasmicClass, props, config, ref) {
|
|
3104
|
+
var _overrides, _extends2;
|
|
3299
3105
|
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
};
|
|
3106
|
+
if (ref === void 0) {
|
|
3107
|
+
ref = null;
|
|
3108
|
+
}
|
|
3304
3109
|
|
|
3305
|
-
|
|
3306
|
-
};
|
|
3110
|
+
useEnsureSSRProvider();
|
|
3307
3111
|
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
return false;
|
|
3311
|
-
}
|
|
3112
|
+
var _useAriaSelectProps = useAriaSelectProps(props),
|
|
3113
|
+
ariaProps = _useAriaSelectProps.ariaProps;
|
|
3312
3114
|
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3115
|
+
var placement = props.placement;
|
|
3116
|
+
var state = select$1.useSelectState(ariaProps);
|
|
3117
|
+
var triggerRef = React.useRef(null);
|
|
3118
|
+
var rootRef = React.useRef(null);
|
|
3119
|
+
var isDisabled = props.isDisabled,
|
|
3120
|
+
name = props.name,
|
|
3121
|
+
menuWidth = props.menuWidth,
|
|
3122
|
+
menuMatchTriggerWidth = props.menuMatchTriggerWidth,
|
|
3123
|
+
autoFocus = props.autoFocus,
|
|
3124
|
+
placeholder = props.placeholder,
|
|
3125
|
+
selectedContent = props.selectedContent;
|
|
3318
3126
|
|
|
3319
|
-
|
|
3320
|
-
|
|
3127
|
+
var _useAriaSelect = select.useSelect(ariaProps, state, triggerRef),
|
|
3128
|
+
triggerPressProps = _useAriaSelect.triggerProps,
|
|
3129
|
+
menuProps = _useAriaSelect.menuProps;
|
|
3321
3130
|
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
}
|
|
3131
|
+
var _usePress = interactions.usePress(_extends({}, triggerPressProps, {
|
|
3132
|
+
isDisabled: isDisabled
|
|
3133
|
+
})),
|
|
3134
|
+
triggerProps = _usePress.pressProps;
|
|
3325
3135
|
|
|
3326
|
-
|
|
3327
|
-
var key = JSON.stringify(path);
|
|
3328
|
-
$$state.existingStates.set(key, {
|
|
3329
|
-
path: path,
|
|
3330
|
-
specKey: spec.path
|
|
3331
|
-
});
|
|
3136
|
+
var triggerContent = state.selectedItem ? selectedContent != null ? selectedContent : getChildProp(state.selectedItem.value, "children") : null;
|
|
3332
3137
|
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3138
|
+
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
3139
|
+
def: config.isOpenVariant,
|
|
3140
|
+
active: state.isOpen
|
|
3141
|
+
}, {
|
|
3142
|
+
def: config.placeholderVariant,
|
|
3143
|
+
active: !state.selectedItem
|
|
3144
|
+
}, {
|
|
3145
|
+
def: config.isDisabledVariant,
|
|
3146
|
+
active: isDisabled
|
|
3147
|
+
}));
|
|
3336
3148
|
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3149
|
+
var triggerContext = React.useMemo(function () {
|
|
3150
|
+
return {
|
|
3151
|
+
triggerRef: triggerRef,
|
|
3152
|
+
state: state,
|
|
3153
|
+
placement: placement,
|
|
3154
|
+
overlayMatchTriggerWidth: menuMatchTriggerWidth,
|
|
3155
|
+
overlayMinTriggerWidth: true,
|
|
3156
|
+
overlayWidth: menuWidth
|
|
3157
|
+
};
|
|
3158
|
+
}, [triggerRef, state, placement, menuMatchTriggerWidth, menuWidth]);
|
|
3159
|
+
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
3160
|
+
props: mergeProps(getStyleProps(props), {
|
|
3161
|
+
ref: rootRef
|
|
3162
|
+
}),
|
|
3163
|
+
wrapChildren: function wrapChildren(children) {
|
|
3164
|
+
return React.createElement(React.Fragment, null, React.createElement(select.HiddenSelect, {
|
|
3165
|
+
state: state,
|
|
3166
|
+
triggerRef: triggerRef,
|
|
3167
|
+
name: name,
|
|
3168
|
+
isDisabled: isDisabled
|
|
3169
|
+
}), children);
|
|
3170
|
+
}
|
|
3171
|
+
}, _overrides[config.trigger] = {
|
|
3172
|
+
props: mergeProps(triggerProps, {
|
|
3173
|
+
ref: triggerRef,
|
|
3174
|
+
autoFocus: autoFocus,
|
|
3175
|
+
disabled: !!isDisabled,
|
|
3176
|
+
// Don't trigger form submission!
|
|
3177
|
+
type: "button"
|
|
3178
|
+
})
|
|
3179
|
+
}, _overrides[config.overlay] = {
|
|
3180
|
+
wrap: function wrap(content) {
|
|
3181
|
+
return React.createElement(TriggeredOverlayContext.Provider, {
|
|
3182
|
+
value: triggerContext
|
|
3183
|
+
}, content);
|
|
3184
|
+
}
|
|
3185
|
+
}, _overrides[config.optionsContainer] = {
|
|
3186
|
+
wrap: function wrap(content) {
|
|
3187
|
+
return React.createElement(ListBoxWrapper, {
|
|
3188
|
+
state: state,
|
|
3189
|
+
menuProps: menuProps
|
|
3190
|
+
}, content);
|
|
3191
|
+
}
|
|
3192
|
+
}, _overrides);
|
|
3342
3193
|
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
}), spec.pathObj.slice(0, currPath.length));
|
|
3349
|
-
}).reduce(function (agg, spec) {
|
|
3350
|
-
var nextKey = spec.pathObj[currPath.length];
|
|
3194
|
+
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.triggerContentSlot] = triggerContent, _extends2[config.placeholderSlot] = placeholder, _extends2[config.optionsSlot] = React.createElement(SelectContext.Provider, {
|
|
3195
|
+
value: state
|
|
3196
|
+
}, Array.from(state.collection).map(function (node) {
|
|
3197
|
+
return renderCollectionNode(node);
|
|
3198
|
+
})), _extends2));
|
|
3351
3199
|
|
|
3352
|
-
|
|
3353
|
-
|
|
3200
|
+
var plumeState = React.useMemo(function () {
|
|
3201
|
+
return {
|
|
3202
|
+
open: function open() {
|
|
3203
|
+
return state.open();
|
|
3204
|
+
},
|
|
3205
|
+
close: function close() {
|
|
3206
|
+
return state.close();
|
|
3207
|
+
},
|
|
3208
|
+
isOpen: function isOpen() {
|
|
3209
|
+
return state.isOpen;
|
|
3210
|
+
},
|
|
3211
|
+
getSelectedValue: function getSelectedValue() {
|
|
3212
|
+
return state.selectedKey ? "" + state.selectedKey : null;
|
|
3213
|
+
},
|
|
3214
|
+
setSelectedValue: function setSelectedValue(key) {
|
|
3215
|
+
return state.setSelectedKey(key);
|
|
3354
3216
|
}
|
|
3217
|
+
};
|
|
3218
|
+
}, [state]);
|
|
3219
|
+
React.useImperativeHandle(ref, function () {
|
|
3220
|
+
return {
|
|
3221
|
+
getRoot: function getRoot() {
|
|
3222
|
+
return rootRef.current;
|
|
3223
|
+
},
|
|
3224
|
+
getTrigger: function getTrigger() {
|
|
3225
|
+
return triggerRef.current;
|
|
3226
|
+
},
|
|
3227
|
+
focus: function focus() {
|
|
3228
|
+
var _triggerRef$current;
|
|
3355
3229
|
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3230
|
+
return (_triggerRef$current = triggerRef.current) == null ? void 0 : _triggerRef$current.focus();
|
|
3231
|
+
},
|
|
3232
|
+
blur: function blur() {
|
|
3233
|
+
var _triggerRef$current2;
|
|
3234
|
+
|
|
3235
|
+
return (_triggerRef$current2 = triggerRef.current) == null ? void 0 : _triggerRef$current2.blur();
|
|
3236
|
+
},
|
|
3237
|
+
open: function open() {
|
|
3238
|
+
return plumeState.open();
|
|
3239
|
+
},
|
|
3240
|
+
close: function close() {
|
|
3241
|
+
return plumeState.close();
|
|
3242
|
+
},
|
|
3243
|
+
isOpen: function isOpen() {
|
|
3244
|
+
return plumeState.isOpen();
|
|
3245
|
+
},
|
|
3246
|
+
getSelectedValue: function getSelectedValue() {
|
|
3247
|
+
return plumeState.getSelectedValue();
|
|
3248
|
+
},
|
|
3249
|
+
setSelectedValue: function setSelectedValue(key) {
|
|
3250
|
+
return plumeState.setSelectedValue(key);
|
|
3251
|
+
}
|
|
3252
|
+
};
|
|
3253
|
+
}, [rootRef, triggerRef, plumeState]);
|
|
3254
|
+
return {
|
|
3255
|
+
plasmicProps: {
|
|
3256
|
+
variants: variants,
|
|
3257
|
+
args: args,
|
|
3258
|
+
overrides: overrides
|
|
3259
|
+
},
|
|
3260
|
+
state: plumeState
|
|
3359
3261
|
};
|
|
3262
|
+
}
|
|
3360
3263
|
|
|
3361
|
-
|
|
3362
|
-
|
|
3264
|
+
function ListBoxWrapper(props) {
|
|
3265
|
+
var state = props.state,
|
|
3266
|
+
menuProps = props.menuProps,
|
|
3267
|
+
children = props.children;
|
|
3268
|
+
var ref = React.useRef(null);
|
|
3363
3269
|
|
|
3364
|
-
|
|
3365
|
-
|
|
3270
|
+
var _useListBox = listbox.useListBox(_extends({}, menuProps, {
|
|
3271
|
+
isVirtualized: false,
|
|
3272
|
+
autoFocus: state.focusStrategy || true,
|
|
3273
|
+
disallowEmptySelection: true
|
|
3274
|
+
}), state, ref),
|
|
3275
|
+
listBoxProps = _useListBox.listBoxProps;
|
|
3366
3276
|
|
|
3367
|
-
|
|
3368
|
-
|
|
3277
|
+
return React.cloneElement(children, mergeProps(children.props, listBoxProps, {
|
|
3278
|
+
style: noOutline(),
|
|
3279
|
+
ref: ref
|
|
3280
|
+
}));
|
|
3281
|
+
}
|
|
3369
3282
|
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
};
|
|
3283
|
+
function useSelectOption(plasmicClass, props, config, outerRef) {
|
|
3284
|
+
var _extends2, _overrides;
|
|
3373
3285
|
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
var specKeysToUpdate = new Set();
|
|
3378
|
-
$$state.existingStates.forEach(function (_ref) {
|
|
3379
|
-
var path = _ref.path,
|
|
3380
|
-
specKey = _ref.specKey;
|
|
3286
|
+
if (outerRef === void 0) {
|
|
3287
|
+
outerRef = null;
|
|
3288
|
+
}
|
|
3381
3289
|
|
|
3382
|
-
|
|
3383
|
-
deleteState($$state, path);
|
|
3384
|
-
specKeysToUpdate.add(specKey);
|
|
3385
|
-
}
|
|
3386
|
-
});
|
|
3387
|
-
specKeysToUpdate.forEach(function (specKey) {
|
|
3388
|
-
var spec = $$state.specsByKey[specKey];
|
|
3290
|
+
var state = React.useContext(SelectContext);
|
|
3389
3291
|
|
|
3390
|
-
|
|
3391
|
-
|
|
3292
|
+
if (!state) {
|
|
3293
|
+
// If no context, then we are being incorrectly used. Complain or just don't
|
|
3294
|
+
// bother installing any hooks. It's okay to violate rules of hooks here
|
|
3295
|
+
// because this instance won't suddenly be used correctly in another render.
|
|
3296
|
+
if (PLUME_STRICT_MODE) {
|
|
3297
|
+
throw new Error("You can only use a Select.Option within a Select component.");
|
|
3298
|
+
}
|
|
3392
3299
|
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
});
|
|
3396
|
-
return Reflect.deleteProperty(target, property);
|
|
3397
|
-
},
|
|
3398
|
-
get: function get(target, property, receiver) {
|
|
3399
|
-
var spec = getSpecForProperty(property);
|
|
3300
|
+
return getDefaultPlasmicProps(plasmicClass, props);
|
|
3301
|
+
}
|
|
3400
3302
|
|
|
3401
|
-
|
|
3402
|
-
|
|
3303
|
+
var children = props.children;
|
|
3304
|
+
var rootRef = React.useRef(null);
|
|
3305
|
+
var onRef = mergeRefs(rootRef, outerRef); // We pass in the Node secretly as an undocumented prop from <Select />
|
|
3403
3306
|
|
|
3404
|
-
|
|
3405
|
-
|
|
3307
|
+
var node = props._node;
|
|
3308
|
+
var isSelected = state.selectionManager.isSelected(node.key);
|
|
3309
|
+
var isDisabled = state.disabledKeys.has(node.key);
|
|
3310
|
+
var isHighlighted = state.selectionManager.isFocused && state.selectionManager.focusedKey === node.key;
|
|
3406
3311
|
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3312
|
+
var _useAriaOption = listbox.useOption({
|
|
3313
|
+
isSelected: isSelected,
|
|
3314
|
+
isDisabled: isDisabled,
|
|
3315
|
+
"aria-label": node && node["aria-label"],
|
|
3316
|
+
key: node.key,
|
|
3317
|
+
shouldSelectOnPressUp: true,
|
|
3318
|
+
shouldFocusOnHover: true,
|
|
3319
|
+
isVirtualized: false
|
|
3320
|
+
}, state, rootRef),
|
|
3321
|
+
optionProps = _useAriaOption.optionProps,
|
|
3322
|
+
labelProps = _useAriaOption.labelProps;
|
|
3413
3323
|
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3324
|
+
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
3325
|
+
def: config.isSelectedVariant,
|
|
3326
|
+
active: isSelected
|
|
3327
|
+
}, {
|
|
3328
|
+
def: config.isDisabledVariant,
|
|
3329
|
+
active: isDisabled
|
|
3330
|
+
}, {
|
|
3331
|
+
def: config.isHighlightedVariant,
|
|
3332
|
+
active: isHighlighted
|
|
3333
|
+
}));
|
|
3419
3334
|
|
|
3420
|
-
|
|
3421
|
-
if (spec.pathObj.length === currPath.length + 1) {
|
|
3422
|
-
var _handlers$set, _handlers2;
|
|
3335
|
+
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.labelSlot] = children, _extends2));
|
|
3423
3336
|
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3337
|
+
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
3338
|
+
props: mergeProps(optionProps, getStyleProps(props), {
|
|
3339
|
+
ref: onRef,
|
|
3340
|
+
style: noOutline()
|
|
3341
|
+
})
|
|
3342
|
+
}, _overrides[config.labelContainer] = {
|
|
3343
|
+
props: labelProps
|
|
3344
|
+
}, _overrides);
|
|
3345
|
+
return {
|
|
3346
|
+
plasmicProps: {
|
|
3347
|
+
variants: variants,
|
|
3348
|
+
args: args,
|
|
3349
|
+
overrides: overrides
|
|
3350
|
+
}
|
|
3351
|
+
};
|
|
3352
|
+
}
|
|
3429
3353
|
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
target[property][key] = value[key];
|
|
3433
|
-
}
|
|
3354
|
+
function useSelectOptionGroup(plasmicClass, props, config) {
|
|
3355
|
+
var _extends2, _overrides;
|
|
3434
3356
|
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
}
|
|
3357
|
+
var state = React.useContext(SelectContext); // `node` should exist if the OptionGroup was instantiated properly
|
|
3358
|
+
// within a Select
|
|
3438
3359
|
|
|
3439
|
-
|
|
3440
|
-
return Reflect.set(target, property, value, receiver);
|
|
3441
|
-
}
|
|
3360
|
+
var node = props._node;
|
|
3442
3361
|
|
|
3443
|
-
|
|
3444
|
-
|
|
3362
|
+
if (!state || !node) {
|
|
3363
|
+
if (PLUME_STRICT_MODE) {
|
|
3364
|
+
throw new Error("You can only use a Select.OptionGroup within a Select component.");
|
|
3365
|
+
}
|
|
3445
3366
|
|
|
3446
|
-
|
|
3367
|
+
return getDefaultPlasmicProps(plasmicClass, props);
|
|
3368
|
+
}
|
|
3447
3369
|
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3370
|
+
var _useListBoxSection = listbox.useListBoxSection({
|
|
3371
|
+
heading: props.title,
|
|
3372
|
+
"aria-label": props["aria-label"]
|
|
3373
|
+
}),
|
|
3374
|
+
headingProps = _useListBoxSection.headingProps,
|
|
3375
|
+
groupProps = _useListBoxSection.groupProps;
|
|
3451
3376
|
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
} // invalid setting a value that doesn't make part of the spec
|
|
3377
|
+
var _useSeparator = separator.useSeparator({
|
|
3378
|
+
elementType: "li"
|
|
3379
|
+
}),
|
|
3380
|
+
separatorProps = _useSeparator.separatorProps;
|
|
3457
3381
|
|
|
3382
|
+
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
3383
|
+
def: config.noTitleVariant,
|
|
3384
|
+
active: !props.title
|
|
3385
|
+
}, {
|
|
3386
|
+
def: config.isFirstVariant,
|
|
3387
|
+
active: state.collection.getFirstKey() === node.key
|
|
3388
|
+
}));
|
|
3458
3389
|
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
};
|
|
3390
|
+
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.titleSlot] = props.title, _extends2[config.optionsSlot] = Array.from(node.childNodes).map(function (childNode) {
|
|
3391
|
+
return renderCollectionNode(childNode);
|
|
3392
|
+
}), _extends2));
|
|
3463
3393
|
|
|
3464
|
-
|
|
3394
|
+
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
3395
|
+
props: getStyleProps(props)
|
|
3396
|
+
}, _overrides[config.separator] = {
|
|
3397
|
+
props: _extends({}, separatorProps)
|
|
3398
|
+
}, _overrides[config.titleContainer] = _extends({
|
|
3399
|
+
props: _extends({
|
|
3400
|
+
role: "presentation"
|
|
3401
|
+
}, headingProps)
|
|
3402
|
+
}, !props.title && {
|
|
3403
|
+
render: function render() {
|
|
3404
|
+
return null;
|
|
3405
|
+
}
|
|
3406
|
+
}), _overrides[config.optionsContainer] = {
|
|
3407
|
+
props: _extends({}, groupProps)
|
|
3408
|
+
}, _overrides);
|
|
3409
|
+
return {
|
|
3410
|
+
plasmicProps: {
|
|
3411
|
+
variants: variants,
|
|
3412
|
+
args: args,
|
|
3413
|
+
overrides: overrides
|
|
3414
|
+
}
|
|
3415
|
+
};
|
|
3465
3416
|
}
|
|
3466
3417
|
|
|
3467
|
-
|
|
3468
|
-
var
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
(_$$state$unsubscripti = $$state.unsubscriptionsByState[key]) == null ? void 0 : _$$state$unsubscripti.forEach(function (f) {
|
|
3472
|
-
return f();
|
|
3418
|
+
function asAriaSwitchProps(props) {
|
|
3419
|
+
var ariaProps = _extends({}, props, {
|
|
3420
|
+
isSelected: props.isChecked,
|
|
3421
|
+
defaultSelected: props.defaultChecked
|
|
3473
3422
|
});
|
|
3474
|
-
delete $$state.unsubscriptionsByState[key];
|
|
3475
|
-
$$state.existingStates["delete"](key); // delete get($$state.stateValues, path.slice(-1))[path.slice(-1)[0]];
|
|
3476
|
-
// delete get($$state.initStateValues, path.slice(-1))[path.slice(-1)[0]];
|
|
3477
|
-
};
|
|
3478
3423
|
|
|
3479
|
-
|
|
3480
|
-
|
|
3424
|
+
delete ariaProps["isChecked"];
|
|
3425
|
+
delete ariaProps["defaultChecked"];
|
|
3426
|
+
return ariaProps;
|
|
3427
|
+
}
|
|
3481
3428
|
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
}
|
|
3429
|
+
function useSwitch(plasmicClass, props, config, ref) {
|
|
3430
|
+
var _overrides, _ref;
|
|
3485
3431
|
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
indexes.push(path[i]);
|
|
3489
|
-
}
|
|
3432
|
+
if (ref === void 0) {
|
|
3433
|
+
ref = null;
|
|
3490
3434
|
}
|
|
3491
3435
|
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
var
|
|
3497
|
-
|
|
3498
|
-
var
|
|
3499
|
-
var stateAccess = new Set();
|
|
3500
|
-
var $state = create$StateProxy($$state, function (path, spec) {
|
|
3501
|
-
return {
|
|
3502
|
-
get: function get() {
|
|
3503
|
-
var key = JSON.stringify(path);
|
|
3504
|
-
stateAccess.add({
|
|
3505
|
-
path: path,
|
|
3506
|
-
spec: spec
|
|
3507
|
-
});
|
|
3436
|
+
var children = props.children,
|
|
3437
|
+
isDisabled = props.isDisabled;
|
|
3438
|
+
useEnsureSSRProvider();
|
|
3439
|
+
var inputRef = React.useRef(null);
|
|
3440
|
+
var rootRef = React.useRef(null);
|
|
3441
|
+
var ariaProps = asAriaSwitchProps(props);
|
|
3442
|
+
var state = toggle.useToggleState(ariaProps);
|
|
3508
3443
|
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
}
|
|
3444
|
+
var _useAriaSwitch = _switch.useSwitch(ariaProps, state, inputRef),
|
|
3445
|
+
inputProps = _useAriaSwitch.inputProps;
|
|
3512
3446
|
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3447
|
+
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
3448
|
+
def: config.isDisabledVariant,
|
|
3449
|
+
active: isDisabled
|
|
3450
|
+
}, {
|
|
3451
|
+
def: config.isCheckedVariant,
|
|
3452
|
+
active: state.isSelected
|
|
3453
|
+
}, {
|
|
3454
|
+
def: config.noLabelVariant,
|
|
3455
|
+
active: !children
|
|
3456
|
+
}));
|
|
3519
3457
|
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3458
|
+
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
3459
|
+
as: "label",
|
|
3460
|
+
props: mergeProps(getStyleProps(props), {
|
|
3461
|
+
ref: rootRef
|
|
3462
|
+
}),
|
|
3463
|
+
wrapChildren: function wrapChildren(children) {
|
|
3464
|
+
return React.createElement(React.Fragment, null, React.createElement(visuallyHidden.VisuallyHidden, {
|
|
3465
|
+
isFocusable: true
|
|
3466
|
+
}, React.createElement("input", Object.assign({}, inputProps, {
|
|
3467
|
+
ref: inputRef
|
|
3468
|
+
}))), children);
|
|
3469
|
+
}
|
|
3470
|
+
}, _overrides);
|
|
3471
|
+
|
|
3472
|
+
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), config.labelSlot ? (_ref = {}, _ref[config.labelSlot] = children, _ref) : {});
|
|
3473
|
+
|
|
3474
|
+
var plumeState = React.useMemo(function () {
|
|
3475
|
+
return {
|
|
3476
|
+
setChecked: function setChecked(checked) {
|
|
3477
|
+
return state.setSelected(checked);
|
|
3524
3478
|
}
|
|
3525
3479
|
};
|
|
3526
|
-
});
|
|
3527
|
-
(
|
|
3528
|
-
return
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
var unsubscribe = utils.subscribeKey(_get($$state.stateValues, path.slice(-1)), path.slice(-1)[0], function () {
|
|
3535
|
-
return set($$state.stateValues, initialStatePath, mkUntrackedValue(initialSpec.initFunc($$state.props, $state, getIndexes(path, spec))));
|
|
3536
|
-
});
|
|
3537
|
-
$$state.unsubscriptionsByState[initialStateKey].push(unsubscribe);
|
|
3538
|
-
});
|
|
3539
|
-
var untrackedInitialValue = mkUntrackedValue(initialSpec.initFunc($$state.props, $state, getIndexes(initialStatePath, initialSpec)));
|
|
3540
|
-
|
|
3541
|
-
set($$state.initStateValues, initialStatePath, untrackedInitialValue);
|
|
3480
|
+
}, [state]);
|
|
3481
|
+
React.useImperativeHandle(ref, function () {
|
|
3482
|
+
return {
|
|
3483
|
+
getRoot: function getRoot() {
|
|
3484
|
+
return rootRef.current;
|
|
3485
|
+
},
|
|
3486
|
+
focus: function focus() {
|
|
3487
|
+
var _inputRef$current;
|
|
3542
3488
|
|
|
3543
|
-
|
|
3489
|
+
return (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
|
|
3490
|
+
},
|
|
3491
|
+
blur: function blur() {
|
|
3492
|
+
var _inputRef$current2;
|
|
3544
3493
|
|
|
3545
|
-
|
|
3494
|
+
return (_inputRef$current2 = inputRef.current) == null ? void 0 : _inputRef$current2.blur();
|
|
3495
|
+
},
|
|
3496
|
+
setChecked: function setChecked(checked) {
|
|
3497
|
+
return plumeState.setChecked(checked);
|
|
3498
|
+
}
|
|
3499
|
+
};
|
|
3500
|
+
}, [rootRef, inputRef, plumeState]);
|
|
3501
|
+
return {
|
|
3502
|
+
plasmicProps: {
|
|
3503
|
+
variants: variants,
|
|
3504
|
+
overrides: overrides,
|
|
3505
|
+
args: args
|
|
3506
|
+
},
|
|
3507
|
+
state: plumeState
|
|
3508
|
+
};
|
|
3546
3509
|
}
|
|
3547
3510
|
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
initStateValues: {},
|
|
3552
|
-
specsByKey: Object.fromEntries(specs.map(function (spec) {
|
|
3553
|
-
return [spec.path, _extends({}, spec, {
|
|
3554
|
-
pathObj: transformPathStringToObj(spec.path),
|
|
3555
|
-
isRepeated: spec.path.split(".").some(function (part) {
|
|
3556
|
-
return part.endsWith("[]");
|
|
3557
|
-
})
|
|
3558
|
-
})];
|
|
3559
|
-
})),
|
|
3560
|
-
statesInstanceBySpec: new Map(),
|
|
3561
|
-
existingStates: new Map(),
|
|
3562
|
-
unsubscriptionsByState: {},
|
|
3563
|
-
props: undefined,
|
|
3564
|
-
registrationsQueue: []
|
|
3565
|
-
})).current;
|
|
3566
|
-
$$state.props = mkUntrackedValue(props);
|
|
3567
|
-
var $state = React__default.useRef(Object.assign(create$StateProxy($$state, function (path, spec) {
|
|
3568
|
-
var key = JSON.stringify(path);
|
|
3569
|
-
|
|
3570
|
-
if (!$$state.existingStates.has(key)) {
|
|
3571
|
-
var _spec$initVal;
|
|
3572
|
-
|
|
3573
|
-
saveNewState($$state, path, spec);
|
|
3574
|
-
var untrackedValue = !spec.initFunc ? mkUntrackedValue((_spec$initVal = spec.initVal) != null ? _spec$initVal : undefined) : initializeStateValue($$state, path, spec);
|
|
3511
|
+
var _excluded$7 = ["isDisabled", "startIcon", "endIcon", "showStartIcon", "showEndIcon", "className", "style", "inputClassName", "inputStyle"];
|
|
3512
|
+
function useTextInput(plasmicClass, props, config, ref) {
|
|
3513
|
+
var _ref, _ref2, _overrides;
|
|
3575
3514
|
|
|
3576
|
-
|
|
3515
|
+
if (ref === void 0) {
|
|
3516
|
+
ref = null;
|
|
3517
|
+
}
|
|
3577
3518
|
|
|
3578
|
-
|
|
3579
|
-
|
|
3519
|
+
var isDisabled = props.isDisabled,
|
|
3520
|
+
startIcon = props.startIcon,
|
|
3521
|
+
endIcon = props.endIcon,
|
|
3522
|
+
showStartIcon = props.showStartIcon,
|
|
3523
|
+
showEndIcon = props.showEndIcon,
|
|
3524
|
+
className = props.className,
|
|
3525
|
+
style = props.style,
|
|
3526
|
+
inputClassName = props.inputClassName,
|
|
3527
|
+
inputStyle = props.inputStyle,
|
|
3528
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded$7);
|
|
3580
3529
|
|
|
3530
|
+
var rootRef = React.useRef(null);
|
|
3531
|
+
var inputRef = React.useRef(null);
|
|
3532
|
+
React.useImperativeHandle(ref, function () {
|
|
3581
3533
|
return {
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
var value = !spec.isRepeated ? $$state.props[spec.valueProp] : _get($$state.props[spec.valueProp], path.slice(1));
|
|
3585
|
-
return value;
|
|
3586
|
-
} else {
|
|
3587
|
-
return _get($$state.stateValues, path);
|
|
3588
|
-
}
|
|
3589
|
-
},
|
|
3590
|
-
set: function set$1(_t, _p, value) {
|
|
3591
|
-
set($$state.stateValues, path, mkUntrackedValue(value));
|
|
3592
|
-
|
|
3593
|
-
if (spec.onChangeProp) {
|
|
3594
|
-
var _$$state$props$spec$o3, _$$state$props3;
|
|
3534
|
+
focus: function focus() {
|
|
3535
|
+
var _inputRef$current;
|
|
3595
3536
|
|
|
3596
|
-
|
|
3597
|
-
|
|
3537
|
+
(_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
|
|
3538
|
+
},
|
|
3539
|
+
blur: function blur() {
|
|
3540
|
+
var _inputRef$current2;
|
|
3598
3541
|
|
|
3599
|
-
|
|
3542
|
+
(_inputRef$current2 = inputRef.current) == null ? void 0 : _inputRef$current2.blur();
|
|
3543
|
+
},
|
|
3544
|
+
getRoot: function getRoot() {
|
|
3545
|
+
return rootRef.current;
|
|
3546
|
+
},
|
|
3547
|
+
getInput: function getInput() {
|
|
3548
|
+
return inputRef.current;
|
|
3600
3549
|
}
|
|
3601
3550
|
};
|
|
3602
|
-
}
|
|
3603
|
-
registerInitFunc: function registerInitFunc(pathStr, f) {
|
|
3604
|
-
var _$$state$statesInstan;
|
|
3551
|
+
}, [rootRef, inputRef]);
|
|
3605
3552
|
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3553
|
+
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
3554
|
+
def: config.showStartIconVariant,
|
|
3555
|
+
active: showStartIcon
|
|
3556
|
+
}, {
|
|
3557
|
+
def: config.showEndIconVariant,
|
|
3558
|
+
active: showEndIcon
|
|
3559
|
+
}, {
|
|
3560
|
+
def: config.isDisabledVariant,
|
|
3561
|
+
active: isDisabled
|
|
3562
|
+
}));
|
|
3563
|
+
|
|
3564
|
+
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), config.startIconSlot && (_ref = {}, _ref[config.startIconSlot] = startIcon, _ref), config.endIconSlot && (_ref2 = {}, _ref2[config.endIconSlot] = endIcon, _ref2));
|
|
3565
|
+
|
|
3566
|
+
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
3567
|
+
props: {
|
|
3568
|
+
ref: rootRef,
|
|
3569
|
+
className: className,
|
|
3570
|
+
style: style
|
|
3616
3571
|
}
|
|
3617
|
-
}
|
|
3618
|
-
|
|
3572
|
+
}, _overrides[config.input] = {
|
|
3573
|
+
props: _extends({}, omit.apply(void 0, [rest].concat(plasmicClass.internalArgProps.filter(function (prop) {
|
|
3574
|
+
return prop !== "required";
|
|
3575
|
+
}), plasmicClass.internalVariantProps)), {
|
|
3576
|
+
disabled: isDisabled,
|
|
3577
|
+
ref: inputRef,
|
|
3578
|
+
className: inputClassName,
|
|
3579
|
+
style: inputStyle
|
|
3580
|
+
})
|
|
3581
|
+
}, _overrides);
|
|
3582
|
+
return {
|
|
3583
|
+
plasmicProps: {
|
|
3584
|
+
variants: variants,
|
|
3585
|
+
args: args,
|
|
3586
|
+
overrides: overrides
|
|
3587
|
+
}
|
|
3588
|
+
};
|
|
3589
|
+
}
|
|
3619
3590
|
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
var path = _ref4.path,
|
|
3623
|
-
specKey = _ref4.specKey;
|
|
3624
|
-
var spec = $$state.specsByKey[specKey];
|
|
3591
|
+
function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissable) {
|
|
3592
|
+
var _extends2, _overrides;
|
|
3625
3593
|
|
|
3626
|
-
|
|
3627
|
-
|
|
3594
|
+
if (outerRef === void 0) {
|
|
3595
|
+
outerRef = null;
|
|
3596
|
+
}
|
|
3628
3597
|
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3598
|
+
if (isDismissable === void 0) {
|
|
3599
|
+
isDismissable = true;
|
|
3600
|
+
}
|
|
3601
|
+
|
|
3602
|
+
var overlayRef = React.useRef(null);
|
|
3603
|
+
var onOverlayRef = mergeRefs(overlayRef, outerRef);
|
|
3604
|
+
var context = React.useContext(TriggeredOverlayContext);
|
|
3605
|
+
|
|
3606
|
+
if (!context) {
|
|
3607
|
+
// If no context, then we are not being correctly used. Either complain, or
|
|
3608
|
+
// exit early. It's okay to exit early and break the rules of React hooks
|
|
3609
|
+
// because we won't suddenly have the appropriate context anyway for this instance.
|
|
3610
|
+
if (PLUME_STRICT_MODE) {
|
|
3611
|
+
throw new Error("You can only use a triggered overlay with a TriggeredOverlayContext");
|
|
3635
3612
|
}
|
|
3636
|
-
});
|
|
3637
|
-
React__default.useLayoutEffect(function () {
|
|
3638
|
-
resetSpecs.forEach(function (_ref5) {
|
|
3639
|
-
var path = _ref5.path,
|
|
3640
|
-
spec = _ref5.spec;
|
|
3641
|
-
var newInit = initializeStateValue($$state, path, spec);
|
|
3642
3613
|
|
|
3643
|
-
|
|
3644
|
-
|
|
3614
|
+
return getDefaultPlasmicProps(plasmicClass, props);
|
|
3615
|
+
}
|
|
3645
3616
|
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
pathStr = _ref6.pathStr;
|
|
3654
|
-
$$state.specsByKey[pathStr].initFunc = f;
|
|
3655
|
-
});
|
|
3656
|
-
$$state.registrationsQueue = [];
|
|
3657
|
-
}, [$$state.registrationsQueue]); // Re-render if any value changed in one of these objects
|
|
3617
|
+
var children = props.children;
|
|
3618
|
+
var triggerRef = context.triggerRef,
|
|
3619
|
+
placement = context.placement,
|
|
3620
|
+
overlayMatchTriggerWidth = context.overlayMatchTriggerWidth,
|
|
3621
|
+
overlayMinTriggerWidth = context.overlayMinTriggerWidth,
|
|
3622
|
+
overlayWidth = context.overlayWidth,
|
|
3623
|
+
state = context.state; // Measure the width of the trigger to inform the width of the menu (below).
|
|
3658
3624
|
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
valtio.useSnapshot($$state.specsByKey, {
|
|
3663
|
-
sync: true
|
|
3664
|
-
});
|
|
3665
|
-
return $state;
|
|
3666
|
-
}
|
|
3625
|
+
var _React$useState = React.useState(false),
|
|
3626
|
+
isRendered = _React$useState[0],
|
|
3627
|
+
setRendered = _React$useState[1];
|
|
3667
3628
|
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
pathObj: transformPathStringToObj(spec.path),
|
|
3675
|
-
isRepeated: spec.path.split(".").some(function (part) {
|
|
3676
|
-
return part.endsWith("[]");
|
|
3677
|
-
})
|
|
3678
|
-
})];
|
|
3679
|
-
})),
|
|
3680
|
-
statesInstanceBySpec: new Map(),
|
|
3681
|
-
existingStates: new Map(),
|
|
3682
|
-
unsubscriptionsByState: {},
|
|
3683
|
-
props: undefined,
|
|
3684
|
-
registrationsQueue: []
|
|
3685
|
-
});
|
|
3686
|
-
$$state.props = mkUntrackedValue(props);
|
|
3687
|
-
var $state = create$StateProxy($$state, function (path, spec) {
|
|
3688
|
-
return {
|
|
3689
|
-
get: function get() {
|
|
3690
|
-
return _get($$state.stateValues, path);
|
|
3691
|
-
},
|
|
3692
|
-
set: function set$1(_t, _p, value) {
|
|
3693
|
-
set($$state.stateValues, path, mkUntrackedValue(value));
|
|
3629
|
+
var triggerWidth = triggerRef.current && (overlayMatchTriggerWidth || overlayMinTriggerWidth) ? triggerRef.current.offsetWidth : undefined;
|
|
3630
|
+
useIsomorphicLayoutEffect(function () {
|
|
3631
|
+
if (!isRendered && triggerRef.current && (overlayMatchTriggerWidth || overlayMinTriggerWidth)) {
|
|
3632
|
+
setRendered(true);
|
|
3633
|
+
}
|
|
3634
|
+
}, [triggerRef, isRendered, overlayMatchTriggerWidth, overlayMinTriggerWidth]);
|
|
3694
3635
|
|
|
3695
|
-
|
|
3696
|
-
|
|
3636
|
+
var _useOverlay = overlays.useOverlay({
|
|
3637
|
+
isOpen: state.isOpen,
|
|
3638
|
+
onClose: state.close,
|
|
3639
|
+
isDismissable: isDismissable,
|
|
3640
|
+
shouldCloseOnBlur: true
|
|
3641
|
+
}, overlayRef),
|
|
3642
|
+
overlayAriaProps = _useOverlay.overlayProps;
|
|
3697
3643
|
|
|
3698
|
-
|
|
3699
|
-
|
|
3644
|
+
var _useOverlayPosition = overlays.useOverlayPosition({
|
|
3645
|
+
targetRef: triggerRef,
|
|
3646
|
+
overlayRef: overlayRef,
|
|
3647
|
+
placement: placement != null ? placement : "bottom left",
|
|
3648
|
+
shouldFlip: true,
|
|
3649
|
+
isOpen: state.isOpen,
|
|
3650
|
+
onClose: state.close,
|
|
3651
|
+
containerPadding: 0
|
|
3652
|
+
}),
|
|
3653
|
+
overlayPositionProps = _useOverlayPosition.overlayProps,
|
|
3654
|
+
updatePosition = _useOverlayPosition.updatePosition,
|
|
3655
|
+
placementAxis = _useOverlayPosition.placement;
|
|
3700
3656
|
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3657
|
+
useIsomorphicLayoutEffect(function () {
|
|
3658
|
+
if (state.isOpen) {
|
|
3659
|
+
requestAnimationFrame(function () {
|
|
3660
|
+
updatePosition();
|
|
3661
|
+
});
|
|
3662
|
+
}
|
|
3663
|
+
}, [state.isOpen, updatePosition]);
|
|
3664
|
+
var overlayProps = mergeProps({
|
|
3665
|
+
style: {
|
|
3666
|
+
left: "auto",
|
|
3667
|
+
right: "auto",
|
|
3668
|
+
top: "auto",
|
|
3669
|
+
bottom: "auto",
|
|
3670
|
+
position: "absolute",
|
|
3671
|
+
width: overlayWidth != null ? overlayWidth : overlayMatchTriggerWidth ? triggerWidth : "auto",
|
|
3672
|
+
minWidth: overlayMinTriggerWidth ? triggerWidth : "auto"
|
|
3673
|
+
}
|
|
3674
|
+
}, overlayAriaProps, overlayPositionProps);
|
|
3705
3675
|
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3676
|
+
var variants = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalVariantProps)), mergeVariantToggles({
|
|
3677
|
+
def: config.isPlacedTopVariant,
|
|
3678
|
+
active: placementAxis === "top"
|
|
3679
|
+
}, {
|
|
3680
|
+
def: config.isPlacedBottomVariant,
|
|
3681
|
+
active: placementAxis === "bottom"
|
|
3682
|
+
}, {
|
|
3683
|
+
def: config.isPlacedLeftVariant,
|
|
3684
|
+
active: placementAxis === "left"
|
|
3685
|
+
}, {
|
|
3686
|
+
def: config.isPlacedRightVariant,
|
|
3687
|
+
active: placementAxis === "right"
|
|
3688
|
+
}));
|
|
3710
3689
|
|
|
3711
|
-
|
|
3712
|
-
|
|
3690
|
+
var args = _extends({}, pick.apply(void 0, [props].concat(plasmicClass.internalArgProps)), (_extends2 = {}, _extends2[config.contentSlot] = React.createElement(focus.FocusScope, {
|
|
3691
|
+
restoreFocus: true
|
|
3692
|
+
}, React.createElement(overlays.DismissButton, {
|
|
3693
|
+
onDismiss: state.close
|
|
3694
|
+
}), children), _extends2));
|
|
3713
3695
|
|
|
3714
|
-
|
|
3696
|
+
var overrides = (_overrides = {}, _overrides[config.root] = {
|
|
3697
|
+
props: mergeProps(overlayProps, getStyleProps(props), {
|
|
3698
|
+
ref: onOverlayRef
|
|
3699
|
+
}),
|
|
3700
|
+
wrap: function wrap(root) {
|
|
3701
|
+
if (typeof document !== "undefined") {
|
|
3702
|
+
return ReactDOM.createPortal(root, document.body);
|
|
3703
|
+
} else {
|
|
3704
|
+
// Possibly being invoked on the server during SSR; no need to
|
|
3705
|
+
// bother with a portal in that case.
|
|
3706
|
+
return root;
|
|
3707
|
+
}
|
|
3708
|
+
}
|
|
3709
|
+
}, _overrides);
|
|
3710
|
+
return {
|
|
3711
|
+
plasmicProps: {
|
|
3712
|
+
variants: variants,
|
|
3713
|
+
args: args,
|
|
3714
|
+
overrides: overrides
|
|
3715
|
+
}
|
|
3716
|
+
};
|
|
3715
3717
|
}
|
|
3716
3718
|
|
|
3717
3719
|
exports.get = _get;
|