business-obligations-ui 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -106,11 +106,12 @@ const [choices] = useProfileChoices(); // { entityType, naics, employeeCount, se
106
106
 
107
107
  ## Conditionally applicable obligations
108
108
 
109
- `ObligationsList` takes an optional `conditional` list and shows it in its own section after the others: items that are
109
+ `ObligationsList` takes an optional `conditional` list and shows each of them inside the group of the level that requires it (city, county, state or federal), after the items
110
+ that do apply, dimmed and with what would bring it in: items that are
110
111
  not in `items` now, but would be if a detail that was left blank turned out a certain way. Each is a `ConditionalItem`,
111
112
  `{ item, when: [{ field, values }] }`, and its card says what would bring it in ("Applies if number of employees: 1, 2,
112
113
  3 …"). The package does not compute them; the playground does, from `analyzeInputs` and `evaluate`
113
- (`conditionalItems` in `apps/web/src/lib/plan.ts`). The list's filters apply to the section too.
114
+ (`conditionalItems` in `apps/web/src/lib/plan.ts`). The list's filters apply to them too. Groups run from the most local level to the widest: city, county, state, federal.
114
115
 
115
116
  ## Bundle size
116
117
 
package/dist/index.cjs CHANGED
@@ -1227,7 +1227,7 @@ function describeWhen(m, { field, values }) {
1227
1227
  }
1228
1228
 
1229
1229
  // src/plan/filters.ts
1230
- var JURISDICTIONS = ["federal", "state", "county", "city"];
1230
+ var JURISDICTIONS = ["city", "county", "state", "federal"];
1231
1231
  var NO_OBLIGATION_FILTERS = {
1232
1232
  jurisdiction: "all",
1233
1233
  category: "all",
@@ -1258,6 +1258,7 @@ function ObligationsListBody({ items, conditional = [], asOf, filters, onFilters
1258
1258
  const shownConditional = conditional.filter(({ item }) => itemMatches(item, filters));
1259
1259
  const titleById = new Map(items.map((item) => [item.id, item.title]));
1260
1260
  const count = (jurisdiction) => items.filter((item) => itemMatches(item, { ...filters, jurisdiction })).length;
1261
+ const conditionalCount = (jurisdiction) => shownConditional.filter(({ item }) => item.jurisdiction === jurisdiction).length;
1261
1262
  const categoryCount = (category) => items.filter((item) => itemMatches(item, { ...filters, category })).length;
1262
1263
  const hasFilters = filters.jurisdiction !== "all" || filters.category !== "all" || filters.query !== "" || filters.trust !== "all";
1263
1264
  const clearFilters = () => onFilters({ ...NO_OBLIGATION_FILTERS });
@@ -1321,7 +1322,7 @@ function ObligationsListBody({ items, conditional = [], asOf, filters, onFilters
1321
1322
  {
1322
1323
  size: "sm",
1323
1324
  theme: filters.jurisdiction === key ? "accent" : void 0,
1324
- disabled: count(key) === 0 && key !== "all",
1325
+ disabled: count(key) + conditionalCount(key) === 0 && key !== "all",
1325
1326
  onPress: () => onFilters({ ...filters, jurisdiction: key }),
1326
1327
  "aria-pressed": filters.jurisdiction === key,
1327
1328
  children: [
@@ -1332,34 +1333,37 @@ function ObligationsListBody({ items, conditional = [], asOf, filters, onFilters
1332
1333
  },
1333
1334
  key
1334
1335
  )) }),
1336
+ shownConditional.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_tamagui8.Text, { fontSize: "sm", color: "placeholder-color", children: m.conditionalNote }),
1335
1337
  filtered.length === 0 && shownConditional.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_tamagui8.Text, { color: "placeholder-color", children: m.noMatch }) : JURISDICTIONS.map((jurisdiction) => {
1336
- const group = filtered.filter((item) => item.jurisdiction === jurisdiction).sort((a, b) => (a.nextDue ?? "9999-12-31").localeCompare(b.nextDue ?? "9999-12-31"));
1337
- if (!group.length) return null;
1338
+ const byDue = (a, b) => (a.nextDue ?? "9999-12-31").localeCompare(b.nextDue ?? "9999-12-31");
1339
+ const group = filtered.filter((item) => item.jurisdiction === jurisdiction).sort(byDue);
1340
+ const maybe = shownConditional.filter(({ item }) => item.jurisdiction === jurisdiction).sort((a, b) => byDue(a.item, b.item));
1341
+ if (!group.length && !maybe.length) return null;
1338
1342
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_tamagui8.YStack, { children: [
1339
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_tamagui8.XStack, { gap: "2", alignItems: "center", paddingTop: "3", paddingBottom: "1", children: [
1343
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_tamagui8.XStack, { gap: "2", alignItems: "center", paddingTop: "3", paddingBottom: "1", flexWrap: "wrap", children: [
1340
1344
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_tamagui8.Text, { render: "h2", fontSize: "lg", fontWeight: "600", margin: 0, children: m.jurisdictions[jurisdiction] }),
1341
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Chip, { tone: "info", children: group.length })
1345
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Chip, { tone: "info", children: group.length }),
1346
+ maybe.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Chip, { tone: "warn", outline: true, children: [
1347
+ "+",
1348
+ maybe.length,
1349
+ " ",
1350
+ m.conditionalHeading.toLowerCase()
1351
+ ] })
1342
1352
  ] }),
1343
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_tamagui8.YStack, { gap: "3", children: group.map((item) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ObligationCard, { item, asOf, titleOf: (id) => titleById.get(id) }, item.id)) })
1353
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_tamagui8.YStack, { gap: "3", children: [
1354
+ group.map((item) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ObligationCard, { item, asOf, titleOf: (id) => titleById.get(id) }, item.id)),
1355
+ maybe.map(({ item, when }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_tamagui8.YStack, { opacity: 0.8, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1356
+ ObligationCard,
1357
+ {
1358
+ item,
1359
+ asOf,
1360
+ titleOf: (id) => titleById.get(id),
1361
+ note: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_tamagui8.XStack, { gap: "1.5", flexWrap: "wrap", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Chip, { tone: "warn", outline: true, children: m.appliesIf(when.map((condition) => describeWhen(m, condition)).join("; ")) }) })
1362
+ }
1363
+ ) }, item.id))
1364
+ ] })
1344
1365
  ] }, jurisdiction);
1345
- }),
1346
- shownConditional.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_tamagui8.YStack, { children: [
1347
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_tamagui8.XStack, { gap: "2", alignItems: "center", paddingTop: "3", paddingBottom: "1", children: [
1348
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_tamagui8.Text, { render: "h2", fontSize: "lg", fontWeight: "600", margin: 0, children: m.conditionalHeading }),
1349
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Chip, { tone: "info", children: shownConditional.length })
1350
- ] }),
1351
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_tamagui8.Text, { fontSize: "sm", color: "placeholder-color", paddingBottom: "2", children: m.conditionalNote }),
1352
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_tamagui8.YStack, { gap: "3", children: shownConditional.map(({ item, when }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1353
- ObligationCard,
1354
- {
1355
- item,
1356
- asOf,
1357
- titleOf: (id) => titleById.get(id),
1358
- note: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_tamagui8.XStack, { gap: "1.5", flexWrap: "wrap", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Chip, { tone: "warn", outline: true, children: m.appliesIf(when.map((condition) => describeWhen(m, condition)).join("; ")) }) })
1359
- },
1360
- item.id
1361
- )) })
1362
- ] })
1366
+ })
1363
1367
  ] });
1364
1368
  }
1365
1369