<html lang="en">
<head></head>
<body>

<form id="mainForm" method="post" action="https://stackblitz.com/run" target="_self">
<input type="hidden" name="project[files][babel.config.js]" value="import { buildMacros } from &#39;@embroider/macros/babel&#39;

const macros = buildMacros({
  configure(config) {
    if (process.env.EMBER_ENV === &#39;test&#39;) {
      config.enableRuntimeMode()
    }
  },
})

export default {
  plugins: [
    [
      &#39;@babel/plugin-transform-typescript&#39;,
      {
        onlyRemoveTypeImports: true,
      },
    ],
    [
      &#39;babel-plugin-ember-template-compilation&#39;,
      {
        transforms: [...macros.templateMacros],
      },
    ],
    [
      &#39;module:decorator-transforms&#39;,
      {
        runtime: {
          import: import.meta.resolve(&#39;decorator-transforms/runtime-esm&#39;),
        },
      },
    ],
    [
      &#39;@babel/plugin-transform-runtime&#39;,
      {
        absoluteRuntime: import.meta.dirname,
      },
    ],
    ...macros.babelMacros,
  ],

  generatorOpts: {
    compact: false,
  },
}
">
<input type="hidden" name="project[files][index.html]" value="&lt;!doctype html&gt;
&lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
    &lt;meta charset=&quot;utf-8&quot; /&gt;
    &lt;title&gt;Minimal App&lt;/title&gt;
    &lt;meta name=&quot;description&quot; content=&quot;&quot; /&gt;
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot; /&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;script type=&quot;module&quot;&gt;
      import Application from &#39;#app/app&#39;
      import environment from &#39;#config&#39;

      Application.create(environment.APP)
    &lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;
">
<input type="hidden" name="project[files][package.json]" value="{
  &quot;name&quot;: &quot;tanstack-ember-table-example-column-ordering&quot;,
  &quot;private&quot;: true,
  &quot;type&quot;: &quot;module&quot;,
  &quot;imports&quot;: {
    &quot;#app/*&quot;: &quot;./app/*&quot;,
    &quot;#config&quot;: &quot;./app/config.ts&quot;,
    &quot;#components/*&quot;: &quot;./app/components/*&quot;,
    &quot;#services/*&quot;: &quot;./app/services/*&quot;,
    &quot;#test-helpers/*&quot;: &quot;./tests/helpers/*&quot;,
    &quot;#utils/*&quot;: &quot;./app/utils/*&quot;
  },
  &quot;exports&quot;: {
    &quot;./tests/*&quot;: &quot;./tests/*&quot;,
    &quot;./*&quot;: &quot;./app/*&quot;
  },
  &quot;scripts&quot;: {
    &quot;dev&quot;: &quot;vite&quot;,
    &quot;build&quot;: &quot;vite build&quot;,
    &quot;serve&quot;: &quot;vite preview&quot;,
    &quot;start&quot;: &quot;vite&quot;,
    &quot;test:e2e&quot;: &quot;PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts&quot;,
    &quot;test:types&quot;: &quot;ember-tsc --noEmit&quot;
  },
  &quot;dependencies&quot;: {
    &quot;@embroider/macros&quot;: &quot;1.21.4&quot;,
    &quot;@embroider/router&quot;: &quot;3.0.6&quot;,
    &quot;@faker-js/faker&quot;: &quot;^10.6.0&quot;,
    &quot;@glimmer/component&quot;: &quot;2.2.1&quot;,
    &quot;@tanstack/ember-table&quot;: &quot;https://pkg.pr.new/TanStack/table/@tanstack/ember-table@a71a0ec35cf875893768dfffd3286de620dc06cc&quot;,
    &quot;decorator-transforms&quot;: &quot;2.4.0&quot;,
    &quot;ember-source&quot;: &quot;7.4.0&quot;,
    &quot;ember-strict-application-resolver&quot;: &quot;0.1.1&quot;
  },
  &quot;devDependencies&quot;: {
    &quot;@babel/core&quot;: &quot;8.1.2&quot;,
    &quot;@babel/plugin-transform-runtime&quot;: &quot;8.1.2&quot;,
    &quot;@babel/plugin-transform-typescript&quot;: &quot;8.0.6&quot;,
    &quot;@babel/runtime&quot;: &quot;8.1.2&quot;,
    &quot;@ember/app-tsconfig&quot;: &quot;2.1.0&quot;,
    &quot;@embroider/core&quot;: &quot;4.6.10&quot;,
    &quot;@glint/ember-tsc&quot;: &quot;1.14.3&quot;,
    &quot;@glint/template&quot;: &quot;1.11.1&quot;,
    &quot;@glint/tsserver-plugin&quot;: &quot;2.7.16&quot;,
    &quot;@nullvoxpopuli/ember-vite&quot;: &quot;1.5.0&quot;,
    &quot;@rolldown/binding-wasm32-wasi&quot;: &quot;~1.3.2&quot;,
    &quot;@rollup/plugin-babel&quot;: &quot;7.1.0&quot;,
    &quot;babel-plugin-ember-template-compilation&quot;: &quot;4.0.1&quot;,
    &quot;typescript&quot;: &quot;6.0.3&quot;,
    &quot;vite&quot;: &quot;^8.3.8&quot;
  },
  &quot;engines&quot;: {
    &quot;node&quot;: &quot;&gt;= 24.11&quot;
  },
  &quot;ember&quot;: {
    &quot;edition&quot;: &quot;octane&quot;
  }
}">
<input type="hidden" name="project[files][tsconfig.json]" value="{
  &quot;extends&quot;: &quot;@ember/app-tsconfig&quot;,
  &quot;compilerOptions&quot;: {
    &quot;lib&quot;: [&quot;ES2025&quot;, &quot;DOM&quot;, &quot;DOM.Iterable&quot;],
    &quot;allowJs&quot;: true,
    &quot;types&quot;: [
      &quot;ember-source/types&quot;,
      &quot;@embroider/core/virtual&quot;,
      &quot;vite/client&quot;,
      &quot;@glint/ember-tsc/types&quot;
    ]
  }
}
">
<input type="hidden" name="project[files][vite.config.mjs]" value="import { defineConfig } from &#39;vite&#39;
import { ember } from &#39;@nullvoxpopuli/ember-vite&#39;

export default defineConfig({
  server: {
    port: 7777,
    allowedHosts: true,
  },
  plugins: [ember()],
})
">
<input type="hidden" name="project[files][.devcontainer/devcontainer.json]" value="{
  &quot;name&quot;: &quot;Node.js&quot;,
  &quot;image&quot;: &quot;mcr.microsoft.com/devcontainers/javascript-node:24&quot;
}
">
<input type="hidden" name="project[files][app/app.css]" value="/* Shared demo styles for the TanStack Table Ember examples. */

html {
  font-family: sans-serif;
  font-size: 14px;
}

* {
  box-sizing: border-box;
}

/* --- Base table --- */

table {
  border: 1px solid lightgray;
  border-collapse: collapse;
  border-spacing: 0;
}

tbody {
  border-bottom: 1px solid lightgray;
}

th {
  position: relative;
  border-bottom: 1px solid lightgray;
  border-right: 1px solid lightgray;
  padding: 2px 4px;
}

td {
  border-right: 1px solid lightgray;
  padding: 2px 4px;
}

tfoot {
  color: gray;
}

tfoot th {
  font-weight: normal;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Div-based grid table (used by the performant resizing example) --- */

.divTable {
  border: 1px solid lightgray;
  width: fit-content;
}

.divTable .tr {
  display: flex;
  width: fit-content;
  height: 30px;
}

.divTable .th,
.divTable .td {
  box-shadow: inset 0 0 0 1px lightgray;
  padding: 2px 4px;
  height: 30px;
}

.divTable .th {
  position: relative;
  font-weight: bold;
  text-align: center;
}

/* --- Column resizing --- */

.resizer {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 5px;
  background: rgba(0, 0, 0, 0.5);
  cursor: col-resize;
  user-select: none;
  touch-action: none;
}

.resizer.isResizing {
  background: blue;
  opacity: 1;
}

@media (hover: hover) {
  .resizer {
    opacity: 0;
  }

  *:hover &gt; .resizer {
    opacity: 1;
  }
}

/* --- Column pinning --- */

.pinned-rows-top,
.pinned-rows-bottom {
  background: #f5f5f5;
}

.split-tables {
  display: flex;
  gap: 1rem;
}

/* --- Demo layout helpers --- */

.demo-root {
  padding: 0.5rem;
}

.spacer-xs {
  height: 0.25rem;
}

.spacer-sm {
  height: 0.5rem;
}

.spacer-md {
  height: 1rem;
}

.controls,
.button-row,
.inline-controls,
.header-controls,
.pin-actions,
.filter-row,
.page-controls {
  display: flex;
  align-items: center;
}

.button-row {
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.controls,
.page-controls {
  gap: 0.5rem;
  flex-wrap: wrap;
}

.inline-controls,
.header-controls,
.pin-actions {
  gap: 0.25rem;
}

.pin-actions {
  justify-content: center;
}

.filter-row {
  gap: 0.5rem;
}

.sortable-header {
  cursor: pointer;
  user-select: none;
}

.nowrap {
  white-space: nowrap;
}

.scroll-container {
  overflow-x: auto;
}

.section-title {
  font-size: 1.25rem;
}

.demo-note {
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

/* --- Column visibility toggle panel --- */

.column-toggle-panel {
  display: inline-block;
  border: 1px solid #000;
  border-radius: 0.25rem;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.2);
}

.column-toggle-panel-header {
  border-bottom: 1px solid #000;
  padding: 0 0.25rem;
}

.column-toggle-row {
  padding: 0 0.25rem;
}

/* --- Buttons and inputs --- */

.demo-button,
.demo-button-spaced,
.pin-button,
.filter-input,
.filter-select,
.page-size-input,
.column-size-input,
.outlined-control {
  border: 1px solid currentColor;
  border-radius: 0.25rem;
}

.outlined-control {
  border-color: #000;
}

.outlined-table {
  border: 2px solid #000;
}

.demo-button {
  padding: 0.5rem;
}

.demo-button-sm {
  padding: 0.25rem;
}

.demo-button-spaced {
  margin-bottom: 0.5rem;
  padding: 0.5rem;
}

.pin-button {
  padding: 0 0.5rem;
}

.page-size-input {
  width: 4rem;
  padding: 0.25rem;
}

.column-size-input {
  width: 6rem;
  margin-left: 0.5rem;
  padding: 0.25rem;
}

.filter-input {
  width: 6rem;
}

.filter-select {
  width: 9rem;
}

/* --- Status cell demo (basic table) --- */

.status-bar {
  font-size: 0.875rem;
}

.status-relationship {
  color: #16a34a;
}

.status-complicated {
  color: #ca8a04;
}

.status-single {
  color: #6b7280;
}

/* --- Row selection --- */

.selected {
  background: #e0f2fe;
}

/* --- Code / state output --- */

.code-block {
  overflow: auto;
  border-radius: 0.25rem;
  background: #f3f4f6;
  padding: 0.5rem;
  font-size: 0.75rem;
}
">
<input type="hidden" name="project[files][app/app.ts]" value="/**
 * Looking for services that come from addons?
 *
 * See: https://github.com/embroider-build/embroider/issues/2659
 *
 * We currently don&#39;t support app-tree merging from libraries.
 *
 * For services, I highly recommend looking into either of
 * - https://github.com/chancancode/ember-polaris-service-
 * - https://ember-primitives.pages.dev/6-utils/createService.md
 *   - https://ember-primitives.pages.dev/6-utils/createAsyncService.md
 */
import Application from &#39;ember-strict-application-resolver&#39;
import &#39;./app.css&#39;

export default class App extends Application {
  modules = {
    ...import.meta.glob(&#39;./router.*&#39;, { eager: true }),
    ...import.meta.glob(&#39;./templates/**/*&#39;, { eager: true }),
    ...import.meta.glob(&#39;./services/**/*&#39;, { eager: true }),
  }
}
">
<input type="hidden" name="project[files][app/config.ts]" value="interface Config {
  environment: &#39;development&#39; | &#39;production&#39;
  locationType: &#39;history&#39; | &#39;hash&#39; | &#39;none&#39; | &#39;auto&#39;
  rootURL: string
  EmberENV?: Record&lt;string, unknown&gt;
  APP: Record&lt;string, unknown&gt; &amp; { rootElement?: string; autoboot?: boolean }
}

const ENV: Config = {
  environment: import.meta.env.DEV ? &#39;development&#39; : &#39;production&#39;,
  rootURL: &#39;/&#39;,
  locationType: &#39;history&#39;,
  EmberENV: {},
  APP: {},
}

export default ENV
">
<input type="hidden" name="project[files][app/router.ts]" value="import EmbroiderRouter from &#39;@embroider/router&#39;
import config from &#39;#config&#39;

export default class Router extends EmbroiderRouter {
  location = config.locationType
  rootURL = config.rootURL
}

Router.map(function () {})

/**
 * Caveat:
 * - https://github.com/embroider-build/embroider/issues/2521
 *   We don&#39;t yet have a way to do this in a nice way
 *
 */
// function bundle(name: string, loader: () =&gt; Promise&lt;{ default: unknown }&gt;[]) {
//   return {
//     names: [name],
//     load: async () =&gt; {
//       const [template, route, controller] = await Promise.all(loader());
//       let slashName = name.replaceAll(&quot;.&quot;, &quot;/&quot;);
//       let results: Record&lt;string, unknown&gt; = {};

//       if (template) results[`./templates/${slashName}`] = template.default;
//       if (route) results[`./routes/${slashName}`] = route.default;
//       if (controller) results[`./controllers/${slashName}`] = controller.default;

//       return {
//         default: results,
//       };
//     },
//   };
// }

/**
 * Examples from:
 * - https://github.com/NullVoxPopuli/limber/blob/67e2f54bbe224052e38f9a9e566d704411e65e86/apps/repl/app/router.ts#L35
 */
// (window as any)._embroiderRouteBundles_ = [
// bundle(&quot;docs&quot;, () =&gt; [import(&quot;./templates/docs.gts&quot;)]),
// bundle(&quot;docs.repl-sdk&quot;, () =&gt; [import(&quot;./templates/docs/repl-sdk.gts&quot;)]),
// bundle(&quot;docs.ember-repl&quot;, () =&gt; [import(&quot;./templates/docs/ember-repl.gts&quot;)]),
// bundle(&quot;docs.embedding&quot;, () =&gt; [import(&quot;./templates/docs/embedding.gts&quot;)]),
// bundle(&quot;docs.editor&quot;, () =&gt; [import(&quot;./templates/docs/editor.gts&quot;)]),
// bundle(&quot;docs.whatever&quot;, () =&gt; [
//   import(&quot;./the/template.gts&quot;),
//   import(&quot;./the/route.ts&quot;),
//   import(&quot;./the/controller.ts&quot;),
// ]),
// ];
">
<input type="hidden" name="project[files][tests/e2e/smoke.spec.ts]" value="import { expect, test } from &#39;@playwright/test&#39;
import type { Locator, Page } from &#39;@playwright/test&#39;
import path from &#39;node:path&#39;
import { startExampleServer } from &#39;../../../../../tests/e2e/helpers/startExampleServer&#39;

const exampleDir = path.resolve()

function collectPageErrors(page: Page) {
  const errors: Array&lt;string&gt; = []

  page.on(&#39;pageerror&#39;, (error) =&gt; {
    errors.push(error.message)
  })

  page.on(&#39;console&#39;, (message) =&gt; {
    if (message.type() === &#39;error&#39;) {
      errors.push(message.text())
    }
  })

  return errors
}

async function openExample(page: Page) {
  const server = await startExampleServer(exampleDir)
  const errors = collectPageErrors(page)

  await page.route(
    &#39;https://unpkg.com/react-scan/dist/auto.global.js&#39;,
    (route) =&gt;
      route.fulfill({
        contentType: &#39;application/javascript&#39;,
        body: &#39;&#39;,
      }),
  )

  await page.goto(server.url)

  return { errors, server }
}

function getTable(page: Page) {
  return page
    .locator(&#39;table:visible, .divTable:visible&#39;)
    .filter({ has: page.locator(&#39;thead th, .thead .th&#39;) })
    .filter({ has: page.locator(&#39;tbody tr, .tbody .tr&#39;) })
    .first()
}

function getHeaderCells(table: Locator) {
  return table.locator(&#39;thead th, .thead .th&#39;)
}

function getBodyRows(table: Locator) {
  return table.locator(&#39;tbody tr, .tbody .tr&#39;)
}

async function getFirstBodyRowData(table: Locator) {
  const row = getBodyRows(table).first()
  const firstInput = row
    .locator(&#39;input:not([type=&quot;checkbox&quot;]):not([type=&quot;radio&quot;])&#39;)
    .first()

  if ((await firstInput.count()) &gt; 0 &amp;&amp; (await firstInput.isVisible())) {
    return firstInput.inputValue()
  }

  const text = await row.textContent()
  return text?.replace(/\s+/g, &#39; &#39;).trim() ?? &#39;&#39;
}

test(&#39;renders the table without crashing&#39;, async ({ page }) =&gt; {
  const { errors, server } = await openExample(page)

  try {
    const table = getTable(page)
    const bodyRows = getBodyRows(table)

    await expect(table).toBeVisible()
    await expect(getHeaderCells(table).first()).toBeVisible()
    await expect(bodyRows.first()).toBeVisible()

    const regenerateButton = page
      .getByRole(&#39;button&#39;, { name: /^Regenerate Data$/i })
      .first()

    if ((await regenerateButton.count()) &gt; 0) {
      await expect(regenerateButton).toBeVisible()

      const firstRowBefore = await getFirstBodyRowData(table)

      await regenerateButton.click()

      await expect
        .poll(() =&gt; getFirstBodyRowData(table))
        .not.toBe(firstRowBefore)
      await expect(bodyRows.first()).toBeVisible()
    }

    expect(errors).toEqual([])
  } finally {
    await server.close()
  }
})
">
<input type="hidden" name="project[files][app/utils/make-data.ts]" value="import { faker } from &#39;@faker-js/faker&#39;

export type Person = {
  firstName: string
  lastName: string
  age: number
  visits: number
  progress: number
  status: &#39;relationship&#39; | &#39;complicated&#39; | &#39;single&#39;
  subRows?: Array&lt;Person&gt;
}

const range = (len: number) =&gt; {
  const arr: Array&lt;number&gt; = []
  for (let i = 0; i &lt; len; i++) {
    arr.push(i)
  }
  return arr
}

const newPerson = (): Person =&gt; {
  return {
    firstName: faker.person.firstName(),
    lastName: faker.person.lastName(),
    age: faker.number.int(40),
    visits: faker.number.int(1000),
    progress: faker.number.int(100),
    status: faker.helpers.shuffle&lt;Person[&#39;status&#39;]&gt;([
      &#39;relationship&#39;,
      &#39;complicated&#39;,
      &#39;single&#39;,
    ])[0]!,
  }
}

export function makeData(...lens: Array&lt;number&gt;) {
  const makeDataLevel = (depth = 0): Array&lt;Person&gt; =&gt; {
    const len = lens[depth] ?? 0
    return range(len).map((): Person =&gt; {
      return {
        ...newPerson(),
        subRows: lens[depth + 1] ? makeDataLevel(depth + 1) : undefined,
      }
    })
  }
  return makeDataLevel()
}
">
<input type="hidden" name="project[files][app/templates/application.gts]" value="import Component from &#39;@glimmer/component&#39;
import { tracked } from &#39;@glimmer/tracking&#39;
import { on } from &#39;@ember/modifier&#39;
import {
  useTable,
  FlexRenderCell,
  FlexRenderHeader,
  FlexRenderFooter,
  tableFeatures,
  columnOrderingFeature,
  columnVisibilityFeature,
  createColumnHelper,
  type Column,
  type Row,
  type Cell,
} from &#39;@tanstack/ember-table&#39;
import { makeData, type Person } from &#39;../utils/make-data&#39;

const features = tableFeatures({
  columnOrderingFeature,
  columnVisibilityFeature,
})

const columnHelper = createColumnHelper&lt;typeof features, Person&gt;()

const columns = columnHelper.columns([
  columnHelper.group({
    id: &#39;name&#39;,
    header: &#39;Name&#39;,
    footer: (props) =&gt; props.column.id,
    columns: columnHelper.columns([
      columnHelper.accessor(&#39;firstName&#39;, {
        cell: (info) =&gt; info.getValue(),
        header: () =&gt; &#39;First Name&#39;,
        footer: (props) =&gt; props.column.id,
      }),
      columnHelper.accessor((row) =&gt; row.lastName, {
        id: &#39;lastName&#39;,
        cell: (info) =&gt; info.getValue(),
        header: () =&gt; &#39;Last Name&#39;,
        footer: (props) =&gt; props.column.id,
      }),
    ]),
  }),
  columnHelper.group({
    id: &#39;info&#39;,
    header: &#39;Info&#39;,
    footer: (props) =&gt; props.column.id,
    columns: columnHelper.columns([
      columnHelper.accessor(&#39;age&#39;, {
        header: () =&gt; &#39;Age&#39;,
        footer: (props) =&gt; props.column.id,
      }),
      columnHelper.group({
        id: &#39;moreInfo&#39;,
        header: &#39;More Info&#39;,
        columns: columnHelper.columns([
          columnHelper.accessor(&#39;visits&#39;, {
            header: () =&gt; &#39;Visits&#39;,
            footer: (props) =&gt; props.column.id,
          }),
          columnHelper.accessor(&#39;status&#39;, {
            header: &#39;Status&#39;,
            footer: (props) =&gt; props.column.id,
          }),
          columnHelper.accessor(&#39;progress&#39;, {
            header: &#39;Profile Progress&#39;,
            footer: (props) =&gt; props.column.id,
          }),
        ]),
      }),
    ]),
  }),
])

// TanStack Table v9 uses prototype-based methods that require `this` binding.
// Ember templates extract function references without binding, so we provide
// helpers that call methods on the correct object.
const getVisibleCells = (
  row: Row&lt;typeof features, Person&gt;,
): Array&lt;Cell&lt;typeof features, Person&gt;&gt; =&gt; row.getVisibleCells()

const getIsVisible = (column: Column&lt;typeof features, Person&gt;): boolean =&gt;
  column.getIsVisible()

const toggleColumnVisibility = (column: Column&lt;typeof features, Person&gt;) =&gt; {
  return (event: Event) =&gt; {
    column.getToggleVisibilityHandler()(event)
  }
}

const shuffle = &lt;T,&gt;(arr: Array&lt;T&gt;): Array&lt;T&gt; =&gt; {
  const result = [...arr]
  for (let i = result.length - 1; i &gt; 0; i--) {
    const j = Math.floor(Math.random() * (i + 1))
    ;[result[i], result[j]] = [result[j]!, result[i]!]
  }
  return result
}

export default class ColumnOrderingTable extends Component {
  @tracked data: Array&lt;Person&gt; = makeData(20)

  table = useTable(() =&gt; ({
    features,
    columns,
    data: this.data,
    // initialState: { columnOrder: [&#39;lastName&#39;, &#39;firstName&#39;] }, // set column order on first render
    // atoms: { columnOrder: columnOrderAtom }, // preferred: own ordering state with an external atom
    // state: { columnOrder }, // classic controlled state; pair with onColumnOrderChange
    // onColumnOrderChange: setColumnOrder,
  }))

  get headerGroups() {
    return this.table.getHeaderGroups()
  }

  get rows() {
    return this.table.getRowModel().rows
  }

  get footerGroups() {
    return this.table.getFooterGroups()
  }

  get leafColumns() {
    return this.table.getAllLeafColumns()
  }

  get isAllColumnsVisible() {
    return this.table.getIsAllColumnsVisible()
  }

  get tableState() {
    return JSON.stringify(this.table.store.state, null, 2)
  }

  refreshData = () =&gt; {
    this.data = makeData(20)
  }

  stressTest = () =&gt; {
    this.data = makeData(1_000)
  }

  toggleAllColumnsVisibility = (event: Event) =&gt; {
    this.table.getToggleAllColumnsVisibilityHandler()(event)
  }

  shuffleColumns = () =&gt; {
    this.table.setColumnOrder(
      shuffle(this.table.getAllLeafColumns().map((column) =&gt; column.id)),
    )
  }

  resetOrder = () =&gt; {
    this.table.resetColumnOrder()
  }

  &lt;template&gt;
    &lt;div class=&#39;column-toggle-panel&#39;&gt;
      &lt;div class=&#39;column-toggle-panel-header&#39;&gt;
        &lt;label&gt;
          &lt;input
            type=&#39;checkbox&#39;
            checked={{this.isAllColumnsVisible}}
            {{on &#39;change&#39; this.toggleAllColumnsVisibility}}
          /&gt;
          Toggle All
        &lt;/label&gt;
      &lt;/div&gt;

      {{#each this.leafColumns as |column|}}
        &lt;div class=&#39;column-toggle-row&#39;&gt;
          &lt;label&gt;
            &lt;input
              type=&#39;checkbox&#39;
              checked={{getIsVisible column}}
              {{on &#39;change&#39; (toggleColumnVisibility column)}}
            /&gt;
            {{column.id}}
          &lt;/label&gt;
        &lt;/div&gt;
      {{/each}}
    &lt;/div&gt;

    &lt;div class=&#39;spacer-md&#39;&gt;&lt;/div&gt;
    &lt;div class=&#39;button-row&#39;&gt;
      &lt;button
        class=&#39;demo-button demo-button-sm&#39;
        {{on &#39;click&#39; this.refreshData}}
      &gt;Regenerate Data&lt;/button&gt;
      &lt;button
        class=&#39;demo-button demo-button-sm&#39;
        {{on &#39;click&#39; this.stressTest}}
      &gt;Stress Test (1k rows)&lt;/button&gt;
      &lt;button
        class=&#39;demo-button demo-button-sm&#39;
        {{on &#39;click&#39; this.shuffleColumns}}
      &gt;Shuffle Columns&lt;/button&gt;
      &lt;button
        class=&#39;demo-button demo-button-sm&#39;
        {{on &#39;click&#39; this.resetOrder}}
      &gt;Reset Order&lt;/button&gt;
    &lt;/div&gt;

    &lt;table&gt;
      &lt;thead&gt;
        {{#each this.headerGroups as |headerGroup|}}
          &lt;tr&gt;
            {{#each headerGroup.headers as |header|}}
              &lt;th colspan={{header.colSpan}}&gt;
                {{#unless header.isPlaceholder}}
                  &lt;FlexRenderHeader @header={{header}} /&gt;
                {{/unless}}
              &lt;/th&gt;
            {{/each}}
          &lt;/tr&gt;
        {{/each}}
      &lt;/thead&gt;
      &lt;tbody&gt;
        {{#each this.rows as |row|}}
          &lt;tr&gt;
            {{#each (getVisibleCells row) as |cell|}}
              &lt;td&gt;&lt;FlexRenderCell @cell={{cell}} /&gt;&lt;/td&gt;
            {{/each}}
          &lt;/tr&gt;
        {{/each}}
      &lt;/tbody&gt;
      &lt;tfoot&gt;
        {{#each this.footerGroups as |footerGroup|}}
          &lt;tr&gt;
            {{#each footerGroup.headers as |header|}}
              &lt;th colspan={{header.colSpan}}&gt;
                {{#unless header.isPlaceholder}}
                  &lt;FlexRenderFooter @footer={{header}} /&gt;
                {{/unless}}
              &lt;/th&gt;
            {{/each}}
          &lt;/tr&gt;
        {{/each}}
      &lt;/tfoot&gt;
    &lt;/table&gt;

    &lt;div class=&#39;spacer-md&#39;&gt;&lt;/div&gt;
    &lt;pre data-testid=&#39;table-state&#39;&gt;{{this.tableState}}&lt;/pre&gt;
  &lt;/template&gt;
}
">
<input type="hidden" name="project[description]" value="generated by https://pkg.pr.new">
<input type="hidden" name="project[template]" value="node">
<input type="hidden" name="project[title]" value="tanstack-ember-table-example-column-ordering">
</form>
<script>document.getElementById("mainForm").submit();</script>

</body></html>