|
|
|
@ -36589,22 +36589,6 @@ var useStore = (options) => {
|
|
|
|
|
const store = (0, import_react2.useContext)(StoreContext);
|
|
|
|
|
return (options == null ? void 0 : options.store) || store || getDefaultStore();
|
|
|
|
|
};
|
|
|
|
|
var Provider = ({
|
|
|
|
|
children,
|
|
|
|
|
store
|
|
|
|
|
}) => {
|
|
|
|
|
const storeRef = (0, import_react2.useRef)();
|
|
|
|
|
if (!store && !storeRef.current) {
|
|
|
|
|
storeRef.current = createStore();
|
|
|
|
|
}
|
|
|
|
|
return (0, import_react2.createElement)(
|
|
|
|
|
StoreContext.Provider,
|
|
|
|
|
{
|
|
|
|
|
value: store || storeRef.current
|
|
|
|
|
},
|
|
|
|
|
children
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
var isPromiseLike2 = (x) => typeof (x == null ? void 0 : x.then) === "function";
|
|
|
|
|
var use = import_react2.default.use || ((promise) => {
|
|
|
|
|
if (promise.status === "pending") {
|
|
|
|
@ -36684,11 +36668,13 @@ function useAtom(atom2, options) {
|
|
|
|
|
|
|
|
|
|
// src/Picker.tsx
|
|
|
|
|
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
|
|
|
|
|
function Picker({ $options, $isLoading, $url, $isEnabled, $selectedOption }) {
|
|
|
|
|
$options = $options || (0, import_react3.useMemo)(() => atom([]), []);
|
|
|
|
|
$isLoading = $isLoading || (0, import_react3.useMemo)(() => atom(true), []);
|
|
|
|
|
$isEnabled = $isEnabled || (0, import_react3.useMemo)(() => atom(true), []);
|
|
|
|
|
$selectedOption = $selectedOption || (0, import_react3.useMemo)(() => atom(""), []);
|
|
|
|
|
function Picker({
|
|
|
|
|
$url,
|
|
|
|
|
$options = (0, import_react3.useMemo)(() => atom([]), []),
|
|
|
|
|
$isLoading = (0, import_react3.useMemo)(() => atom(true), []),
|
|
|
|
|
$isEnabled = (0, import_react3.useMemo)(() => atom(true), []),
|
|
|
|
|
$selectedOption = (0, import_react3.useMemo)(() => atom(""), [])
|
|
|
|
|
}) {
|
|
|
|
|
const url = useAtomValue($url);
|
|
|
|
|
const options = useAtomValue($options);
|
|
|
|
|
const isLoading = useAtomValue($isLoading);
|
|
|
|
@ -36703,14 +36689,14 @@ function Picker({ $options, $isLoading, $url, $isEnabled, $selectedOption }) {
|
|
|
|
|
fetch(url).then((x) => x.json()).catch((err) => ["AAPL", "MSFT", "GOOG"]).then(optionsFetched);
|
|
|
|
|
}
|
|
|
|
|
}, [url, isEnabled]);
|
|
|
|
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Loading..." }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("select", { value: selectedOption, onChange: (e) => {
|
|
|
|
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Loading..." }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("select", { value: selectedOption, onChange: (e) => {
|
|
|
|
|
setSelectedOption(e.target.value);
|
|
|
|
|
}, children: [
|
|
|
|
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: "" }, ""),
|
|
|
|
|
options.map(
|
|
|
|
|
(date) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("option", { value: date, children: date }, date)
|
|
|
|
|
)
|
|
|
|
|
] }) }) });
|
|
|
|
|
] }) });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// src/App.module.css
|
|
|
|
|