@flickfyi/flkr 0.0.141 → 0.0.153
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/node_modules/@flickfyi/attestation/.turbo/turbo-build.log +7 -7
- package/node_modules/@flickfyi/biscuit/.turbo/turbo-build.log +7 -7
- package/node_modules/@flickfyi/core/.oxlintrc.json +2 -1
- package/node_modules/@flickfyi/core/.turbo/turbo-build.log +499 -92
- package/node_modules/@flickfyi/core/README.md +58 -4
- package/node_modules/@flickfyi/core/dist/index.cjs +1 -1
- package/node_modules/@flickfyi/core/dist/index.js +35 -24
- package/node_modules/@flickfyi/core/dist/kowalski/calculations.d.ts +17 -0
- package/node_modules/@flickfyi/core/dist/kowalski/calculator.d.ts +13 -0
- package/node_modules/@flickfyi/core/dist/kowalski/catalog.cjs +1 -0
- package/node_modules/@flickfyi/core/dist/kowalski/catalog.d.cts +962 -0
- package/node_modules/@flickfyi/core/dist/kowalski/catalog.d.ts +962 -0
- package/node_modules/@flickfyi/core/dist/kowalski/catalog.js +639 -0
- package/node_modules/@flickfyi/core/dist/kowalski/clocks.d.ts +4 -0
- package/node_modules/@flickfyi/core/dist/kowalski/date-time.d.ts +22 -0
- package/node_modules/@flickfyi/core/dist/kowalski/details.d.ts +7 -0
- package/node_modules/@flickfyi/core/dist/kowalski/everyday.d.ts +8 -0
- package/node_modules/@flickfyi/core/dist/kowalski/format.d.ts +4 -0
- package/node_modules/@flickfyi/core/dist/kowalski/frame.d.ts +161 -0
- package/node_modules/@flickfyi/core/dist/kowalski/index.cjs +21 -0
- package/node_modules/@flickfyi/core/dist/kowalski/index.d.cts +8 -0
- package/node_modules/@flickfyi/core/dist/kowalski/index.d.ts +8 -0
- package/node_modules/@flickfyi/core/dist/kowalski/index.js +7496 -0
- package/node_modules/@flickfyi/core/dist/kowalski/productivity.d.ts +5 -0
- package/node_modules/@flickfyi/core/dist/kowalski/recipe.d.ts +8 -0
- package/node_modules/@flickfyi/core/dist/kowalski/tools.d.ts +7 -0
- package/node_modules/@flickfyi/core/dist/kowalski/use-clock.d.ts +6 -0
- package/node_modules/@flickfyi/core/dist/kowalski/use-configured-feature.d.ts +19 -0
- package/node_modules/@flickfyi/core/dist/kowalski/use-feature-store.d.ts +15 -0
- package/node_modules/@flickfyi/core/dist/kowalski.css +506 -0
- package/node_modules/@flickfyi/core/dist/molecules/field/field.d.ts +8 -0
- package/node_modules/@flickfyi/core/dist/molecules/index.cjs +1 -1
- package/node_modules/@flickfyi/core/dist/molecules/index.d.cts +3 -0
- package/node_modules/@flickfyi/core/dist/molecules/index.d.ts +3 -0
- package/node_modules/@flickfyi/core/dist/molecules/index.js +88 -27
- package/node_modules/@flickfyi/core/dist/molecules/segmented/segmented.d.ts +10 -0
- package/node_modules/@flickfyi/core/dist/molecules/stepper/stepper.d.ts +10 -0
- package/node_modules/@flickfyi/core/dist/quantum/use-store.d.ts +7 -1
- package/node_modules/@flickfyi/core/dist/themes.css +2 -0
- package/node_modules/@flickfyi/core/examples/kowalski/bill-split/bill-split.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/bill-split/bill-split.tsx +17 -0
- package/node_modules/@flickfyi/core/examples/kowalski/bookmark/bookmark.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/bookmark/bookmark.tsx +23 -0
- package/node_modules/@flickfyi/core/examples/kowalski/budget/budget.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/budget/budget.tsx +26 -0
- package/node_modules/@flickfyi/core/examples/kowalski/calculator/calculator.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/calculator/calculator.tsx +24 -0
- package/node_modules/@flickfyi/core/examples/kowalski/checklist/checklist.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/checklist/checklist.tsx +26 -0
- package/node_modules/@flickfyi/core/examples/kowalski/color-palette/color-palette.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/color-palette/color-palette.tsx +22 -0
- package/node_modules/@flickfyi/core/examples/kowalski/contact/contact.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/contact/contact.tsx +23 -0
- package/node_modules/@flickfyi/core/examples/kowalski/countdown/countdown.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/countdown/countdown.tsx +23 -0
- package/node_modules/@flickfyi/core/examples/kowalski/event/event.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/event/event.tsx +24 -0
- package/node_modules/@flickfyi/core/examples/kowalski/expense/expense.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/expense/expense.tsx +23 -0
- package/node_modules/@flickfyi/core/examples/kowalski/goal/goal.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/goal/goal.tsx +24 -0
- package/node_modules/@flickfyi/core/examples/kowalski/habit/habit.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/habit/habit.tsx +23 -0
- package/node_modules/@flickfyi/core/examples/kowalski/ledger/ledger.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/ledger/ledger.tsx +25 -0
- package/node_modules/@flickfyi/core/examples/kowalski/note/note.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/note/note.tsx +22 -0
- package/node_modules/@flickfyi/core/examples/kowalski/poll/poll.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/poll/poll.tsx +26 -0
- package/node_modules/@flickfyi/core/examples/kowalski/random-picker/random-picker.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/random-picker/random-picker.tsx +23 -0
- package/node_modules/@flickfyi/core/examples/kowalski/rating/rating.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/rating/rating.tsx +19 -0
- package/node_modules/@flickfyi/core/examples/kowalski/recipe/recipe.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/recipe/recipe.tsx +120 -0
- package/node_modules/@flickfyi/core/examples/kowalski/reminder/reminder.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/reminder/reminder.tsx +23 -0
- package/node_modules/@flickfyi/core/examples/kowalski/rotation/rotation.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/rotation/rotation.tsx +27 -0
- package/node_modules/@flickfyi/core/examples/kowalski/scoreboard/scoreboard.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/scoreboard/scoreboard.tsx +26 -0
- package/node_modules/@flickfyi/core/examples/kowalski/shopping-list/shopping-list.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/shopping-list/shopping-list.tsx +27 -0
- package/node_modules/@flickfyi/core/examples/kowalski/task-board/task-board.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/task-board/task-board.tsx +27 -0
- package/node_modules/@flickfyi/core/examples/kowalski/theme.ts +3 -0
- package/node_modules/@flickfyi/core/examples/kowalski/time-zone/time-zone.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/time-zone/time-zone.tsx +22 -0
- package/node_modules/@flickfyi/core/examples/kowalski/timer/timer.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/timer/timer.tsx +23 -0
- package/node_modules/@flickfyi/core/examples/kowalski/trip/trip.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/trip/trip.tsx +26 -0
- package/node_modules/@flickfyi/core/examples/kowalski/unit-converter/unit-converter.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/unit-converter/unit-converter.tsx +24 -0
- package/node_modules/@flickfyi/core/examples/parrott/calculator/calculator.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/examples/parrott/checklist/checklist.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/examples/parrott/countdown/countdown.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/examples/parrott/counter/counter.stories.tsx +1 -0
- package/node_modules/@flickfyi/core/examples/parrott/fortune/fortune.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/examples/parrott/grid/grid.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/examples/parrott/kale-smoothie/kale-smoothie.stories.tsx +1 -0
- package/node_modules/@flickfyi/core/examples/parrott/list/list.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/examples/parrott/log/log.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/examples/parrott/timed-task/timed-task.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/examples/parrott/timer/timer.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/fixtures/native/host/project.yml +3 -0
- package/node_modules/@flickfyi/core/fixtures/native/src/catalog-features.tsx +88 -0
- package/node_modules/@flickfyi/core/package.json +35 -5
- package/node_modules/@flickfyi/core/package.tsgo.json +19 -1
- package/node_modules/@flickfyi/core/scripts/vite-globals.d.ts +2 -0
- package/node_modules/@flickfyi/core/src/generated-types.d.ts +1 -0
- package/node_modules/@flickfyi/core/src/kowalski/README.md +9 -0
- package/node_modules/@flickfyi/core/src/kowalski/calculations.ts +106 -0
- package/node_modules/@flickfyi/core/src/kowalski/calculator.ts +243 -0
- package/node_modules/@flickfyi/core/src/kowalski/catalog.ts +787 -0
- package/node_modules/@flickfyi/core/src/kowalski/clocks.tsx +464 -0
- package/node_modules/@flickfyi/core/src/kowalski/date-time.tsx +469 -0
- package/node_modules/@flickfyi/core/src/kowalski/details.tsx +1387 -0
- package/node_modules/@flickfyi/core/src/kowalski/everyday.tsx +652 -0
- package/node_modules/@flickfyi/core/src/kowalski/format.ts +48 -0
- package/node_modules/@flickfyi/core/src/kowalski/frame.tsx +351 -0
- package/node_modules/@flickfyi/core/src/kowalski/index.ts +23 -0
- package/node_modules/@flickfyi/core/src/kowalski/productivity.tsx +575 -0
- package/node_modules/@flickfyi/core/src/kowalski/recipe.tsx +555 -0
- package/node_modules/@flickfyi/core/src/kowalski/stories/composition.stories.tsx +47 -0
- package/node_modules/@flickfyi/core/src/kowalski/stories/composition.tsx +100 -0
- package/node_modules/@flickfyi/core/src/kowalski/tools.tsx +1213 -0
- package/node_modules/@flickfyi/core/src/kowalski/use-clock.ts +19 -0
- package/node_modules/@flickfyi/core/src/kowalski/use-configured-feature.ts +85 -0
- package/node_modules/@flickfyi/core/src/kowalski/use-feature-store.ts +119 -0
- package/node_modules/@flickfyi/core/src/molecules/field/field.tsx +34 -0
- package/node_modules/@flickfyi/core/src/molecules/index.ts +3 -0
- package/node_modules/@flickfyi/core/src/molecules/segmented/segmented.tsx +48 -0
- package/node_modules/@flickfyi/core/src/molecules/stepper/stepper.tsx +54 -0
- package/node_modules/@flickfyi/core/src/quantum/use-store.ts +41 -16
- package/node_modules/@flickfyi/core/tests/fly.test.ts +34 -7
- package/node_modules/@flickfyi/core/tests/kowalski-calculations.test.ts +60 -0
- package/node_modules/@flickfyi/core/tests/kowalski-calculator.test.ts +142 -0
- package/node_modules/@flickfyi/core/tests/kowalski-contracts.test.ts +223 -0
- package/node_modules/@flickfyi/core/tests/kowalski-date-time.test.tsx +462 -0
- package/node_modules/@flickfyi/core/tests/kowalski-features.test.tsx +2158 -0
- package/node_modules/@flickfyi/core/tests/kowalski-store.test.tsx +514 -0
- package/node_modules/@flickfyi/core/tests/preview-build.test.ts +1 -1
- package/node_modules/@flickfyi/core/tests/quantum-use-store.test.ts +53 -1
- package/node_modules/@flickfyi/core/tests/verify-tsgo-assets.test.ts +1 -1
- package/node_modules/@flickfyi/core/tsconfig.vite-dts.json +2 -1
- package/node_modules/@flickfyi/core/tsgo.bun.lock +111 -9
- package/node_modules/@flickfyi/core/tsgo.package.json +21 -3
- package/node_modules/@flickfyi/core/vite.config.ts +9 -5
- package/node_modules/@flickfyi/core/vitest.config.ts +1 -1
- package/node_modules/@flickfyi/http-message-sig/.turbo/turbo-build.log +7 -7
- package/node_modules/@flickfyi/identity/.turbo/turbo-build.log +8 -9
- package/node_modules/@flickfyi/lens/.turbo/turbo-build.log +7 -7
- package/node_modules/@flickfyi/photon/.turbo/turbo-build.log +4 -4
- package/node_modules/@flickfyi/photon/Sources/Photon/Components/Button.swift +29 -2
- package/node_modules/@flickfyi/photon/Sources/PhotonVersion/Resources/photon-version.json +1 -1
- package/node_modules/@flickfyi/photon/Tests/PhotonTests/Components/ButtonHostTests.swift +26 -0
- package/node_modules/@flickfyi/photon/Tests/PhotonTests/Fixtures/StyleX/catalog-features.styles.json +1 -0
- package/node_modules/@flickfyi/photon/Tests/PhotonTests/Fixtures/StyleX/catalog-native.styles.json +1 -1
- package/node_modules/@flickfyi/photon/Tests/PhotonTests/Fixtures/StyleX/catalog-scale.styles.json +1 -1
- package/node_modules/@flickfyi/photon/Tests/PhotonTests/Fixtures/StyleX/catalog-theme.styles.json +1 -1
- package/node_modules/@flickfyi/photon/Tests/PhotonTests/Fixtures/StyleX/catalog-typography.styles.json +1 -1
- package/node_modules/@flickfyi/photon/Tests/PhotonTests/Fixtures/StyleX/stylex-calculator.styles.json +1 -1
- package/node_modules/@flickfyi/photon/dist/globals.d.ts +5 -0
- package/node_modules/@flickfyi/photon/dist/version.cjs +1 -1
- package/node_modules/@flickfyi/photon/dist/version.js +1 -1
- package/node_modules/@flickfyi/photon/generated/react-swiftui.d.ts +1 -0
- package/node_modules/@flickfyi/photon/package.json +1 -1
- package/node_modules/@flickfyi/photon/src/globals.d.ts +5 -0
- package/node_modules/@flickfyi/rwsdk-extensions/.turbo/turbo-build.log +7 -7
- package/node_modules/@formatjs/fast-memoize/LICENSE.md +9 -0
- package/node_modules/@formatjs/fast-memoize/README.md +3 -0
- package/node_modules/@formatjs/fast-memoize/index.d.ts +35 -0
- package/node_modules/@formatjs/fast-memoize/index.js +69 -0
- package/node_modules/@formatjs/fast-memoize/index.js.map +1 -0
- package/node_modules/@formatjs/fast-memoize/package.json +25 -0
- package/node_modules/@formatjs/icu-messageformat-parser/LICENSE.md +9 -0
- package/node_modules/@formatjs/icu-messageformat-parser/README.md +38 -0
- package/node_modules/@formatjs/icu-messageformat-parser/index.d.ts +393 -0
- package/node_modules/@formatjs/icu-messageformat-parser/index.js +2187 -0
- package/node_modules/@formatjs/icu-messageformat-parser/index.js.map +1 -0
- package/node_modules/@formatjs/icu-messageformat-parser/manipulator.d.ts +175 -0
- package/node_modules/@formatjs/icu-messageformat-parser/manipulator.js +209 -0
- package/node_modules/@formatjs/icu-messageformat-parser/manipulator.js.map +1 -0
- package/node_modules/@formatjs/icu-messageformat-parser/no-parser.d.ts +183 -0
- package/node_modules/@formatjs/icu-messageformat-parser/no-parser.js +162 -0
- package/node_modules/@formatjs/icu-messageformat-parser/no-parser.js.map +1 -0
- package/node_modules/@formatjs/icu-messageformat-parser/package.json +21 -0
- package/node_modules/@formatjs/icu-messageformat-parser/printer.d.ts +154 -0
- package/node_modules/@formatjs/icu-messageformat-parser/printer.js +224 -0
- package/node_modules/@formatjs/icu-messageformat-parser/printer.js.map +1 -0
- package/node_modules/@formatjs/icu-skeleton-parser/LICENSE.md +9 -0
- package/node_modules/@formatjs/icu-skeleton-parser/README.md +1 -0
- package/node_modules/@formatjs/icu-skeleton-parser/index.d.ts +67 -0
- package/node_modules/@formatjs/icu-skeleton-parser/index.js +380 -0
- package/node_modules/@formatjs/icu-skeleton-parser/index.js.map +1 -0
- package/node_modules/@formatjs/icu-skeleton-parser/package.json +15 -0
- package/node_modules/@formatjs/intl/LICENSE.md +9 -0
- package/node_modules/@formatjs/intl/README.md +3 -0
- package/node_modules/@formatjs/intl/index.d.ts +499 -0
- package/node_modules/@formatjs/intl/index.js +595 -0
- package/node_modules/@formatjs/intl/index.js.map +1 -0
- package/node_modules/@formatjs/intl/package.json +37 -0
- package/node_modules/decimal.js/LICENCE.md +23 -0
- package/node_modules/decimal.js/README.md +246 -0
- package/node_modules/decimal.js/decimal.d.ts +301 -0
- package/node_modules/decimal.js/decimal.js +4951 -0
- package/node_modules/decimal.js/decimal.mjs +4914 -0
- package/node_modules/decimal.js/package.json +55 -0
- package/node_modules/format-quantity/LICENSE +21 -0
- package/node_modules/format-quantity/README.md +181 -0
- package/node_modules/format-quantity/dist/cjs/format-quantity.cjs.development.d.ts +131 -0
- package/node_modules/format-quantity/dist/cjs/format-quantity.cjs.development.js +214 -0
- package/node_modules/format-quantity/dist/cjs/format-quantity.cjs.development.js.map +1 -0
- package/node_modules/format-quantity/dist/cjs/format-quantity.cjs.production.d.ts +131 -0
- package/node_modules/format-quantity/dist/cjs/format-quantity.cjs.production.js +2 -0
- package/node_modules/format-quantity/dist/cjs/format-quantity.cjs.production.js.map +1 -0
- package/node_modules/format-quantity/dist/cjs/index.d.ts +1 -0
- package/node_modules/format-quantity/dist/cjs/index.js +6 -0
- package/node_modules/format-quantity/dist/format-quantity.d.mts +131 -0
- package/node_modules/format-quantity/dist/format-quantity.legacy-esm.d.ts +131 -0
- package/node_modules/format-quantity/dist/format-quantity.legacy-esm.js +268 -0
- package/node_modules/format-quantity/dist/format-quantity.legacy-esm.js.map +1 -0
- package/node_modules/format-quantity/dist/format-quantity.mjs +208 -0
- package/node_modules/format-quantity/dist/format-quantity.mjs.map +1 -0
- package/node_modules/format-quantity/dist/format-quantity.production.d.mts +131 -0
- package/node_modules/format-quantity/dist/format-quantity.production.mjs +2 -0
- package/node_modules/format-quantity/dist/format-quantity.production.mjs.map +1 -0
- package/node_modules/format-quantity/dist/format-quantity.umd.min.js +3 -0
- package/node_modules/format-quantity/dist/format-quantity.umd.min.js.map +1 -0
- package/node_modules/format-quantity/package.json +81 -0
- package/node_modules/intl-messageformat/LICENSE.md +33 -0
- package/node_modules/intl-messageformat/README.md +3 -0
- package/node_modules/intl-messageformat/index.d.ts +177 -0
- package/node_modules/intl-messageformat/index.js +327 -0
- package/node_modules/intl-messageformat/index.js.map +1 -0
- package/node_modules/intl-messageformat/intl-messageformat.iife.js +2819 -0
- package/node_modules/intl-messageformat/package.json +40 -0
- package/node_modules/numeric-quantity/LICENSE +21 -0
- package/node_modules/numeric-quantity/README.md +306 -0
- package/node_modules/numeric-quantity/dist/cjs/index.d.ts +1 -0
- package/node_modules/numeric-quantity/dist/cjs/index.js +6 -0
- package/node_modules/numeric-quantity/dist/cjs/numeric-quantity.cjs.development.d.ts +293 -0
- package/node_modules/numeric-quantity/dist/cjs/numeric-quantity.cjs.development.js +579 -0
- package/node_modules/numeric-quantity/dist/cjs/numeric-quantity.cjs.development.js.map +1 -0
- package/node_modules/numeric-quantity/dist/cjs/numeric-quantity.cjs.production.d.ts +293 -0
- package/node_modules/numeric-quantity/dist/cjs/numeric-quantity.cjs.production.js +2 -0
- package/node_modules/numeric-quantity/dist/cjs/numeric-quantity.cjs.production.js.map +1 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.d.mts +293 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.iife.umd.min.js +2 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.iife.umd.min.js.map +1 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.legacy-esm.d.ts +293 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.legacy-esm.js +622 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.legacy-esm.js.map +1 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.mjs +564 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.mjs.map +1 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.production.d.mts +293 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.production.mjs +2 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.production.mjs.map +1 -0
- package/node_modules/numeric-quantity/package.json +72 -0
- package/node_modules/validator/LICENSE +20 -0
- package/node_modules/validator/README.md +269 -0
- package/node_modules/validator/es/index.js +218 -0
- package/node_modules/validator/es/lib/alpha.js +151 -0
- package/node_modules/validator/es/lib/blacklist.js +5 -0
- package/node_modules/validator/es/lib/contains.js +15 -0
- package/node_modules/validator/es/lib/equals.js +5 -0
- package/node_modules/validator/es/lib/escape.js +5 -0
- package/node_modules/validator/es/lib/isAbaRouting.js +15 -0
- package/node_modules/validator/es/lib/isAfter.js +10 -0
- package/node_modules/validator/es/lib/isAlpha.js +23 -0
- package/node_modules/validator/es/lib/isAlphanumeric.js +23 -0
- package/node_modules/validator/es/lib/isAscii.js +10 -0
- package/node_modules/validator/es/lib/isBIC.js +16 -0
- package/node_modules/validator/es/lib/isBase32.js +15 -0
- package/node_modules/validator/es/lib/isBase58.js +8 -0
- package/node_modules/validator/es/lib/isBase64.js +23 -0
- package/node_modules/validator/es/lib/isBefore.js +10 -0
- package/node_modules/validator/es/lib/isBoolean.js +15 -0
- package/node_modules/validator/es/lib/isBtcAddress.js +7 -0
- package/node_modules/validator/es/lib/isByteLength.js +19 -0
- package/node_modules/validator/es/lib/isCreditCard.js +43 -0
- package/node_modules/validator/es/lib/isCurrency.js +74 -0
- package/node_modules/validator/es/lib/isDataURI.js +31 -0
- package/node_modules/validator/es/lib/isDate.js +93 -0
- package/node_modules/validator/es/lib/isDecimal.js +22 -0
- package/node_modules/validator/es/lib/isDivisibleBy.js +6 -0
- package/node_modules/validator/es/lib/isEAN.js +70 -0
- package/node_modules/validator/es/lib/isEmail.js +165 -0
- package/node_modules/validator/es/lib/isEmpty.js +10 -0
- package/node_modules/validator/es/lib/isEthereumAddress.js +6 -0
- package/node_modules/validator/es/lib/isFQDN.js +67 -0
- package/node_modules/validator/es/lib/isFloat.js +14 -0
- package/node_modules/validator/es/lib/isFullWidth.js +6 -0
- package/node_modules/validator/es/lib/isHSL.js +13 -0
- package/node_modules/validator/es/lib/isHalfWidth.js +6 -0
- package/node_modules/validator/es/lib/isHash.js +21 -0
- package/node_modules/validator/es/lib/isHexColor.js +13 -0
- package/node_modules/validator/es/lib/isHexadecimal.js +6 -0
- package/node_modules/validator/es/lib/isIBAN.js +171 -0
- package/node_modules/validator/es/lib/isIMEI.js +40 -0
- package/node_modules/validator/es/lib/isIP.js +58 -0
- package/node_modules/validator/es/lib/isIPRange.js +41 -0
- package/node_modules/validator/es/lib/isISBN.js +47 -0
- package/node_modules/validator/es/lib/isISIN.js +55 -0
- package/node_modules/validator/es/lib/isISO15924.js +9 -0
- package/node_modules/validator/es/lib/isISO31661Alpha2.js +21 -0
- package/node_modules/validator/es/lib/isISO31661Alpha3.js +20 -0
- package/node_modules/validator/es/lib/isISO31661Numeric.js +8 -0
- package/node_modules/validator/es/lib/isISO4217.js +9 -0
- package/node_modules/validator/es/lib/isISO6346.js +28 -0
- package/node_modules/validator/es/lib/isISO6391.js +6 -0
- package/node_modules/validator/es/lib/isISO8601.js +42 -0
- package/node_modules/validator/es/lib/isISRC.js +8 -0
- package/node_modules/validator/es/lib/isISSN.js +19 -0
- package/node_modules/validator/es/lib/isIdentityCard.js +407 -0
- package/node_modules/validator/es/lib/isIn.js +23 -0
- package/node_modules/validator/es/lib/isInt.js +19 -0
- package/node_modules/validator/es/lib/isJSON.js +26 -0
- package/node_modules/validator/es/lib/isJWT.js +15 -0
- package/node_modules/validator/es/lib/isLatLong.js +21 -0
- package/node_modules/validator/es/lib/isLength.js +27 -0
- package/node_modules/validator/es/lib/isLicensePlate.js +58 -0
- package/node_modules/validator/es/lib/isLocale.js +107 -0
- package/node_modules/validator/es/lib/isLowercase.js +5 -0
- package/node_modules/validator/es/lib/isLuhnNumber.js +25 -0
- package/node_modules/validator/es/lib/isMACAddress.js +36 -0
- package/node_modules/validator/es/lib/isMD5.js +6 -0
- package/node_modules/validator/es/lib/isMagnetURI.js +9 -0
- package/node_modules/validator/es/lib/isMailtoURI.js +75 -0
- package/node_modules/validator/es/lib/isMimeType.js +40 -0
- package/node_modules/validator/es/lib/isMobilePhone.js +212 -0
- package/node_modules/validator/es/lib/isMongoId.js +6 -0
- package/node_modules/validator/es/lib/isMultibyte.js +10 -0
- package/node_modules/validator/es/lib/isNumeric.js +10 -0
- package/node_modules/validator/es/lib/isOctal.js +6 -0
- package/node_modules/validator/es/lib/isPassportNumber.js +145 -0
- package/node_modules/validator/es/lib/isPort.js +8 -0
- package/node_modules/validator/es/lib/isPostalCode.js +100 -0
- package/node_modules/validator/es/lib/isRFC3339.js +21 -0
- package/node_modules/validator/es/lib/isRgbColor.js +34 -0
- package/node_modules/validator/es/lib/isSemVer.js +14 -0
- package/node_modules/validator/es/lib/isSlug.js +6 -0
- package/node_modules/validator/es/lib/isStrongPassword.js +90 -0
- package/node_modules/validator/es/lib/isSurrogatePair.js +6 -0
- package/node_modules/validator/es/lib/isTaxID.js +1407 -0
- package/node_modules/validator/es/lib/isTime.js +22 -0
- package/node_modules/validator/es/lib/isULID.js +5 -0
- package/node_modules/validator/es/lib/isURL.js +241 -0
- package/node_modules/validator/es/lib/isUUID.js +23 -0
- package/node_modules/validator/es/lib/isUppercase.js +5 -0
- package/node_modules/validator/es/lib/isVAT.js +264 -0
- package/node_modules/validator/es/lib/isVariableWidth.js +7 -0
- package/node_modules/validator/es/lib/isWhitelisted.js +10 -0
- package/node_modules/validator/es/lib/ltrim.js +7 -0
- package/node_modules/validator/es/lib/matches.js +8 -0
- package/node_modules/validator/es/lib/normalizeEmail.js +131 -0
- package/node_modules/validator/es/lib/rtrim.js +15 -0
- package/node_modules/validator/es/lib/stripLow.js +7 -0
- package/node_modules/validator/es/lib/toBoolean.js +8 -0
- package/node_modules/validator/es/lib/toDate.js +6 -0
- package/node_modules/validator/es/lib/toFloat.js +5 -0
- package/node_modules/validator/es/lib/toInt.js +5 -0
- package/node_modules/validator/es/lib/trim.js +5 -0
- package/node_modules/validator/es/lib/unescape.js +8 -0
- package/node_modules/validator/es/lib/util/algorithms.js +79 -0
- package/node_modules/validator/es/lib/util/assertString.js +4 -0
- package/node_modules/validator/es/lib/util/checkHost.js +12 -0
- package/node_modules/validator/es/lib/util/includesArray.js +6 -0
- package/node_modules/validator/es/lib/util/includesString.js +4 -0
- package/node_modules/validator/es/lib/util/merge.js +14 -0
- package/node_modules/validator/es/lib/util/multilineRegex.js +12 -0
- package/node_modules/validator/es/lib/util/nullUndefinedCheck.js +3 -0
- package/node_modules/validator/es/lib/util/toString.js +13 -0
- package/node_modules/validator/es/lib/util/typeOf.js +10 -0
- package/node_modules/validator/es/lib/whitelist.js +5 -0
- package/node_modules/validator/index.js +229 -0
- package/node_modules/validator/lib/alpha.js +157 -0
- package/node_modules/validator/lib/blacklist.js +14 -0
- package/node_modules/validator/lib/contains.js +24 -0
- package/node_modules/validator/lib/equals.js +14 -0
- package/node_modules/validator/lib/escape.js +14 -0
- package/node_modules/validator/lib/isAbaRouting.js +23 -0
- package/node_modules/validator/lib/isAfter.js +19 -0
- package/node_modules/validator/lib/isAlpha.js +31 -0
- package/node_modules/validator/lib/isAlphanumeric.js +31 -0
- package/node_modules/validator/lib/isAscii.js +18 -0
- package/node_modules/validator/lib/isBIC.js +24 -0
- package/node_modules/validator/lib/isBase32.js +24 -0
- package/node_modules/validator/lib/isBase58.js +16 -0
- package/node_modules/validator/lib/isBase64.js +32 -0
- package/node_modules/validator/lib/isBefore.js +19 -0
- package/node_modules/validator/lib/isBoolean.js +24 -0
- package/node_modules/validator/lib/isBtcAddress.js +16 -0
- package/node_modules/validator/lib/isByteLength.js +27 -0
- package/node_modules/validator/lib/isCreditCard.js +52 -0
- package/node_modules/validator/lib/isCurrency.js +83 -0
- package/node_modules/validator/lib/isDataURI.js +40 -0
- package/node_modules/validator/lib/isDate.js +102 -0
- package/node_modules/validator/lib/isDecimal.js +31 -0
- package/node_modules/validator/lib/isDivisibleBy.js +15 -0
- package/node_modules/validator/lib/isEAN.js +78 -0
- package/node_modules/validator/lib/isEmail.js +174 -0
- package/node_modules/validator/lib/isEmpty.js +19 -0
- package/node_modules/validator/lib/isEthereumAddress.js +15 -0
- package/node_modules/validator/lib/isFQDN.js +76 -0
- package/node_modules/validator/lib/isFloat.js +22 -0
- package/node_modules/validator/lib/isFullWidth.js +14 -0
- package/node_modules/validator/lib/isHSL.js +22 -0
- package/node_modules/validator/lib/isHalfWidth.js +14 -0
- package/node_modules/validator/lib/isHash.js +30 -0
- package/node_modules/validator/lib/isHexColor.js +22 -0
- package/node_modules/validator/lib/isHexadecimal.js +15 -0
- package/node_modules/validator/lib/isIBAN.js +178 -0
- package/node_modules/validator/lib/isIMEI.js +49 -0
- package/node_modules/validator/lib/isIP.js +67 -0
- package/node_modules/validator/lib/isIPRange.js +50 -0
- package/node_modules/validator/lib/isISBN.js +56 -0
- package/node_modules/validator/lib/isISIN.js +64 -0
- package/node_modules/validator/lib/isISO15924.js +16 -0
- package/node_modules/validator/lib/isISO31661Alpha2.js +28 -0
- package/node_modules/validator/lib/isISO31661Alpha3.js +28 -0
- package/node_modules/validator/lib/isISO31661Numeric.js +16 -0
- package/node_modules/validator/lib/isISO4217.js +16 -0
- package/node_modules/validator/lib/isISO6346.js +35 -0
- package/node_modules/validator/lib/isISO6391.js +15 -0
- package/node_modules/validator/lib/isISO8601.js +50 -0
- package/node_modules/validator/lib/isISRC.js +16 -0
- package/node_modules/validator/lib/isISSN.js +28 -0
- package/node_modules/validator/lib/isIdentityCard.js +416 -0
- package/node_modules/validator/lib/isIn.js +32 -0
- package/node_modules/validator/lib/isInt.js +28 -0
- package/node_modules/validator/lib/isJSON.js +35 -0
- package/node_modules/validator/lib/isJWT.js +24 -0
- package/node_modules/validator/lib/isLatLong.js +30 -0
- package/node_modules/validator/lib/isLength.js +35 -0
- package/node_modules/validator/lib/isLicensePlate.js +67 -0
- package/node_modules/validator/lib/isLocale.js +115 -0
- package/node_modules/validator/lib/isLowercase.js +14 -0
- package/node_modules/validator/lib/isLuhnNumber.js +34 -0
- package/node_modules/validator/lib/isMACAddress.js +45 -0
- package/node_modules/validator/lib/isMD5.js +15 -0
- package/node_modules/validator/lib/isMagnetURI.js +18 -0
- package/node_modules/validator/lib/isMailtoURI.js +84 -0
- package/node_modules/validator/lib/isMimeType.js +48 -0
- package/node_modules/validator/lib/isMobilePhone.js +219 -0
- package/node_modules/validator/lib/isMongoId.js +15 -0
- package/node_modules/validator/lib/isMultibyte.js +18 -0
- package/node_modules/validator/lib/isNumeric.js +19 -0
- package/node_modules/validator/lib/isOctal.js +15 -0
- package/node_modules/validator/lib/isPassportNumber.js +152 -0
- package/node_modules/validator/lib/isPort.js +17 -0
- package/node_modules/validator/lib/isPostalCode.js +107 -0
- package/node_modules/validator/lib/isRFC3339.js +29 -0
- package/node_modules/validator/lib/isRgbColor.js +42 -0
- package/node_modules/validator/lib/isSemVer.js +22 -0
- package/node_modules/validator/lib/isSlug.js +15 -0
- package/node_modules/validator/lib/isStrongPassword.js +99 -0
- package/node_modules/validator/lib/isSurrogatePair.js +15 -0
- package/node_modules/validator/lib/isTaxID.js +1417 -0
- package/node_modules/validator/lib/isTime.js +31 -0
- package/node_modules/validator/lib/isULID.js +14 -0
- package/node_modules/validator/lib/isURL.js +249 -0
- package/node_modules/validator/lib/isUUID.js +32 -0
- package/node_modules/validator/lib/isUppercase.js +14 -0
- package/node_modules/validator/lib/isVAT.js +274 -0
- package/node_modules/validator/lib/isVariableWidth.js +16 -0
- package/node_modules/validator/lib/isWhitelisted.js +19 -0
- package/node_modules/validator/lib/ltrim.js +16 -0
- package/node_modules/validator/lib/matches.js +17 -0
- package/node_modules/validator/lib/normalizeEmail.js +140 -0
- package/node_modules/validator/lib/rtrim.js +24 -0
- package/node_modules/validator/lib/stripLow.js +16 -0
- package/node_modules/validator/lib/toBoolean.js +17 -0
- package/node_modules/validator/lib/toDate.js +15 -0
- package/node_modules/validator/lib/toFloat.js +14 -0
- package/node_modules/validator/lib/toInt.js +14 -0
- package/node_modules/validator/lib/trim.js +14 -0
- package/node_modules/validator/lib/unescape.js +17 -0
- package/node_modules/validator/lib/util/algorithms.js +88 -0
- package/node_modules/validator/lib/util/assertString.js +12 -0
- package/node_modules/validator/lib/util/checkHost.js +20 -0
- package/node_modules/validator/lib/util/includesArray.js +14 -0
- package/node_modules/validator/lib/util/includesString.js +12 -0
- package/node_modules/validator/lib/util/merge.js +22 -0
- package/node_modules/validator/lib/util/multilineRegex.js +20 -0
- package/node_modules/validator/lib/util/nullUndefinedCheck.js +11 -0
- package/node_modules/validator/lib/util/toString.js +21 -0
- package/node_modules/validator/lib/util/typeOf.js +18 -0
- package/node_modules/validator/lib/whitelist.js +14 -0
- package/node_modules/validator/package.json +76 -0
- package/node_modules/validator/validator.js +5808 -0
- package/node_modules/validator/validator.min.js +23 -0
- package/package.json +3 -3
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
import { Flex, Icon, Text } from '@flickfyi/core'
|
|
2
|
+
import { Button, Input, Picker } from '@flickfyi/core/atoms'
|
|
3
|
+
import {
|
|
4
|
+
Choice,
|
|
5
|
+
completedTaskStyle,
|
|
6
|
+
Field,
|
|
7
|
+
List,
|
|
8
|
+
Segmented,
|
|
9
|
+
Stat,
|
|
10
|
+
Stepper,
|
|
11
|
+
} from '@flickfyi/core/molecules'
|
|
12
|
+
import * as stylex from '@stylexjs/stylex'
|
|
13
|
+
import { useState } from 'react'
|
|
14
|
+
|
|
15
|
+
import { size, space } from '~/themes/scale.stylex'
|
|
16
|
+
import { appearance, button, roles } from '~/themes/shared'
|
|
17
|
+
import { colors } from '~/themes/tokens.stylex'
|
|
18
|
+
|
|
19
|
+
import { formatCurrency } from './calculations'
|
|
20
|
+
import { kowalskiCatalog, type KowalskiInput } from './catalog'
|
|
21
|
+
import { format, parseNumberInput } from './format'
|
|
22
|
+
import {
|
|
23
|
+
FeatureAction,
|
|
24
|
+
FeatureFacts,
|
|
25
|
+
FeatureField,
|
|
26
|
+
FeatureFrame,
|
|
27
|
+
FeatureProgress,
|
|
28
|
+
FeatureWell,
|
|
29
|
+
layout,
|
|
30
|
+
} from './frame'
|
|
31
|
+
import { useConfiguredFeature } from './use-configured-feature'
|
|
32
|
+
|
|
33
|
+
export function Budget(input: KowalskiInput<'budget'>) {
|
|
34
|
+
const props = kowalskiCatalog.budget.props.parse(input)
|
|
35
|
+
const categories = props.categories
|
|
36
|
+
const schema = kowalskiCatalog.budget.storeSchema
|
|
37
|
+
const store = useConfiguredFeature({
|
|
38
|
+
name: props.id ?? 'KowalskiBudget',
|
|
39
|
+
revision: props.revision,
|
|
40
|
+
schema,
|
|
41
|
+
scope: props.scope,
|
|
42
|
+
seed: schema.parse({}),
|
|
43
|
+
})
|
|
44
|
+
const [categoryId, setCategoryId] = useState(categories[0].id)
|
|
45
|
+
const [amount, setAmount] = useState({ value: '' })
|
|
46
|
+
const money = (value: number) => formatCurrency(value, props.currency)
|
|
47
|
+
const spentOn = (id: string) => store.value[`spent_${id}`] ?? 0
|
|
48
|
+
const spent = categories.reduce((total, category) => total + spentOn(category.id), 0)
|
|
49
|
+
const limit = categories.reduce((total, category) => total + category.limit, 0)
|
|
50
|
+
const left = limit - spent
|
|
51
|
+
const category = categories.find(option => option.id === categoryId) ?? categories[0]
|
|
52
|
+
const parsed = parseNumberInput(amount.value, props.currency)
|
|
53
|
+
const valid =
|
|
54
|
+
Number.isFinite(parsed) && parsed > 0 && parsed <= 1e12 - spentOn(category.id)
|
|
55
|
+
return (
|
|
56
|
+
<FeatureFrame
|
|
57
|
+
onRetry={store.retry}
|
|
58
|
+
notice={store.error}
|
|
59
|
+
component="budget"
|
|
60
|
+
title={props.title}
|
|
61
|
+
trailing={
|
|
62
|
+
<Text {...stylex.props(roles.muted, left < 0 && layout.notice)}>
|
|
63
|
+
{left < 0 ? `${money(-left)} over` : `${money(left)} left`}
|
|
64
|
+
</Text>
|
|
65
|
+
}
|
|
66
|
+
>
|
|
67
|
+
<FeatureWell>
|
|
68
|
+
<Stat>
|
|
69
|
+
<Stat.Value>{money(spent)}</Stat.Value>
|
|
70
|
+
<Stat.Caption>{`Spent of ${money(limit)}`}</Stat.Caption>
|
|
71
|
+
</Stat>
|
|
72
|
+
<FeatureProgress component="budget" value={Math.min(1, spent / limit)} />
|
|
73
|
+
</FeatureWell>
|
|
74
|
+
<FeatureFacts>
|
|
75
|
+
{categories.map(option => (
|
|
76
|
+
<List.Item
|
|
77
|
+
description={
|
|
78
|
+
spentOn(option.id) > option.limit
|
|
79
|
+
? `${money(spentOn(option.id) - option.limit)} over`
|
|
80
|
+
: undefined
|
|
81
|
+
}
|
|
82
|
+
key={option.id}
|
|
83
|
+
label={option.label}
|
|
84
|
+
trailing={`${money(spentOn(option.id))} of ${money(option.limit)}`}
|
|
85
|
+
/>
|
|
86
|
+
))}
|
|
87
|
+
</FeatureFacts>
|
|
88
|
+
<Field
|
|
89
|
+
error={amount.value && !valid && 'Enter an amount within the supported range.'}
|
|
90
|
+
label="Add spending"
|
|
91
|
+
>
|
|
92
|
+
<Picker label="Category" value={category.id} onChange={setCategoryId}>
|
|
93
|
+
{categories.map(option => (
|
|
94
|
+
<Text key={option.id} value={option.id}>
|
|
95
|
+
{option.label}
|
|
96
|
+
</Text>
|
|
97
|
+
))}
|
|
98
|
+
</Picker>
|
|
99
|
+
<Input
|
|
100
|
+
placeholder="Amount"
|
|
101
|
+
value={amount.value}
|
|
102
|
+
onChange={value => setAmount({ value })}
|
|
103
|
+
style={[layout.input]}
|
|
104
|
+
/>
|
|
105
|
+
</Field>
|
|
106
|
+
<FeatureAction
|
|
107
|
+
component="budget"
|
|
108
|
+
disabled={!valid || !store.ready || store.saving}
|
|
109
|
+
icon="plus"
|
|
110
|
+
size="lg"
|
|
111
|
+
variant="primary"
|
|
112
|
+
onClick={() =>
|
|
113
|
+
store.set(
|
|
114
|
+
current => ({
|
|
115
|
+
[`spent_${category.id}`]: (current[`spent_${category.id}`] ?? 0) + parsed,
|
|
116
|
+
}),
|
|
117
|
+
() => setAmount(current => (current === amount ? { value: '' } : current))
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
>
|
|
121
|
+
{`Add to ${category.label}`}
|
|
122
|
+
</FeatureAction>
|
|
123
|
+
</FeatureFrame>
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function Scoreboard(input: KowalskiInput<'scoreboard'>) {
|
|
128
|
+
const props = kowalskiCatalog.scoreboard.props.parse(input)
|
|
129
|
+
const players = props.players
|
|
130
|
+
const schema = kowalskiCatalog.scoreboard.storeSchema
|
|
131
|
+
const store = useConfiguredFeature({
|
|
132
|
+
name: props.id ?? 'KowalskiScoreboard',
|
|
133
|
+
revision: props.revision,
|
|
134
|
+
schema,
|
|
135
|
+
scope: props.scope,
|
|
136
|
+
seed: schema.parse({}),
|
|
137
|
+
})
|
|
138
|
+
const scoreOf = (id: string) => store.value[`score_${id}`] ?? 0
|
|
139
|
+
const best = Math.max(...players.map(player => scoreOf(player.id)))
|
|
140
|
+
const leaders = players.filter(player => scoreOf(player.id) === best)
|
|
141
|
+
const started = players.some(player => scoreOf(player.id) !== 0)
|
|
142
|
+
const change = (id: string, direction: -1 | 1) =>
|
|
143
|
+
store.set(current => ({
|
|
144
|
+
[`score_${id}`]: (current[`score_${id}`] ?? 0) + direction * props.step,
|
|
145
|
+
}))
|
|
146
|
+
return (
|
|
147
|
+
<FeatureFrame
|
|
148
|
+
onRetry={store.retry}
|
|
149
|
+
notice={store.error}
|
|
150
|
+
component="scoreboard"
|
|
151
|
+
title={props.title}
|
|
152
|
+
trailing={
|
|
153
|
+
<Text
|
|
154
|
+
{...stylex.props(
|
|
155
|
+
roles.muted,
|
|
156
|
+
started && leaders.length === 1 && appearance.accent
|
|
157
|
+
)}
|
|
158
|
+
>
|
|
159
|
+
{started
|
|
160
|
+
? leaders.length === 1
|
|
161
|
+
? `${leaders[0].label} leads`
|
|
162
|
+
: `Tied at ${format.formatNumber(best)}`
|
|
163
|
+
: 'No scores yet'}
|
|
164
|
+
</Text>
|
|
165
|
+
}
|
|
166
|
+
>
|
|
167
|
+
<FeatureFacts>
|
|
168
|
+
{players.map(player => (
|
|
169
|
+
<List.Item
|
|
170
|
+
key={player.id}
|
|
171
|
+
label={player.label}
|
|
172
|
+
trailing={
|
|
173
|
+
<Stepper
|
|
174
|
+
decrementDisabled={!store.ready}
|
|
175
|
+
decrementLabel={`Lower ${player.label}`}
|
|
176
|
+
incrementDisabled={!store.ready}
|
|
177
|
+
incrementLabel={`Raise ${player.label}`}
|
|
178
|
+
onDecrement={() => change(player.id, -1)}
|
|
179
|
+
onIncrement={() => change(player.id, 1)}
|
|
180
|
+
>
|
|
181
|
+
<Text {...stylex.props(roles.h2, everydayStyles.score)}>
|
|
182
|
+
{format.formatNumber(scoreOf(player.id))}
|
|
183
|
+
</Text>
|
|
184
|
+
</Stepper>
|
|
185
|
+
}
|
|
186
|
+
/>
|
|
187
|
+
))}
|
|
188
|
+
</FeatureFacts>
|
|
189
|
+
{started && (
|
|
190
|
+
<FeatureAction
|
|
191
|
+
component="scoreboard"
|
|
192
|
+
disabled={!store.ready}
|
|
193
|
+
icon="arrow.counterclockwise"
|
|
194
|
+
onClick={() =>
|
|
195
|
+
store.set(() =>
|
|
196
|
+
Object.fromEntries(players.map(player => [`score_${player.id}`, 0]))
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
>
|
|
200
|
+
New game
|
|
201
|
+
</FeatureAction>
|
|
202
|
+
)}
|
|
203
|
+
</FeatureFrame>
|
|
204
|
+
)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export function TaskBoard(input: KowalskiInput<'taskBoard'>) {
|
|
208
|
+
const props = kowalskiCatalog.taskBoard.props.parse(input)
|
|
209
|
+
const tasks = props.tasks
|
|
210
|
+
const schema = kowalskiCatalog.taskBoard.storeSchema
|
|
211
|
+
const store = useConfiguredFeature({
|
|
212
|
+
name: props.id ?? 'KowalskiTaskBoard',
|
|
213
|
+
revision: props.revision,
|
|
214
|
+
schema,
|
|
215
|
+
scope: props.scope,
|
|
216
|
+
seed: schema.parse({}),
|
|
217
|
+
})
|
|
218
|
+
const [column, setColumn] = useState<TaskStatus>('todo')
|
|
219
|
+
const statusOf = (id: string): TaskStatus => store.value[`status_${id}`] ?? 'todo'
|
|
220
|
+
const visible = tasks.filter(task => statusOf(task.id) === column)
|
|
221
|
+
return (
|
|
222
|
+
<FeatureFrame
|
|
223
|
+
onRetry={store.retry}
|
|
224
|
+
notice={store.error}
|
|
225
|
+
component="taskBoard"
|
|
226
|
+
title={props.title}
|
|
227
|
+
trailing={
|
|
228
|
+
<Text {...stylex.props(roles.muted)}>
|
|
229
|
+
{`${format.formatNumber(tasks.filter(task => statusOf(task.id) === 'done').length)} of ${format.formatNumber(tasks.length)} done`}
|
|
230
|
+
</Text>
|
|
231
|
+
}
|
|
232
|
+
>
|
|
233
|
+
<Segmented
|
|
234
|
+
options={taskColumns.map(option => ({
|
|
235
|
+
label: `${option.label} ${format.formatNumber(tasks.filter(task => statusOf(task.id) === option.value).length)}`,
|
|
236
|
+
value: option.value,
|
|
237
|
+
}))}
|
|
238
|
+
value={column}
|
|
239
|
+
onChange={setColumn}
|
|
240
|
+
/>
|
|
241
|
+
{visible.length === 0 ? (
|
|
242
|
+
<FeatureWell style={everydayStyles.empty}>
|
|
243
|
+
<Text {...stylex.props(roles.muted)}>
|
|
244
|
+
{column === 'done' ? 'Nothing finished yet.' : 'Nothing here.'}
|
|
245
|
+
</Text>
|
|
246
|
+
</FeatureWell>
|
|
247
|
+
) : (
|
|
248
|
+
<FeatureFacts>
|
|
249
|
+
{visible.map(task => {
|
|
250
|
+
const next: TaskStatus =
|
|
251
|
+
column === 'todo' ? 'doing' : column === 'doing' ? 'done' : 'todo'
|
|
252
|
+
return (
|
|
253
|
+
<List.Item
|
|
254
|
+
key={task.id}
|
|
255
|
+
label={task.label}
|
|
256
|
+
trailing={
|
|
257
|
+
<Button
|
|
258
|
+
accessibilityLabel={`${moveLabels[column]}: ${task.label}`}
|
|
259
|
+
disabled={!store.ready}
|
|
260
|
+
onClick={() => {
|
|
261
|
+
store.set(() => ({ [`status_${task.id}`]: next }))
|
|
262
|
+
}}
|
|
263
|
+
style={[button.quiet, button.sm, layout.trailingAction]}
|
|
264
|
+
>
|
|
265
|
+
<Text>{moveLabels[column]}</Text>
|
|
266
|
+
</Button>
|
|
267
|
+
}
|
|
268
|
+
/>
|
|
269
|
+
)
|
|
270
|
+
})}
|
|
271
|
+
</FeatureFacts>
|
|
272
|
+
)}
|
|
273
|
+
</FeatureFrame>
|
|
274
|
+
)
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export function Rotation(input: KowalskiInput<'rotation'>) {
|
|
278
|
+
const props = kowalskiCatalog.rotation.props.parse(input)
|
|
279
|
+
const people = props.people
|
|
280
|
+
const schema = kowalskiCatalog.rotation.storeSchema
|
|
281
|
+
const store = useConfiguredFeature({
|
|
282
|
+
name: props.id ?? 'KowalskiRotation',
|
|
283
|
+
revision: props.revision,
|
|
284
|
+
schema,
|
|
285
|
+
scope: props.scope,
|
|
286
|
+
seed: schema.parse({}),
|
|
287
|
+
})
|
|
288
|
+
// A saved turn for someone no longer in the group falls back to the first person.
|
|
289
|
+
const position = (turn: string | null) =>
|
|
290
|
+
Math.max(
|
|
291
|
+
0,
|
|
292
|
+
people.findIndex(person => person.id === turn)
|
|
293
|
+
)
|
|
294
|
+
const current = people[position(store.value.turn)]
|
|
295
|
+
const pass = (completed: boolean) =>
|
|
296
|
+
store.set(state => ({
|
|
297
|
+
completed: state.completed + (completed ? 1 : 0),
|
|
298
|
+
turn: people[(position(state.turn) + 1) % people.length].id,
|
|
299
|
+
}))
|
|
300
|
+
return (
|
|
301
|
+
<FeatureFrame
|
|
302
|
+
onRetry={store.retry}
|
|
303
|
+
notice={store.error}
|
|
304
|
+
component="rotation"
|
|
305
|
+
title={props.title}
|
|
306
|
+
detail={props.task}
|
|
307
|
+
>
|
|
308
|
+
<Field
|
|
309
|
+
label={
|
|
310
|
+
store.value.completed > 0
|
|
311
|
+
? `Order · ${format.formatNumber(store.value.completed)} done so far`
|
|
312
|
+
: 'Order'
|
|
313
|
+
}
|
|
314
|
+
>
|
|
315
|
+
<FeatureFacts>
|
|
316
|
+
{people.map(person => (
|
|
317
|
+
<List.Item
|
|
318
|
+
key={person.id}
|
|
319
|
+
label={person.label}
|
|
320
|
+
trailing={
|
|
321
|
+
person.id === current.id ? (
|
|
322
|
+
<Text {...stylex.props(roles.muted, appearance.accent)}>Now</Text>
|
|
323
|
+
) : undefined
|
|
324
|
+
}
|
|
325
|
+
/>
|
|
326
|
+
))}
|
|
327
|
+
</FeatureFacts>
|
|
328
|
+
</Field>
|
|
329
|
+
<FeatureWell style={everydayStyles.centered}>
|
|
330
|
+
<Text {...stylex.props(roles.label, layout.fieldLabel)}>Up now</Text>
|
|
331
|
+
<Text {...stylex.props(roles.h1)}>{current.label}</Text>
|
|
332
|
+
</FeatureWell>
|
|
333
|
+
<Flex {...stylex.props(layout.actions)}>
|
|
334
|
+
<FeatureAction
|
|
335
|
+
component="rotation"
|
|
336
|
+
disabled={!store.ready}
|
|
337
|
+
size="lg"
|
|
338
|
+
onClick={() => pass(false)}
|
|
339
|
+
>
|
|
340
|
+
Skip
|
|
341
|
+
</FeatureAction>
|
|
342
|
+
<FeatureAction
|
|
343
|
+
component="rotation"
|
|
344
|
+
disabled={!store.ready}
|
|
345
|
+
icon="checkmark"
|
|
346
|
+
size="lg"
|
|
347
|
+
variant="primary"
|
|
348
|
+
onClick={() => pass(true)}
|
|
349
|
+
>
|
|
350
|
+
Done
|
|
351
|
+
</FeatureAction>
|
|
352
|
+
</Flex>
|
|
353
|
+
</FeatureFrame>
|
|
354
|
+
)
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export function ShoppingList(input: KowalskiInput<'shoppingList'>) {
|
|
358
|
+
const props = kowalskiCatalog.shoppingList.props.parse(input)
|
|
359
|
+
const items = props.items
|
|
360
|
+
const schema = kowalskiCatalog.shoppingList.storeSchema
|
|
361
|
+
const store = useConfiguredFeature({
|
|
362
|
+
name: props.id ?? 'KowalskiShoppingList',
|
|
363
|
+
revision: props.revision,
|
|
364
|
+
schema,
|
|
365
|
+
scope: props.scope,
|
|
366
|
+
seed: schema.parse({}),
|
|
367
|
+
})
|
|
368
|
+
const money = (value: number) => formatCurrency(value, props.currency)
|
|
369
|
+
const got = (id: string) => Boolean(store.value[`got_${id}`])
|
|
370
|
+
const priced = items.filter(item => item.price !== undefined)
|
|
371
|
+
const cost = (item: (typeof items)[number]) => (item.price ?? 0) * item.quantity
|
|
372
|
+
const total = priced.reduce((sum, item) => sum + cost(item), 0)
|
|
373
|
+
const cart = priced
|
|
374
|
+
.filter(item => got(item.id))
|
|
375
|
+
.reduce((sum, item) => sum + cost(item), 0)
|
|
376
|
+
const count = items.filter(item => got(item.id)).length
|
|
377
|
+
return (
|
|
378
|
+
<FeatureFrame
|
|
379
|
+
onRetry={store.retry}
|
|
380
|
+
notice={store.error}
|
|
381
|
+
component="shoppingList"
|
|
382
|
+
title={props.title}
|
|
383
|
+
trailing={
|
|
384
|
+
<Text {...stylex.props(roles.muted)}>
|
|
385
|
+
{`${format.formatNumber(count)} of ${format.formatNumber(items.length)}`}
|
|
386
|
+
</Text>
|
|
387
|
+
}
|
|
388
|
+
>
|
|
389
|
+
{priced.length > 0 && (
|
|
390
|
+
<FeatureWell>
|
|
391
|
+
<Stat>
|
|
392
|
+
<Stat.Value>{money(cart)}</Stat.Value>
|
|
393
|
+
<Stat.Caption>{`In the cart of ${money(total)}`}</Stat.Caption>
|
|
394
|
+
</Stat>
|
|
395
|
+
</FeatureWell>
|
|
396
|
+
)}
|
|
397
|
+
<List style={completedTaskStyle}>
|
|
398
|
+
{items.map(item => (
|
|
399
|
+
<Choice
|
|
400
|
+
checked={got(item.id)}
|
|
401
|
+
description={
|
|
402
|
+
item.price === undefined
|
|
403
|
+
? item.quantity > 1
|
|
404
|
+
? `× ${format.formatNumber(item.quantity)}`
|
|
405
|
+
: undefined
|
|
406
|
+
: item.quantity > 1
|
|
407
|
+
? `${format.formatNumber(item.quantity)} × ${money(item.price)}`
|
|
408
|
+
: money(item.price)
|
|
409
|
+
}
|
|
410
|
+
disabled={!store.ready}
|
|
411
|
+
key={item.id}
|
|
412
|
+
onCheckedChange={checked =>
|
|
413
|
+
store.set(() => ({ [`got_${item.id}`]: checked }))
|
|
414
|
+
}
|
|
415
|
+
>
|
|
416
|
+
{item.label}
|
|
417
|
+
</Choice>
|
|
418
|
+
))}
|
|
419
|
+
</List>
|
|
420
|
+
{count > 0 && (
|
|
421
|
+
<FeatureAction
|
|
422
|
+
component="shoppingList"
|
|
423
|
+
disabled={!store.ready}
|
|
424
|
+
onClick={() =>
|
|
425
|
+
store.set(() =>
|
|
426
|
+
Object.fromEntries(items.map(item => [`got_${item.id}`, false]))
|
|
427
|
+
)
|
|
428
|
+
}
|
|
429
|
+
>
|
|
430
|
+
Start a new trip
|
|
431
|
+
</FeatureAction>
|
|
432
|
+
)}
|
|
433
|
+
</FeatureFrame>
|
|
434
|
+
)
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
export function Rating(input: KowalskiInput<'rating'>) {
|
|
438
|
+
const props = kowalskiCatalog.rating.props.parse(input)
|
|
439
|
+
const schema = kowalskiCatalog.rating.storeSchema
|
|
440
|
+
const store = useConfiguredFeature({
|
|
441
|
+
name: props.id ?? 'KowalskiRating',
|
|
442
|
+
revision: props.revision,
|
|
443
|
+
schema,
|
|
444
|
+
scope: props.scope,
|
|
445
|
+
seed: schema.parse({}),
|
|
446
|
+
})
|
|
447
|
+
const stars = store.value.stars
|
|
448
|
+
return (
|
|
449
|
+
<FeatureFrame
|
|
450
|
+
onRetry={store.retry}
|
|
451
|
+
notice={store.error}
|
|
452
|
+
component="rating"
|
|
453
|
+
title={props.title}
|
|
454
|
+
detail={props.subject}
|
|
455
|
+
>
|
|
456
|
+
<FeatureField
|
|
457
|
+
component="rating"
|
|
458
|
+
label="Note"
|
|
459
|
+
multiline
|
|
460
|
+
ready={store.ready}
|
|
461
|
+
saving={store.saving}
|
|
462
|
+
validate={value => value.length <= 2000}
|
|
463
|
+
value={store.value.note.value}
|
|
464
|
+
onChange={(note, onSaved) =>
|
|
465
|
+
store.set(() => ({ note: { value: note } }), onSaved)
|
|
466
|
+
}
|
|
467
|
+
/>
|
|
468
|
+
<FeatureWell style={everydayStyles.centered}>
|
|
469
|
+
<Flex {...stylex.props(everydayStyles.stars)}>
|
|
470
|
+
{[1, 2, 3, 4, 5].map(value => (
|
|
471
|
+
<Button
|
|
472
|
+
accessibilityLabel={`${value} ${value === 1 ? 'star' : 'stars'}`}
|
|
473
|
+
disabled={!store.ready}
|
|
474
|
+
key={value}
|
|
475
|
+
onClick={() => {
|
|
476
|
+
store.set(() => ({ stars: stars === value ? 0 : value }))
|
|
477
|
+
}}
|
|
478
|
+
selected={value === stars}
|
|
479
|
+
style={[button.quiet, everydayStyles.star]}
|
|
480
|
+
>
|
|
481
|
+
<Icon
|
|
482
|
+
name="star"
|
|
483
|
+
{...stylex.props(
|
|
484
|
+
roles.h1,
|
|
485
|
+
value <= stars ? appearance.accent : everydayStyles.emptyStar
|
|
486
|
+
)}
|
|
487
|
+
/>
|
|
488
|
+
</Button>
|
|
489
|
+
))}
|
|
490
|
+
</Flex>
|
|
491
|
+
<Text {...stylex.props(roles.muted)}>{ratingLabels[stars]}</Text>
|
|
492
|
+
</FeatureWell>
|
|
493
|
+
</FeatureFrame>
|
|
494
|
+
)
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
export function Ledger(input: KowalskiInput<'ledger'>) {
|
|
498
|
+
const props = kowalskiCatalog.ledger.props.parse(input)
|
|
499
|
+
const schema = kowalskiCatalog.ledger.storeSchema
|
|
500
|
+
const store = useConfiguredFeature({
|
|
501
|
+
name: props.id ?? 'KowalskiLedger',
|
|
502
|
+
revision: props.revision,
|
|
503
|
+
schema,
|
|
504
|
+
scope: props.scope,
|
|
505
|
+
seed: schema.parse({}),
|
|
506
|
+
})
|
|
507
|
+
const [first, second] = props.people
|
|
508
|
+
const [label, setLabel] = useState({ value: '' })
|
|
509
|
+
const [amount, setAmount] = useState({ value: '' })
|
|
510
|
+
const [paidBy, setPaidBy] = useState(first.id)
|
|
511
|
+
const money = (value: number) => formatCurrency(value, props.currency)
|
|
512
|
+
const nameOf = (id: string) => (id === first.id ? first.label : second.label)
|
|
513
|
+
const parsed = parseNumberInput(amount.value, props.currency)
|
|
514
|
+
const validLabel = schema.shape.entries
|
|
515
|
+
.unwrap()
|
|
516
|
+
.element.shape.label.safeParse(label.value.trim()).success
|
|
517
|
+
const valid = validLabel && Number.isFinite(parsed) && parsed > 0 && parsed <= 1e12
|
|
518
|
+
// Every cost is shared evenly, so whoever paid is owed half of it.
|
|
519
|
+
const balance = store.value.entries.reduce(
|
|
520
|
+
(sum, entry) => sum + (entry.paidBy === first.id ? entry.amount : -entry.amount) / 2,
|
|
521
|
+
0
|
|
522
|
+
)
|
|
523
|
+
const settled = Math.abs(balance) < 0.005
|
|
524
|
+
return (
|
|
525
|
+
<FeatureFrame
|
|
526
|
+
onRetry={store.retry}
|
|
527
|
+
notice={store.error}
|
|
528
|
+
component="ledger"
|
|
529
|
+
title={props.title}
|
|
530
|
+
detail={`${first.label} and ${second.label} · costs split evenly`}
|
|
531
|
+
>
|
|
532
|
+
<FeatureWell style={everydayStyles.centered}>
|
|
533
|
+
<Text {...stylex.props(roles.h1)}>
|
|
534
|
+
{settled ? 'All square' : money(Math.abs(balance))}
|
|
535
|
+
</Text>
|
|
536
|
+
{!settled && (
|
|
537
|
+
<Text {...stylex.props(roles.muted)}>
|
|
538
|
+
{balance > 0
|
|
539
|
+
? `${second.label} owes ${first.label}`
|
|
540
|
+
: `${first.label} owes ${second.label}`}
|
|
541
|
+
</Text>
|
|
542
|
+
)}
|
|
543
|
+
</FeatureWell>
|
|
544
|
+
{store.value.entries.length > 0 && (
|
|
545
|
+
<>
|
|
546
|
+
<FeatureAction
|
|
547
|
+
component="ledger"
|
|
548
|
+
disabled={!store.ready}
|
|
549
|
+
onClick={() => store.set(() => ({ entries: [] }))}
|
|
550
|
+
>
|
|
551
|
+
Settle up
|
|
552
|
+
</FeatureAction>
|
|
553
|
+
<FeatureFacts>
|
|
554
|
+
{store.value.entries.slice(0, 20).map(entry => (
|
|
555
|
+
<List.Item
|
|
556
|
+
description={`Paid by ${nameOf(entry.paidBy)}`}
|
|
557
|
+
key={entry.id}
|
|
558
|
+
label={entry.label || 'Shared cost'}
|
|
559
|
+
trailing={money(entry.amount)}
|
|
560
|
+
/>
|
|
561
|
+
))}
|
|
562
|
+
</FeatureFacts>
|
|
563
|
+
</>
|
|
564
|
+
)}
|
|
565
|
+
<Field
|
|
566
|
+
error={!validLabel && 'Keep the description within 160 characters.'}
|
|
567
|
+
label="What for"
|
|
568
|
+
>
|
|
569
|
+
<Input
|
|
570
|
+
placeholder="What for"
|
|
571
|
+
value={label.value}
|
|
572
|
+
onChange={value => setLabel({ value })}
|
|
573
|
+
style={[layout.input]}
|
|
574
|
+
/>
|
|
575
|
+
</Field>
|
|
576
|
+
<Field
|
|
577
|
+
error={amount.value && !valid && 'Enter an amount within the supported range.'}
|
|
578
|
+
label="Amount"
|
|
579
|
+
>
|
|
580
|
+
<Input
|
|
581
|
+
placeholder="Amount"
|
|
582
|
+
value={amount.value}
|
|
583
|
+
onChange={value => setAmount({ value })}
|
|
584
|
+
style={[layout.input]}
|
|
585
|
+
/>
|
|
586
|
+
</Field>
|
|
587
|
+
<Field label="Paid by">
|
|
588
|
+
<Segmented
|
|
589
|
+
options={props.people.map(person => ({
|
|
590
|
+
label: person.label,
|
|
591
|
+
value: person.id,
|
|
592
|
+
}))}
|
|
593
|
+
value={paidBy}
|
|
594
|
+
onChange={setPaidBy}
|
|
595
|
+
/>
|
|
596
|
+
</Field>
|
|
597
|
+
<FeatureAction
|
|
598
|
+
component="ledger"
|
|
599
|
+
disabled={
|
|
600
|
+
!valid || !store.ready || store.saving || store.value.entries.length >= 200
|
|
601
|
+
}
|
|
602
|
+
icon="plus"
|
|
603
|
+
size="lg"
|
|
604
|
+
variant="primary"
|
|
605
|
+
onClick={() =>
|
|
606
|
+
store.set(
|
|
607
|
+
current => ({
|
|
608
|
+
entries: [
|
|
609
|
+
{
|
|
610
|
+
amount: parsed,
|
|
611
|
+
id: `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`,
|
|
612
|
+
label: label.value.trim(),
|
|
613
|
+
paidBy,
|
|
614
|
+
},
|
|
615
|
+
...current.entries,
|
|
616
|
+
],
|
|
617
|
+
}),
|
|
618
|
+
() => {
|
|
619
|
+
setAmount(current => (current === amount ? { value: '' } : current))
|
|
620
|
+
setLabel(current => (current === label ? { value: '' } : current))
|
|
621
|
+
}
|
|
622
|
+
)
|
|
623
|
+
}
|
|
624
|
+
>
|
|
625
|
+
Add to the tab
|
|
626
|
+
</FeatureAction>
|
|
627
|
+
</FeatureFrame>
|
|
628
|
+
)
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
type TaskStatus = 'doing' | 'done' | 'todo'
|
|
632
|
+
|
|
633
|
+
const moveLabels: Record<TaskStatus, string> = {
|
|
634
|
+
doing: 'Finish',
|
|
635
|
+
done: 'Reopen',
|
|
636
|
+
todo: 'Start',
|
|
637
|
+
}
|
|
638
|
+
const ratingLabels = ['Tap a star to rate', 'Poor', 'Fair', 'Good', 'Great', 'Excellent']
|
|
639
|
+
const taskColumns: { label: string; value: TaskStatus }[] = [
|
|
640
|
+
{ label: 'To do', value: 'todo' },
|
|
641
|
+
{ label: 'Doing', value: 'doing' },
|
|
642
|
+
{ label: 'Done', value: 'done' },
|
|
643
|
+
]
|
|
644
|
+
|
|
645
|
+
const everydayStyles = stylex.create({
|
|
646
|
+
centered: { alignItems: 'center', textAlign: 'center' },
|
|
647
|
+
empty: { alignItems: 'center', padding: space[6] },
|
|
648
|
+
emptyStar: { color: colors.border },
|
|
649
|
+
score: { minWidth: size[8], textAlign: 'center' },
|
|
650
|
+
star: { minWidth: 0, paddingLeft: space[1], paddingRight: space[1] },
|
|
651
|
+
stars: { flexDirection: 'row', gap: space[1], justifyContent: 'center' },
|
|
652
|
+
})
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createIntl, createIntlCache } from '@formatjs/intl'
|
|
2
|
+
import isCurrency from 'validator/lib/isCurrency.js'
|
|
3
|
+
|
|
4
|
+
/** Kowalski's authored English UI uses one cache for display and editor formatting. */
|
|
5
|
+
export const format = createIntl(
|
|
6
|
+
{
|
|
7
|
+
defaultLocale: 'en-US',
|
|
8
|
+
formats: {
|
|
9
|
+
number: {
|
|
10
|
+
decimal: {
|
|
11
|
+
maximumFractionDigits: 100,
|
|
12
|
+
maximumSignificantDigits: 17,
|
|
13
|
+
roundingPriority: 'morePrecision',
|
|
14
|
+
},
|
|
15
|
+
integer: { maximumFractionDigits: 0 },
|
|
16
|
+
twoDigits: {
|
|
17
|
+
maximumFractionDigits: 0,
|
|
18
|
+
minimumIntegerDigits: 2,
|
|
19
|
+
useGrouping: false,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
locale: 'en-US',
|
|
24
|
+
messages: {},
|
|
25
|
+
},
|
|
26
|
+
createIntlCache()
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
/** Validate the UI's English decimal/currency grammar before removing its fixed affixes. */
|
|
30
|
+
export function parseNumberInput(text: string, currency?: string) {
|
|
31
|
+
const symbol = currency
|
|
32
|
+
? (format
|
|
33
|
+
.formatNumberToParts(0, { currency, style: 'currency' })
|
|
34
|
+
.find(part => part.type === 'currency')?.value ?? currency)
|
|
35
|
+
: ''
|
|
36
|
+
const normalized = text.replaceAll('\u200E', '').trim().replaceAll('\u00A0', ' ')
|
|
37
|
+
const amount = normalized.replace(symbol, '')
|
|
38
|
+
if (
|
|
39
|
+
!isCurrency(normalized, {
|
|
40
|
+
allow_space_after_symbol: true,
|
|
41
|
+
digits_after_decimal: [amount.split('.')[1]?.length ?? 0],
|
|
42
|
+
symbol,
|
|
43
|
+
})
|
|
44
|
+
) {
|
|
45
|
+
return Number.NaN
|
|
46
|
+
}
|
|
47
|
+
return Number(amount.replaceAll(',', '').trim())
|
|
48
|
+
}
|