npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@flipdish/ui-connected

v1.1.0

Published

Flipdish Design System — API-connected components. Domain-aware building blocks (PropertySelect, AssetManager) built on @flipdish/ui-library and TanStack Query.

Readme

@flipdish/ui-connected

API-connected React components for Flipdish products — domain-aware building blocks (PropertySelect, AssetManager) built on @flipdish/ui-library and TanStack Query.

Internal package, published publicly. Everything here knows about a Flipdish API endpoint. It is on the public registry so Flipdish micro-frontends can share it — it is not useful outside Flipdish.

Part of the Flipdish Design System:

| Package | Purpose | | ---------------------------------------------------------------------------- | -------------------------------------------- | | @flipdish/ui-tokens | Design tokens — colours, type scale, spacing | | @flipdish/ui-icons | Icon set | | @flipdish/ui-library | Components — pure, prop-driven | | @flipdish/ui-connected | Components that talk to APIs (this package) |

Why this package exists

ui-library components are pure functions of their props. That is what makes them safe to use anywhere, cheap to test, and portable to React Native. These are not: they fetch, they know endpoints, and they follow backend contracts that change on the backend's schedule.

Keeping them apart is a release-cadence decision more than a technical one. A properties-endpoint change should not force a ui-library version bump on every product that consumes Button, and a design-system release should not carry domain code that raises its risk profile.

The test for whether something belongs here: does it know about a Flipdish endpoint? If yes, it lives here. If no, it belongs in ui-library — including generic components that merely accept async data via props.

Installation

pnpm add @flipdish/ui-connected @flipdish/ui-library @tanstack/react-query

Peer dependencies

| Package | Version | Notes | | ----------------------- | ---------------------- | ------------------------------------------------ | | react | ^18.3.0 \|\| ^19.0.0 | | | react-dom | ^18.3.0 \|\| ^19.0.0 | | | @tanstack/react-query | ^5.0.0 | You own the QueryClient — see below | | @flipdish/ui-library | >=0.63.0 | Plus that package's own peers and Tailwind setup |

Why ui-library is a peer, not a dependency. It ships React contexts (ThemeProvider, PortalContainer, RouteProvider, and react-aria's own). Two copies in one app means two sets of context instances, and components silently failing to see the provider you mounted. Declaring it as a peer makes your single copy the only copy.

Setup

Two providers, in this order:

import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { UIConnectedProvider } from '@flipdish/ui-connected/providers/UIConnectedProvider';

const queryClient = new QueryClient();

<QueryClientProvider client={queryClient}>
  <UIConnectedProvider
    baseUrl={import.meta.env.VITE_API_URL}
    orgId={orgId}
    fetch={authenticatedFetch}
  >
    <App />
  </UIConnectedProvider>
</QueryClientProvider>;

UIConnectedProvider options:

| Prop | Required | Purpose | | -------------- | -------- | --------------------------------------------------------------------------- | | baseUrl | yes | API root (not the Portal origin). Validated — see below. | | orgId | yes | Organisation scope for every request. | | brandId | no | Default brand scope for the assets API; individual components can override. | | allowedHosts | no | Hosts baseUrl may point at. null disables the check. | | fetch | yes | Your app's authenticated HTTP client — see below. |

baseUrl is the API host, not the origin your MFE is embedded in:

| Environment | baseUrl | | ------------ | ------------------------------------------------- | | Production | https://api.portal.flipdish.com | | prod-staging | https://api-prod-staging.portal.flipdishdev.com |

In web-portal these come from getApiEndPoint() (helpers/apibase.ts), which already handles the ?fd-api= override — pass that value straight through.

It is deliberately required rather than derived. The Portal's original AssetManager picked between hard-coded prod and staging hosts by inspecting window.location.host, which cannot work in a package used by more than one product and breaks in tests, Storybook, and SSR.

baseUrl is validated at mount

Because the default fetcher sends cookies, the configured origin receives the user's Flipdish session on every request — so a baseUrl from a mistyped env var would hand that session to a third party, and CORS does not stop the credentialed request being sent. The provider therefore fails closed:

  • Must parse as an absolute URL, must not embed credentials (https://user:pass@…), and must not carry a query string or fragment (services append paths by concatenation, so those would swallow the route).
  • Must be https: — http: is permitted only for loopback (localhost, 127.0.0.1, ::1).
  • Host must match allowedHosts, exactly or as a dot-anchored suffix. portal.flipdish.com.attacker.net and notportal.flipdish.com are both rejected.

The default is ['portal.flipdish.com', 'portal.flipdishdev.com', 'api.flipdish.co'], covering the Portal API, the Portal origins, and the public developer API. It is scoped to those rather than the bare flipdish.com / flipdish.co apexes so a takeover of an unrelated Flipdish subdomain (marketing, docs, a parked host) can't be used as a target.

If your app lets users repoint the API at runtime — web-portal does, via ?fd-api= and a flipdish-api-endpoint localStorage key — the host check will reject those overrides. Either supply your own list, or opt out explicitly:

import { UNSAFE_ALLOW_ANY_HOST } from '@flipdish/ui-connected/providers/UIConnectedProvider';

<UIConnectedProvider allowedHosts={UNSAFE_ALLOW_ANY_HOST} … />

The token is named and greppable on purpose. Opting out means your fetch will send the user's session to whatever origin baseUrl names, so baseUrl must never be derived from user input — an attacker-supplied value would be a session-exfiltration path. The structural checks still apply.

A bad baseUrl throws during render, so it surfaces via your error boundary at mount rather than silently pointing somewhere wrong.

Auth is yours — fetch is required

This package owns no authentication. Every consumer does it differently:

| Consumer | How it authenticates | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | web-portal | cookies (withCredentials) plus an X-Flipdish-Source-Origin header (portal.flipdish.com, portal.flipdishdev.com, or local.portal.com locally, so SameSite=None works) | | flipdish-ui | cookies (credentials: 'include') |

A built-in default would work for one of those and fail confusingly for the other — sending cookies without the Portal's origin header, for instance. So fetch is a required prop: pass whatever client your app already has, and auth refresh, retries, tracing and error normalisation stay in one place.

// web-portal-style
const authenticatedFetch = (url: string, init?: RequestInit) =>
  fetch(url, {
    ...init,
    credentials: 'include',
    headers: {
      ...init?.headers,
      'X-Flipdish-Source-Origin': sourceOrigin(),
      Accept: 'application/json',
    },
  });

Everything targets the Portal API base, which serves both the assets routes and /orgManagement/orgs/{orgId}/properties. api.flipdish.co is the external gateway for the same routes — internal apps don't use it — so one baseUrl and one fetch covers the package.

There is no axios here either. TanStack Query is transport-agnostic and requires only that a queryFn throws on failure, which assertOk handles.

Requests are abortable — each service threads TanStack Query's signal through, so in-flight fetches cancel on unmount or refetch.

One QueryClient, owned by the shell

This package never creates a QueryClient. It reads yours. That is the most important thing on this page, and getting it wrong makes these components slower than the hand-written code they replace.

Why it matters:

  • Shared cache. Several MFEs on one page reading properties should cost one request. With per-component clients it costs one request each.
  • Invalidation reaches everything. useUploadAssets invalidates assetsKeys.all on your client, so a list rendered by a different component — or a different MFE — refreshes too. A private client can only ever refresh itself.
  • Your defaults apply. Retry policy, error handling, and devtools work the way the rest of your app does.

For reference, the Portal's current AssetManager does the opposite — it instantiates a QueryClient and wraps itself in a private QueryClientProvider, so that its consumers do not need one. Convenient, and the reason uploads there cannot refresh anything outside that one instance. The port drops it.

Query keys are namespaced

Because we live in your keyspace, every key is prefixed with flipdish:

propertiesKeys.list({ orgId }); // ['flipdish', 'properties', 'list', { orgId }]

That avoids colliding with your own ['properties'], and stops a broad invalidateQueries({ queryKey: ['properties'] }) on either side from clobbering the other.

Structure

Two folders, grouped on two different axes — deliberately:

src/
├── providers/            # UIConnectedProvider — config for everything else
├── api/                  # DATA, grouped by domain
│   ├── assets/
│   └── properties/
├── components/           # PRESENTATION, grouped by kind
│   ├── selects/          # PropertySelect, StoreSelect, MenuSelect …
│   └── media/            # AssetManager, ImageCropper …
├── utilities/            # leaf helpers — httpUtils, fileUtils
└── constants/            # shared values — durations

Why the split. Components are discovered by shape ("I need a select"), so they group by kind. Query keys and services are contracts shared across components — if PropertySelect, a property badge, and an entitlement filter each carried their own copy, they would each get their own cache entry and their own request. So the data layer groups by domain, and every component reads through it.

The two axes also sit at different granularities: for small components the useful axis is shape (a select is a select, whatever the domain), while for large ones the shape is the domain (AssetManager's shape is asset management). That is intentional, not an inconsistency to tidy up. See AGENTS.md for the folder-naming rule.

Importing

import { UIConnectedProvider } from '@flipdish/ui-connected/providers/UIConnectedProvider';
import { PropertySelect } from '@flipdish/ui-connected/components/selects/PropertySelect';
import { AssetManager } from '@flipdish/ui-connected/components/media/AssetManager';
import {
  useProperties,
  propertiesKeys,
} from '@flipdish/ui-connected/api/properties';
import { useAssets, useUploadAssets } from '@flipdish/ui-connected/api/assets';

Hooks are public, not just internal plumbing. Consumers regularly want the data without the UI, and if this package does not offer it they will write their own fetch under a different key and lose the shared cache.

Contents

| Export | Status | Notes | | ----------------------------------- | ----------- | -------------------------------------------------- | | providers/UIConnectedProvider | ✅ ready | Config context | | api/properties | ✅ ready | useProperties, getProperties, propertiesKeys | | api/assets | ✅ ready | useAssets, useUploadAssets, assetsKeys | | components/selects/PropertySelect | 🚧 API only | Blocked on SmartSelect in ui-library | | components/media/AssetManager | 🚧 API only | Data layer done; presentation port outstanding | | utilities/httpUtils | ✅ ready | assertOk, errorMessageFrom | | utilities/fileUtils | ✅ ready | sanitiseFile | | constants/durations | ✅ ready | FIVE_MINUTES, TEN_MINUTES, … |

Usage

The data layer is what's usable today. PropertySelect and AssetManager are stubs — see "Contents" above.

import { useProperties } from '@flipdish/ui-connected/api/properties';

const { data, isPending, isError } = useProperties();

Build the select in your app for now. Because it reads through propertiesKeys.list, a hand-rolled select today and PropertySelect tomorrow share one cache entry — so the eventual swap costs nothing and there is no duplicate request in the meantime.

Selects are deliberately not implemented here yet: ui-library's Select has no loading, error, or remote-search state, and that behaviour belongs upstream as SmartSelect rather than being hand-rolled per domain package. Once it lands, PropertySelect becomes a thin binding over it.

Filters in the URL

When these drive a filtered list, keep the filter state in URL query params, read it with useSearchParams, and put it in the query key:

const [params] = useSearchParams();
const propertyId = params.get('property') ?? undefined;

const { data } = useQuery({
  queryKey: ['entitlements', { propertyId }],
  queryFn: () => fetchEntitlements({ propertyId }),
  placeholderData: keepPreviousData,
});

The URL should be the single source of truth — do not mirror filters into useState, or they desync on back/forward. Reset any page param when filters change, and use keepPreviousData so the table holds its rows instead of flashing empty.

Loading states

ui-library's Select has no loading, error, or remote-search state yet. That behaviour belongs upstream as SmartSelect rather than being hand-rolled here, which is why PropertySelect is still a stub — see "Contents" above.

For an app-side select in the meantime, isDisabled plus placeholder copy ("Loading properties…") is the interim pattern. Don't reach for LoadingIndicator inside a select trigger — it is a block-level region loader whose smallest spinner is 32px against a size-4 icon slot. It's the right choice for a whole filter bar loading at once, not one control.

Do not reach for LoadingIndicator in a select trigger — it is a block-level region loader whose smallest spinner is 32px, against a size-4 icon slot. It is the right choice for a whole filter bar loading at once, not for one control.

React Native

Web-only. The ui-library components underneath (Select, Modal) have no index.native.tsx siblings, so nothing here is React Native safe. Metro's resolver falls back to index.tsx when no native sibling exists, so an RN import will bundle web-only code rather than failing cleanly — don't import this package from an RN app.

Contributing

See AGENTS.md for the folder-naming rule, dependency direction, and the checklist for adding a component or a domain. General repo setup lives in the root CONTRIBUTING.md.

Not done yet

  • Storybook is not wired up for this package — stories and MDX come next, sourced alongside ui-library's in the Storybook MCP config.
  • No test suite yet (pnpm test is a stub). The services and the select factory are the first things worth covering.
  • check-exports-resolution.mjs has not been ported from ui-library; verify-build.mjs here checks artefact presence only.
  • The properties endpoint in api/properties/properties.service.ts is assumed, not confirmed — no properties API consumer exists in flipdish-ui yet to check it against.
  • AssetManager throws if rendered; only its public API is defined. Use api/assets directly in the meantime.